future-private: add placeTpSlOrder request
This commit is contained in:
1 parent
526ef64ad8
commit
bf185918e1
5 files changed
+635
-1
No files matched your search
@@ -11,9 +11,10 @@ use Msr\LaravelBitunixApi\Requests\GetPendingPositionsRequestContract;
|
||||
use Msr\LaravelBitunixApi\Requests\GetSingleAccountRequestContract;
|
||||
use Msr\LaravelBitunixApi\Requests\Header;
|
||||
use Msr\LaravelBitunixApi\Requests\PlaceOrderRequestContract;
|
||||
use Msr\LaravelBitunixApi\Requests\PlaceTpSlOrderRequestContract;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
|
||||
class LaravelBitunixApi implements ChangeLeverageRequestContract, ChangeMarginModeRequestContract, FlashClosePositionRequestContract, FutureKLineRequestContract, GetPendingPositionsRequestContract, GetSingleAccountRequestContract, PlaceOrderRequestContract
|
||||
class LaravelBitunixApi implements ChangeLeverageRequestContract, ChangeMarginModeRequestContract, FlashClosePositionRequestContract, FutureKLineRequestContract, GetPendingPositionsRequestContract, GetSingleAccountRequestContract, PlaceOrderRequestContract, PlaceTpSlOrderRequestContract
|
||||
{
|
||||
private Client $publicFutureClient;
|
||||
|
||||
@@ -201,4 +202,62 @@ class LaravelBitunixApi implements ChangeLeverageRequestContract, ChangeMarginMo
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
public function placeTpSlOrder(
|
||||
string $symbol,
|
||||
string $positionId,
|
||||
?string $tpPrice = null,
|
||||
?string $tpStopType = null,
|
||||
?string $slPrice = null,
|
||||
?string $slStopType = null,
|
||||
?string $tpOrderType = null,
|
||||
?string $tpOrderPrice = null,
|
||||
?string $slOrderType = null,
|
||||
?string $slOrderPrice = null,
|
||||
?string $tpQty = null,
|
||||
?string $slQty = null
|
||||
): ResponseInterface {
|
||||
$body = [
|
||||
'symbol' => $symbol,
|
||||
'positionId' => $positionId,
|
||||
];
|
||||
|
||||
// Add optional parameters if provided
|
||||
if ($tpPrice !== null) {
|
||||
$body['tpPrice'] = $tpPrice;
|
||||
}
|
||||
if ($tpStopType !== null) {
|
||||
$body['tpStopType'] = $tpStopType;
|
||||
}
|
||||
if ($slPrice !== null) {
|
||||
$body['slPrice'] = $slPrice;
|
||||
}
|
||||
if ($slStopType !== null) {
|
||||
$body['slStopType'] = $slStopType;
|
||||
}
|
||||
if ($tpOrderType !== null) {
|
||||
$body['tpOrderType'] = $tpOrderType;
|
||||
}
|
||||
if ($tpOrderPrice !== null) {
|
||||
$body['tpOrderPrice'] = $tpOrderPrice;
|
||||
}
|
||||
if ($slOrderType !== null) {
|
||||
$body['slOrderType'] = $slOrderType;
|
||||
}
|
||||
if ($slOrderPrice !== null) {
|
||||
$body['slOrderPrice'] = $slOrderPrice;
|
||||
}
|
||||
if ($tpQty !== null) {
|
||||
$body['tpQty'] = $tpQty;
|
||||
}
|
||||
if ($slQty !== null) {
|
||||
$body['slQty'] = $slQty;
|
||||
}
|
||||
|
||||
$response = $this->getPrivateFutureClient([], $body)->post('tpsl/place_order', [
|
||||
'json' => $body,
|
||||
]);
|
||||
|
||||
return $response;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace Msr\LaravelBitunixApi\Requests;
|
||||
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
|
||||
interface PlaceTpSlOrderRequestContract
|
||||
{
|
||||
/**
|
||||
* Place TP/SL Order
|
||||
*
|
||||
* @param string $symbol Trading pair
|
||||
* @param string $positionId Position ID associated with take-profit and stop-loss
|
||||
* @param string|null $tpPrice Take-profit trigger price
|
||||
* @param string|null $tpStopType Take-profit trigger type (LAST_PRICE/MARK_PRICE)
|
||||
* @param string|null $slPrice Stop-loss trigger price
|
||||
* @param string|null $slStopType Stop-loss trigger type (LAST_PRICE/MARK_PRICE)
|
||||
* @param string|null $tpOrderType Take-profit order type (LIMIT/MARKET)
|
||||
* @param string|null $tpOrderPrice Take-profit order price
|
||||
* @param string|null $slOrderType Stop-loss order type (LIMIT/MARKET)
|
||||
* @param string|null $slOrderPrice Stop-loss order price
|
||||
* @param string|null $tpQty Take-profit order quantity (base coin)
|
||||
* @param string|null $slQty Stop-loss order quantity (base coin)
|
||||
*/
|
||||
public function placeTpSlOrder(
|
||||
string $symbol,
|
||||
string $positionId,
|
||||
?string $tpPrice = null,
|
||||
?string $tpStopType = null,
|
||||
?string $slPrice = null,
|
||||
?string $slStopType = null,
|
||||
?string $tpOrderType = null,
|
||||
?string $tpOrderPrice = null,
|
||||
?string $slOrderType = null,
|
||||
?string $slOrderPrice = null,
|
||||
?string $tpQty = null,
|
||||
?string $slQty = null
|
||||
): ResponseInterface;
|
||||
}
|
||||
Reference in new issue
Block a user