Skip to content

Commit e10881f

Browse files
authored
Merge pull request #17 from fieyum/master
feat: update version
2 parents 27ca0f0 + a023b2a commit e10881f

File tree

10 files changed

+408
-24
lines changed

10 files changed

+408
-24
lines changed

README.md

Lines changed: 47 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -237,34 +237,50 @@ go(function () {
237237

238238
</details>
239239

240+
241+
<details>
242+
<summary>KuCoin\Futures\SDK\PrivateApi\Fee</summary>
243+
244+
| API | Authentication | Description |
245+
|---------------------------------------------------|----------------|------------------------------------------------------------------------------------|
246+
| KuCoin\Futures\SDK\PrivateApi\Fee::getTradeFees() | YES | https://www.kucoin.com/docs/rest/funding/trade-fee/trading-pair-actual-fee-futures |
247+
248+
</details>
249+
240250
<details>
241251
<summary>KuCoin\Futures\SDK\PrivateApi\Order</summary>
242252

243-
| API | Authentication | Description |
244-
|---------------------------------------------------------------|----------------|-----------------------------------------------------------------------------------|
245-
| KuCoin\Futures\SDK\PrivateApi\Order::create() | YES | https://docs.kucoin.com/futures/#place-an-order |
246-
| KuCoin\Futures\SDK\PrivateApi\Order::cancel() | YES | https://docs.kucoin.com/futures/#cancel-an-order |
247-
| KuCoin\Futures\SDK\PrivateApi\Order::batchCancel() | YES | https://docs.kucoin.com/futures/#limit-order-mass-cancelation |
248-
| KuCoin\Futures\SDK\PrivateApi\Order::stopOrders() | YES | https://docs.kucoin.com/futures/#stop-order-mass-cancelation |
249-
| KuCoin\Futures\SDK\PrivateApi\Order::getList() | YES | https://docs.kucoin.com/futures/#get-order-list |
250-
| KuCoin\Futures\SDK\PrivateApi\Order::getStopOrders() | YES | https://docs.kucoin.com/futures/#get-untriggered-stop-order-list |
251-
| KuCoin\Futures\SDK\PrivateApi\Order::getRecentDoneOrders() | YES | https://docs.kucoin.com/futures/#get-list-of-orders-completed-in-24h |
252-
| KuCoin\Futures\SDK\PrivateApi\Order::getDetail() | YES | https://docs.kucoin.com/futures/#get-details-of-a-single-order |
253-
| KuCoin\Futures\SDK\PrivateApi\Order::getDetailByClientOid() | YES | https://docs.kucoin.com/futures/#get-details-of-a-single-order |
254-
| KuCoin\Futures\SDK\PrivateApi\Order::getOpenOrderStatistics() | YES | https://docs.kucoin.com/futures/#active-order-value-calculation |
255-
| KuCoin\Futures\SDK\PrivateApi\Order::cancelByClientOid() | YES | https://www.kucoin.com/docs/rest/futures-trading/orders/cancel-order-by-clientoid |
256-
| KuCoin\Futures\SDK\PrivateApi\Order::createTest() | YES | https://www.kucoin.com/docs/rest/futures-trading/orders/place-order-test |
253+
| API | Authentication | Description |
254+
|---------------------------------------------------------------|----------------|-----------------------------------------------------------------------------------------------|
255+
| KuCoin\Futures\SDK\PrivateApi\Order::create() | YES | https://docs.kucoin.com/futures/#place-an-order |
256+
| KuCoin\Futures\SDK\PrivateApi\Order::cancel() | YES | https://docs.kucoin.com/futures/#cancel-an-order |
257+
| KuCoin\Futures\SDK\PrivateApi\Order::batchCancel() | YES | https://docs.kucoin.com/futures/#limit-order-mass-cancelation |
258+
| KuCoin\Futures\SDK\PrivateApi\Order::stopOrders() | YES | https://docs.kucoin.com/futures/#stop-order-mass-cancelation |
259+
| KuCoin\Futures\SDK\PrivateApi\Order::getList() | YES | https://docs.kucoin.com/futures/#get-order-list |
260+
| KuCoin\Futures\SDK\PrivateApi\Order::getStopOrders() | YES | https://docs.kucoin.com/futures/#get-untriggered-stop-order-list |
261+
| KuCoin\Futures\SDK\PrivateApi\Order::getRecentDoneOrders() | YES | https://docs.kucoin.com/futures/#get-list-of-orders-completed-in-24h |
262+
| KuCoin\Futures\SDK\PrivateApi\Order::getDetail() | YES | https://docs.kucoin.com/futures/#get-details-of-a-single-order |
263+
| KuCoin\Futures\SDK\PrivateApi\Order::getDetailByClientOid() | YES | https://docs.kucoin.com/futures/#get-details-of-a-single-order |
264+
| KuCoin\Futures\SDK\PrivateApi\Order::getOpenOrderStatistics() | YES | https://docs.kucoin.com/futures/#active-order-value-calculation |
265+
| KuCoin\Futures\SDK\PrivateApi\Order::cancelByClientOid() | YES | https://www.kucoin.com/docs/rest/futures-trading/orders/cancel-order-by-clientoid |
266+
| KuCoin\Futures\SDK\PrivateApi\Order::createTest() | YES | https://www.kucoin.com/docs/rest/futures-trading/orders/place-order-test |
267+
| KuCoin\Futures\SDK\PrivateApi\Order::createStOrder() | YES | https://www.kucoin.com/docs/rest/futures-trading/orders/place-take-profit-and-stop-loss-order |
268+
| KuCoin\Futures\SDK\PrivateApi\Order::createMultiOrders() | YES | https://www.kucoin.com/docs/rest/futures-trading/orders/place-multiple-orders |
257269

258270
</details>
259271
<details>
260272
<summary>KuCoin\Futures\SDK\PrivateApi\Position</summary>
261273

262-
| API | Authentication | Description |
263-
|------------------------------------------------------------------|----------------|------------------------------------------------------------------------|
264-
| KuCoin\Futures\SDK\PrivateApi\Position::getList() | YES | https://docs.kucoin.com/futures/#get-position-list |
265-
| KuCoin\Futures\SDK\PrivateApi\Position::getDetail() | YES | https://docs.kucoin.com/futures/#get-position-details |
266-
| KuCoin\Futures\SDK\PrivateApi\Position::changeAutoAppendStatus() | YES | https://docs.kucoin.com/futures/#enable-disable-of-auto-deposit-margin |
267-
| KuCoin\Futures\SDK\PrivateApi\Position::marginAppend() | YES | https://docs.kucoin.com/futures/#add-margin-manually |
274+
| API | Authentication | Description |
275+
|------------------------------------------------------------------|----------------|-------------------------------------------------------------------------------------------|
276+
| KuCoin\Futures\SDK\PrivateApi\Position::getList() | YES | https://docs.kucoin.com/futures/#get-position-list |
277+
| KuCoin\Futures\SDK\PrivateApi\Position::getDetail() | YES | https://docs.kucoin.com/futures/#get-position-details |
278+
| KuCoin\Futures\SDK\PrivateApi\Position::changeAutoAppendStatus() | YES | https://docs.kucoin.com/futures/#enable-disable-of-auto-deposit-margin |
279+
| KuCoin\Futures\SDK\PrivateApi\Position::marginAppend() | YES | https://docs.kucoin.com/futures/#add-margin-manually |
280+
| KuCoin\Futures\SDK\PrivateApi\Position::getMaxWithdrawMargin() | YES | https://www.kucoin.com/docs/rest/futures-trading/positions/get-max-withdraw-margin |
281+
| KuCoin\Futures\SDK\PrivateApi\Position::withdrawMargin() | YES | https://www.kucoin.com/docs/rest/futures-trading/positions/remove-margin-manually |
282+
| KuCoin\Futures\SDK\PrivateApi\Position::getHistoryPositions() | YES | https://www.kucoin.com/docs/rest/futures-trading/positions/get-positions-history |
283+
| KuCoin\Futures\SDK\PrivateApi\Position::getMaxOpenSize() | YES | https://www.kucoin.com/docs/rest/futures-trading/positions/get-maximum-open-position-size |
268284

269285
</details>
270286

@@ -323,6 +339,17 @@ go(function () {
323339

324340
</details>
325341

342+
<details>
343+
<summary>KuCoin\Futures\SDK\PublicApi\Contract</summary>
344+
345+
| API | Authentication | Description |
346+
|--------------------------------------------------------|----------------|--------------------------------------------------------------------------------------------------|
347+
| KuCoin\Futures\SDK\PublicApi\Contract::getList() | NO | https://www.kucoin.com/docs/rest/futures-trading/market-data/get-symbols-list |
348+
| KuCoin\Futures\SDK\PublicApi\Contract::getDetail() | NO | https://www.kucoin.com/docs/rest/futures-trading/market-data/get-symbol-detail |
349+
| KuCoin\Futures\SDK\PublicApi\Contract::getAllTickers() | NO | https://www.kucoin.com/docs/rest/futures-trading/market-data/get-latest-ticker-for-all-contracts |
350+
351+
</details>
352+
326353
<details>
327354
<summary>KuCoin\Futures\SDK\PublicApi\Time</summary>
328355

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.24';
19+
const VERSION = '1.0.25';
2020

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

2626
/**
2727
* @var string

src/PrivateApi/Fee.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
3+
namespace KuCoin\Futures\SDK\PrivateApi;
4+
5+
use KuCoin\Futures\SDK\Http\Request;
6+
use KuCoin\Futures\SDK\KuCoinFuturesApi;
7+
8+
/**
9+
* Class Fill
10+
* @package KuCoin\Futures\SDK\PrivateApi
11+
* @see https://www.kucoin.com/docs/rest/funding/trade-fee/trading-pair-actual-fee-futures
12+
*/
13+
class Fee extends KuCoinFuturesApi
14+
{
15+
/**
16+
* This interface is for the actual fee rate of the trading pair. The fee rate of your sub-account is the same as that of the master account.
17+
*
18+
* @param $symbol
19+
* @return mixed|null
20+
* @throws \KuCoin\Futures\SDK\Exceptions\BusinessException
21+
* @throws \KuCoin\Futures\SDK\Exceptions\HttpException
22+
* @throws \KuCoin\Futures\SDK\Exceptions\InvalidApiUriException
23+
*/
24+
public function getTradeFees($symbol)
25+
{
26+
$response = $this->call(Request::METHOD_GET, '/api/v1/trade-fees', compact('symbol'));
27+
return $response->getApiData();
28+
}
29+
}

src/PrivateApi/Order.php

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,4 +198,38 @@ public function createTest(array $order)
198198
$response = $this->call(Request::METHOD_POST, '/api/v1/orders/test', $order);
199199
return $response->getApiData();
200200
}
201+
202+
/**
203+
* You can place up to 20 orders at one time, including limit orders, market orders, and stop orders.
204+
*
205+
* @param array $orders
206+
* @return mixed|null
207+
* @throws BusinessException
208+
* @throws HttpException
209+
* @throws InvalidApiUriException
210+
*/
211+
public function createMultiOrders(array $orders)
212+
{
213+
$response = $this->call(Request::METHOD_POST, '/api/v1/orders/multi', $orders);
214+
return $response->getApiData();
215+
}
216+
217+
/**
218+
* This interface supports both take-profit and stop-loss functions, and other functions are exactly the same as the place order interface.
219+
*
220+
* You can place two types of orders: limit and market. Orders can only be placed if your account has sufficient funds. Once an order is placed, your funds will be put on hold for the duration of the order. The amount of funds on hold depends on the order type and parameters specified.
221+
*
222+
* Please be noted that the system would hold the fees from the orders entered the orderbook in advance. Read Get Fills to learn more.
223+
*
224+
* @param array $order
225+
* @return mixed|null
226+
* @throws BusinessException
227+
* @throws HttpException
228+
* @throws InvalidApiUriException
229+
*/
230+
public function createStOrder(array $order)
231+
{
232+
$response = $this->call(Request::METHOD_POST, '/api/v1/st-orders', $order);
233+
return $response->getApiData();
234+
}
201235
}

src/PrivateApi/Position.php

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,4 +95,66 @@ public function marginAppend(array $params)
9595
return $response->getApiData();
9696
}
9797

98+
99+
/**
100+
* Get Max Withdraw Margin.
101+
*
102+
* @param $symbol
103+
* @return mixed|null
104+
* @throws \KuCoin\Futures\SDK\Exceptions\BusinessException
105+
* @throws \KuCoin\Futures\SDK\Exceptions\HttpException
106+
* @throws \KuCoin\Futures\SDK\Exceptions\InvalidApiUriException
107+
*/
108+
public function getMaxWithdrawMargin($symbol)
109+
{
110+
$response = $this->call(Request::METHOD_GET, '/api/v1/margin/maxWithdrawMargin', compact('symbol'));
111+
return $response->getApiData();
112+
}
113+
114+
/**
115+
* Remove Margin Manually.
116+
*
117+
* @param $symbol
118+
* @param $withdrawAmount
119+
* @return mixed|null
120+
* @throws \KuCoin\Futures\SDK\Exceptions\BusinessException
121+
* @throws \KuCoin\Futures\SDK\Exceptions\HttpException
122+
* @throws \KuCoin\Futures\SDK\Exceptions\InvalidApiUriException
123+
*/
124+
public function withdrawMargin($symbol, $withdrawAmount)
125+
{
126+
$response = $this->call(Request::METHOD_POST, '/api/v1/margin/withdrawMargin', compact('symbol', 'withdrawAmount'));
127+
return $response->getApiData();
128+
}
129+
130+
/**
131+
* Get Positions History.
132+
*
133+
* @param array $params
134+
* @return \KuCoin\Futures\SDK\Http\Response
135+
* @throws \KuCoin\Futures\SDK\Exceptions\HttpException
136+
* @throws \KuCoin\Futures\SDK\Exceptions\InvalidApiUriException
137+
*/
138+
public function getHistoryPositions(array $params)
139+
{
140+
$response = $this->call(Request::METHOD_GET, '/api/v1/history-positions', $params);
141+
return $response->getApiData();
142+
}
143+
144+
/**
145+
* Get Maximum Open Position Size.
146+
*
147+
* @param $symbol
148+
* @param $price
149+
* @param $leverage
150+
* @return mixed|null
151+
* @throws \KuCoin\Futures\SDK\Exceptions\BusinessException
152+
* @throws \KuCoin\Futures\SDK\Exceptions\HttpException
153+
* @throws \KuCoin\Futures\SDK\Exceptions\InvalidApiUriException
154+
*/
155+
public function getMaxOpenSize($symbol, $price, $leverage)
156+
{
157+
$response = $this->call(Request::METHOD_GET, '/api/v2/getMaxOpenSize', compact('symbol', 'price', 'leverage'));
158+
return $response->getApiData();
159+
}
98160
}

src/PublicApi/Contract.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,18 @@ public function getDetail($symbol)
4040
$response = $this->call(Request::METHOD_GET, '/api/v1/contracts/' . $symbol);
4141
return $response->getApiData();
4242
}
43+
44+
/**
45+
* Get Latest Ticker for All Contracts.
46+
*
47+
* @return mixed|null
48+
* @throws \KuCoin\Futures\SDK\Exceptions\BusinessException
49+
* @throws \KuCoin\Futures\SDK\Exceptions\HttpException
50+
* @throws \KuCoin\Futures\SDK\Exceptions\InvalidApiUriException
51+
*/
52+
public function getAllTickers()
53+
{
54+
$response = $this->call(Request::METHOD_GET, '/api/v1/allTickers');
55+
return $response->getApiData();
56+
}
4357
}

tests/ContractTest.php

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
namespace KuCoin\Futures\SDK\Tests;
88

9-
use \KuCoin\Futures\SDK\PublicApi\Contract;
9+
use KuCoin\Futures\SDK\PublicApi\Contract;
1010

1111

1212
class ContractTest extends TestCase
@@ -146,4 +146,32 @@ public function testGetDetail(Contract $api)
146146
$this->assertArrayHasKey('priceChgPct', $data);
147147
$this->assertArrayHasKey('priceChg', $data);
148148
}
149+
150+
/**
151+
* @dataProvider apiProvider
152+
*
153+
* @param Contract $api
154+
* @return void
155+
* @throws \KuCoin\Futures\SDK\Exceptions\BusinessException
156+
* @throws \KuCoin\Futures\SDK\Exceptions\HttpException
157+
* @throws \KuCoin\Futures\SDK\Exceptions\InvalidApiUriException
158+
*/
159+
public function testGetAllTickers(Contract $api)
160+
{
161+
$data = $api->getAllTickers();
162+
$this->assertInternalType('array', $data);
163+
foreach ($data as $item) {
164+
$this->assertArrayHasKey('symbol', $item);
165+
$this->assertArrayHasKey('sequence', $item);
166+
$this->assertArrayHasKey('side', $item);
167+
$this->assertArrayHasKey('size', $item);
168+
$this->assertArrayHasKey('tradeId', $item);
169+
$this->assertArrayHasKey('price', $item);
170+
$this->assertArrayHasKey('bestBidPrice', $item);
171+
$this->assertArrayHasKey('bestBidSize', $item);
172+
$this->assertArrayHasKey('bestAskPrice', $item);
173+
$this->assertArrayHasKey('bestAskSize', $item);
174+
$this->assertArrayHasKey('ts', $item);
175+
}
176+
}
149177
}

tests/FeeTest.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
3+
namespace KuCoin\Futures\SDK\Tests;
4+
5+
use KuCoin\Futures\SDK\PrivateApi\Fee;
6+
7+
class FeeTest extends TestCase
8+
{
9+
protected $apiClass = Fee::class;
10+
11+
protected $apiWithAuth = true;
12+
13+
/**
14+
* @dataProvider apiProvider
15+
* @param Fee $api
16+
* @throws \KuCoin\Futures\SDK\Exceptions\BusinessException
17+
* @throws \KuCoin\Futures\SDK\Exceptions\HttpException
18+
* @throws \KuCoin\Futures\SDK\Exceptions\InvalidApiUriException
19+
*/
20+
public function testGetTradeFees(Fee $api)
21+
{
22+
$symbol = 'ETHUSDTM';
23+
$data = $api->getTradeFees($symbol);
24+
$this->assertInternalType('array', $data);
25+
$this->assertArrayHasKey('symbol', $data);
26+
$this->assertArrayHasKey('takerFeeRate', $data);
27+
$this->assertArrayHasKey('makerFeeRate', $data);
28+
}
29+
}

0 commit comments

Comments
 (0)