Skip to content

Commit 61f72e1

Browse files
authored
Merge pull request #15 from fieyum/master
api upgrade update
2 parents ec44ba6 + 0a57632 commit 61f72e1

File tree

6 files changed

+92
-2
lines changed

6 files changed

+92
-2
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,7 @@ go(function () {
247247
| KuCoin\Futures\SDK\PrivateApi\Order::getDetail() | YES | https://docs.kucoin.com/futures/#get-details-of-a-single-order |
248248
| KuCoin\Futures\SDK\PrivateApi\Order::getDetailByClientOid() | YES | https://docs.kucoin.com/futures/#get-details-of-a-single-order |
249249
| KuCoin\Futures\SDK\PrivateApi\Order::getOpenOrderStatistics() | YES | https://docs.kucoin.com/futures/#active-order-value-calculation |
250+
| KuCoin\Futures\SDK\PrivateApi\Order::cancelByClientOid() | YES | https://www.kucoin.com/docs/rest/futures-trading/orders/cancel-order-by-clientoid|
250251

251252
</details>
252253
<details>
@@ -311,6 +312,7 @@ go(function () {
311312
| KuCoin\Futures\SDK\PublicApi\Symbol::getKLines() | NO | https://docs.kucoin.com/futures/?lang=en_US#get-k-line-data-of-contract |
312313
| KuCoin\Futures\SDK\PublicApi\Symbol::getLevel2Depth20 | NO | https://docs.kucoin.com/futures/cn/#level-2-2 |
313314
| KuCoin\Futures\SDK\PublicApi\Symbol::getLevel2Depth100 | NO | https://docs.kucoin.com/futures/cn/#level-2-2 |
315+
| KuCoin\Futures\SDK\PublicApi\Symbol::getFundingRates | NO |https://www.kucoin.com/docs/rest/futures-trading/funding-fees/get-public-funding-history |
314316

315317
</details>
316318

src/Api.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@ abstract class Api
1616
/**
1717
* @var string SDK Version
1818
*/
19-
const VERSION = '1.0.22';
19+
const VERSION = '1.0.23';
2020

2121
/**
2222
* @var string SDK update date
2323
*/
24-
const UPDATE_DATE = '2023.07.17';
24+
const UPDATE_DATE = '2024.01.05';
2525

2626
/**
2727
* @var string

src/PrivateApi/Order.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
namespace KuCoin\Futures\SDK\PrivateApi;
44

5+
use KuCoin\Futures\SDK\Exceptions\BusinessException;
6+
use KuCoin\Futures\SDK\Exceptions\HttpException;
7+
use KuCoin\Futures\SDK\Exceptions\InvalidApiUriException;
58
use KuCoin\Futures\SDK\Http\Request;
69
use KuCoin\Futures\SDK\KuCoinFuturesApi;
710

@@ -164,4 +167,20 @@ public function getDetailByClientOid($clientOid)
164167
$response = $this->call(Request::METHOD_GET, '/api/v1/orders/' . $clientOid, ['clientOid' => $clientOid]);
165168
return $response->getApiData();
166169
}
170+
171+
/**
172+
* Cancel Order by clientOid.
173+
*
174+
* @param $clientOid
175+
* @param $symbol
176+
* @return array
177+
* @throws BusinessException
178+
* @throws HttpException
179+
* @throws InvalidApiUriException
180+
*/
181+
public function cancelByClientOid($clientOid, $symbol)
182+
{
183+
$response = $this->call(Request::METHOD_DELETE, '/api/v1/orders/client-order/' . $clientOid, ['symbol' => $symbol]);
184+
return $response->getApiData();
185+
}
167186
}

src/PublicApi/Symbol.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,4 +178,22 @@ public function getLevel2Depth100($symbol)
178178
$response = $this->call(Request::METHOD_GET, '/api/v1/level2/depth100', ['symbol' => $symbol]);
179179
return $response->getApiData();
180180
}
181+
182+
/**
183+
* Get Public Funding History.
184+
*
185+
* @param $symbol
186+
* @param $from
187+
* @param $to
188+
* @return mixed|null
189+
* @throws \KuCoin\Futures\SDK\Exceptions\BusinessException
190+
* @throws \KuCoin\Futures\SDK\Exceptions\HttpException
191+
* @throws \KuCoin\Futures\SDK\Exceptions\InvalidApiUriException
192+
*/
193+
public function getFundingRates($symbol, $from, $to)
194+
{
195+
$params = compact('symbol', 'from', 'to');
196+
$response = $this->call(Request::METHOD_GET, '/api/v1/contract/funding-rates', $params);
197+
return $response->getApiData();
198+
}
181199
}

tests/OrderTest.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,4 +258,33 @@ public function testGetDetailByClientOid(Order $api)
258258
$this->assertArrayHasKey('updatedAt', $order);
259259
$this->assertArrayHasKey('orderTime', $order);
260260
}
261+
262+
/**
263+
* @dataProvider apiProvider
264+
* @param Order $api
265+
* @throws \KuCoin\Futures\SDK\Exceptions\BusinessException
266+
* @throws \KuCoin\Futures\SDK\Exceptions\HttpException
267+
* @throws \KuCoin\Futures\SDK\Exceptions\InvalidApiUriException
268+
*/
269+
public function testCancelByClientOid($api)
270+
{
271+
$clientId = uniqid();
272+
$symbol = 'DOTUSDTM';
273+
$order = [
274+
'clientOid' => $clientId,
275+
'type' => 'limit',
276+
'side' => 'buy',
277+
'symbol' => $symbol,
278+
'leverage' => 5,
279+
'remark' => 'test cancel order',
280+
281+
'price' => 6,
282+
'size' => 1,
283+
];
284+
285+
$api->create($order);
286+
$result = $api->cancelByClientOid($clientId, $symbol);
287+
$this->assertInternalType('array', $result);
288+
$this->assertArrayHasKey('clientOid', $result);
289+
}
261290
}

tests/SymbolTest.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,4 +176,26 @@ public function testGetLevel2Depth100(Symbol $api)
176176
$this->assertInternalType('array', $data['asks']);
177177
$this->assertInternalType('array', $data['bids']);
178178
}
179+
180+
/**
181+
* @dataProvider apiProvider
182+
* @param Symbol $api
183+
* @return void
184+
* @throws \KuCoin\Futures\SDK\Exceptions\BusinessException
185+
* @throws \KuCoin\Futures\SDK\Exceptions\HttpException
186+
* @throws \KuCoin\Futures\SDK\Exceptions\InvalidApiUriException
187+
*/
188+
public function testGetFundingRates(Symbol $api)
189+
{
190+
$from = strtotime(date('Y-m-d', time() - 86400));
191+
$to = $from + 86400;
192+
$data = $api->getFundingRates('ETHUSDTM', $from * 1000, $to * 1000);
193+
$this->assertInternalType('array', $data);
194+
foreach ($data as $item) {
195+
$this->assertInternalType('array', $item);
196+
$this->assertArrayHasKey('symbol', $item);
197+
$this->assertArrayHasKey('fundingRate', $item);
198+
$this->assertArrayHasKey('timepoint', $item);
199+
}
200+
}
179201
}

0 commit comments

Comments
 (0)