Skip to content

Commit

Permalink
Merge pull request #121 from Hugo-Doe/master
Browse files Browse the repository at this point in the history
add endpoint /api/v1/risk/limit/strategy
  • Loading branch information
hhxsv5 authored Feb 21, 2022
2 parents a028178 + 6522d9d commit 773f589
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Api.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ abstract class Api
/**
* @var string SDK Version
*/
const VERSION = '1.1.24';
const VERSION = '1.1.25';

/**
* @var string SDK update date
*/
const UPDATE_DATE = '2021.12.02';
const UPDATE_DATE = '2022.02.21';

/**
* @var string
Expand Down
15 changes: 15 additions & 0 deletions src/PrivateApi/Margin.php
Original file line number Diff line number Diff line change
Expand Up @@ -301,4 +301,19 @@ public function getTradeLast($currency)
$response = $this->call(Request::METHOD_GET, '/api/v1/margin/trade/last', compact('currency'));
return $response->getApiData();
}

/**
* This endpoint can query the cross/isolated margin risk limit.
* This endpoint requires the "General" permission
* @param string $marginModel corss(corss margin), isolated (isolated margin)
* @return mixed
* @throws \KuCoin\SDK\Exceptions\BusinessException
* @throws \KuCoin\SDK\Exceptions\HttpException
* @throws \KuCoin\SDK\Exceptions\InvalidApiUriException
*/
public function getStrategyRiskLimit(string $marginModel)
{
$response = $this->call(Request::METHOD_GET, '/api/v1/risk/limit/strategy', ['marginModel' => $marginModel]);
return $response->getApiData();
}
}
1 change: 1 addition & 0 deletions src/PrivateApi/Order.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ public function getList(array $params = [], array $pagination = [])

/**
* Get v1 historical orders list
* @deprecated
* @param array $params
* @param array $pagination
* @return array
Expand Down
18 changes: 18 additions & 0 deletions tests/PrivateApi/MarginTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -371,4 +371,22 @@ public function testGetTradeLast(Margin $api)
$this->assertArrayHasKey('dailyIntRate', $data[0]);
}
}

/**
* @dataProvider apiProvider
* @param Margin $api
* @throws \KuCoin\SDK\Exceptions\BusinessException
* @throws \KuCoin\SDK\Exceptions\HttpException
* @throws \KuCoin\SDK\Exceptions\InvalidApiUriException
*/
public function testGetStrategyRiskLimit(Margin $api)
{
$data = $api->getStrategyRiskLimit('cross');
if (!empty($data)) {
$this->assertArrayHasKey('currency', $data[0]);
$this->assertArrayHasKey('borrowMaxAmount', $data[0]);
$this->assertArrayHasKey('buyMaxAmount', $data[0]);
$this->assertArrayHasKey('precision', $data[0]);
}
}
}

0 comments on commit 773f589

Please sign in to comment.