future-public: add set leverage request
This commit is contained in:
1 parent
bea493935b
commit
0996c5fc27
9 files changed
+377
-25
No files matched your search
@@ -4,9 +4,11 @@ namespace Msr\LaravelBitunixApi;
|
||||
|
||||
use GuzzleHttp\Client;
|
||||
use Msr\LaravelBitunixApi\Requests\FutureKLineRequestContract;
|
||||
use Msr\LaravelBitunixApi\Requests\ChangeLeverageRequestContract;
|
||||
use Msr\LaravelBitunixApi\Requests\Header;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
|
||||
class LaravelBitunixApi implements FutureKLineRequestContract
|
||||
class LaravelBitunixApi implements FutureKLineRequestContract, ChangeLeverageRequestContract
|
||||
{
|
||||
private Client $publicFutureClient;
|
||||
|
||||
@@ -17,6 +19,17 @@ class LaravelBitunixApi implements FutureKLineRequestContract
|
||||
]);
|
||||
}
|
||||
|
||||
protected function getPrivateFutureClient(array $queryParams = [], array $body = []): Client
|
||||
{
|
||||
$bodyString = json_encode($body);
|
||||
$headers = Header::generateHeaders($queryParams, $bodyString);
|
||||
|
||||
return new Client([
|
||||
'base_uri' => config('bitunix-api.future_base_uri').'/api/v1/futures/',
|
||||
'headers' => $headers,
|
||||
]);
|
||||
}
|
||||
|
||||
public function getFutureKline(string $symbol, string $interval, int $limit = 100, ?int $startTime = null, ?int $endTime = null, string $type = 'LAST_PRICE'): ResponseInterface
|
||||
{
|
||||
$response = $this->publicFutureClient->get('kline', [
|
||||
@@ -32,4 +45,19 @@ class LaravelBitunixApi implements FutureKLineRequestContract
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
public function changeLeverage(string $symbol, string $marginCoin, int $leverage): ResponseInterface
|
||||
{
|
||||
$body = [
|
||||
'symbol' => $symbol,
|
||||
'marginCoin' => $marginCoin,
|
||||
'leverage' => $leverage,
|
||||
];
|
||||
|
||||
$response = $this->getPrivateFutureClient([], $body)->post('account/change_leverage', [
|
||||
'json' => $body,
|
||||
]);
|
||||
|
||||
return $response;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user