Skip to content

Commit 49f7fd6

Browse files
authored
Merge pull request #13 from Artisan-Liu/master
Update futures api
2 parents 5075cee + 1b28d91 commit 49f7fd6

File tree

7 files changed

+291
-57
lines changed

7 files changed

+291
-57
lines changed

README.md

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -204,8 +204,13 @@ go(function () {
204204
| KuCoin\Futures\SDK\PrivateApi\Account::transferIn() | YES |`deprecated`|
205205
| KuCoin\Futures\SDK\PrivateApi\Account::transferOut() | YES | `deprecated` https://docs.kucoin.com/futures/#transfer-funds-to-kucoin-main-account |
206206
| KuCoin\Futures\SDK\PrivateApi\Account::transferOutV2() | YES | https://docs.kucoin.com/futures/#transfer-funds-to-kucoin-main-account-2 |
207-
| KuCoin\Futures\SDK\PrivateApi\Account::cancelTransferOut() | YES | https://docs.kucoin.com/futures/#cancel-transfer-out-request |
207+
| KuCoin\Futures\SDK\PrivateApi\Account::cancelTransferOut() | YES | `deprecated` https://docs.kucoin.com/futures/#cancel-transfer-out-request |
208208
| KuCoin\Futures\SDK\PrivateApi\Account::getTransferList() | YES | https://docs.kucoin.com/futures/#get-transfer-out-request-records |
209+
| KuCoin\Futures\SDK\PrivateApi\Account::getSubApikey() | YES | https://docs.kucoin.com/futures/#get-sub-account-futures-api-list |
210+
| KuCoin\Futures\SDK\PrivateApi\Account::createSubApikey() | YES | https://docs.kucoin.com/futures/#create-futures-apis-for-sub-account |
211+
| KuCoin\Futures\SDK\PrivateApi\Account::modifySubApikey() | YES | https://docs.kucoin.com/futures/#modify-sub-account-futures-apis |
212+
| KuCoin\Futures\SDK\PrivateApi\Account::deleteSubApikey() | YES | https://docs.kucoin.com/futures/#delete-sub-account-futures-apis |
213+
| KuCoin\Futures\SDK\PrivateApi\Account::transferOutV3() | YES | https://docs.kucoin.com/futures/#transfer-to-main-or-trade-account |
209214
</details>
210215

211216
<details>
@@ -240,6 +245,7 @@ go(function () {
240245
| KuCoin\Futures\SDK\PrivateApi\Order::getStopOrders() | YES | https://docs.kucoin.com/futures/#get-untriggered-stop-order-list |
241246
| KuCoin\Futures\SDK\PrivateApi\Order::getRecentDoneOrders() | YES | https://docs.kucoin.com/futures/#get-list-of-orders-completed-in-24h |
242247
| KuCoin\Futures\SDK\PrivateApi\Order::getDetail() | YES | https://docs.kucoin.com/futures/#get-details-of-a-single-order |
248+
| KuCoin\Futures\SDK\PrivateApi\Order::getDetailByClientOid() | YES | https://docs.kucoin.com/futures/#get-details-of-a-single-order |
243249
| KuCoin\Futures\SDK\PrivateApi\Order::getOpenOrderStatistics() | YES | https://docs.kucoin.com/futures/#active-order-value-calculation |
244250

245251
</details>
@@ -293,18 +299,18 @@ go(function () {
293299
<details>
294300
<summary>KuCoin\Futures\SDK\PublicApi\Symbol</summary>
295301

296-
| API | Authentication | Description |
297-
| -------- | -------- | -------- |
298-
| KuCoin\Futures\SDK\PublicApi\Symbol::getTicker() | NO | https://docs.kucoin.com/futures/#get-ticker |
299-
| KuCoin\Futures\SDK\PublicApi\Symbol::getLevel2Snapshot() | NO | https://docs.kucoin.com/futures/#get-full-order-book-level-2 |
300-
| KuCoin\Futures\SDK\PublicApi\Symbol::getLevel3Snapshot() | NO | https://docs.kucoin.com/futures/#get-full-order-book-level-3 |
301-
| KuCoin\Futures\SDK\PublicApi\Symbol::getV2Level3Snapshot() | NO | https://docs.kucoin.com/futures/#get-full-order-book-level-3-v2 |
302-
| KuCoin\Futures\SDK\PublicApi\Symbol::getLevel2Message() | NO | https://docs.kucoin.com/futures/##level-2-pulling-messages |
303-
| KuCoin\Futures\SDK\PublicApi\Symbol::getLevel3Message() | NO | https://docs.kucoin.com/futures/##level-3-pulling-messages |
304-
| KuCoin\Futures\SDK\PublicApi\Symbol::getTradeHistory() | NO | https://docs.kucoin.com/futures/#get-trade-histories |
302+
| API | Authentication | Description |
303+
| -------- | -------- |-------------------------------------------------------------------------|
304+
| KuCoin\Futures\SDK\PublicApi\Symbol::getTicker() | NO | https://docs.kucoin.com/futures/#get-ticker |
305+
| KuCoin\Futures\SDK\PublicApi\Symbol::getLevel2Snapshot() | NO | https://docs.kucoin.com/futures/#get-full-order-book-level-2 |
306+
| KuCoin\Futures\SDK\PublicApi\Symbol::getLevel3Snapshot() | NO | https://docs.kucoin.com/futures/#get-full-order-book-level-3 |
307+
| KuCoin\Futures\SDK\PublicApi\Symbol::getV2Level3Snapshot() | NO | https://docs.kucoin.com/futures/#get-full-order-book-level-3-v2 |
308+
| KuCoin\Futures\SDK\PublicApi\Symbol::getLevel2Message() | NO | `deprecated` https://docs.kucoin.com/futures/##level-2-pulling-messages |
309+
| KuCoin\Futures\SDK\PublicApi\Symbol::getLevel3Message() | NO | `deprecated` https://docs.kucoin.com/futures/##level-3-pulling-messages |
310+
| KuCoin\Futures\SDK\PublicApi\Symbol::getTradeHistory() | NO | https://docs.kucoin.com/futures/#get-trade-histories |
305311
| KuCoin\Futures\SDK\PublicApi\Symbol::getKLines() | NO | https://docs.kucoin.com/futures/?lang=en_US#get-k-line-data-of-contract |
306-
| KuCoin\Futures\SDK\PublicApi\Symbol::getLevel2Depth20 | NO | https://docs.kucoin.com/futures/cn/#level-2-2 |
307-
| KuCoin\Futures\SDK\PublicApi\Symbol::getLevel2Depth100 | NO | https://docs.kucoin.com/futures/cn/#level-2-2 |
312+
| KuCoin\Futures\SDK\PublicApi\Symbol::getLevel2Depth20 | NO | https://docs.kucoin.com/futures/cn/#level-2-2 |
313+
| KuCoin\Futures\SDK\PublicApi\Symbol::getLevel2Depth100 | NO | https://docs.kucoin.com/futures/cn/#level-2-2 |
308314

309315
</details>
310316

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

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

2626
/**
2727
* @var string

src/PrivateApi/Account.php

Lines changed: 90 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ public function getOverview(array $params = [])
2929
/**
3030
* Get a transaction history of accounts.
3131
*
32-
* @param array $params
33-
* @param array $pagination
32+
* @param array $params
33+
* @param array $pagination
3434
* @return array
3535
* @throws \KuCoin\Futures\SDK\Exceptions\BusinessException
3636
* @throws \KuCoin\Futures\SDK\Exceptions\HttpException
@@ -43,11 +43,8 @@ public function getTransactionHistory(array $params = [], array $pagination = []
4343
}
4444

4545
/**
46-
* @deprecated
47-
*
4846
* KuCoin transfer to kuCoin futures account.
49-
*
50-
* @param number amount
47+
* @param string amount
5148
* @return array
5249
* @throws \KuCoin\Futures\SDK\Exceptions\BusinessException
5350
* @throws \KuCoin\Futures\SDK\Exceptions\HttpException
@@ -62,8 +59,8 @@ public function transferIn($amount)
6259
/**
6360
* kuCoin futures transfer to KuCoin account.
6461
*
65-
* @param string bizNo
66-
* @param number amount
62+
* @param string bizNo
63+
* @param string amount
6764
* @return array
6865
* @throws \KuCoin\Futures\SDK\Exceptions\BusinessException
6966
* @throws \KuCoin\Futures\SDK\Exceptions\HttpException
@@ -77,12 +74,12 @@ public function transferOut($bizNo, $amount)
7774

7875
/**
7976
* Cancel an transfer out.
80-
*
81-
* @param string $applyId
77+
* @param string $applyId
8278
* @return array
8379
* @throws \KuCoin\Futures\SDK\Exceptions\BusinessException
8480
* @throws \KuCoin\Futures\SDK\Exceptions\HttpException
8581
* @throws \KuCoin\Futures\SDK\Exceptions\InvalidApiUriException
82+
* @deprecated
8683
*/
8784
public function cancelTransferOut($applyId)
8885
{
@@ -93,8 +90,8 @@ public function cancelTransferOut($applyId)
9390
/**
9491
* Get a transfer list.
9592
*
96-
* @param array $params
97-
* @param array $pagination
93+
* @param array $params
94+
* @param array $pagination
9895
* @return array
9996
* @throws \KuCoin\Futures\SDK\Exceptions\BusinessException
10097
* @throws \KuCoin\Futures\SDK\Exceptions\HttpException
@@ -108,10 +105,10 @@ public function getTransferList(array $params = [], array $pagination = [])
108105

109106
/**
110107
* kuCoin futures transfer to KuCoin account.
111-
*
112-
* @param string bizNo
113-
* @param number amount
114-
* @param string currency
108+
* [It is recommended to call transferOutV3() instead]
109+
* @param string bizNo
110+
* @param string amount
111+
* @param string currency
115112
* @return array
116113
* @throws \KuCoin\Futures\SDK\Exceptions\BusinessException
117114
* @throws \KuCoin\Futures\SDK\Exceptions\HttpException
@@ -122,4 +119,81 @@ public function transferOutV2($bizNo, $amount, $currency)
122119
$response = $this->call(Request::METHOD_POST, '/api/v2/transfer-out', compact('bizNo', 'amount', 'currency'));
123120
return $response->getApiData();
124121
}
122+
123+
/**
124+
* Get list of Futures APIs pertaining to a sub-accounts.
125+
*
126+
* @param array $params
127+
* @return array
128+
* @throws \KuCoin\Futures\SDK\Exceptions\BusinessException
129+
* @throws \KuCoin\Futures\SDK\Exceptions\HttpException
130+
* @throws \KuCoin\Futures\SDK\Exceptions\InvalidApiUriException
131+
*/
132+
public function getSubApikey(array $params)
133+
{
134+
$response = $this->call(Request::METHOD_GET, '/api/v1/sub/api-key', $params);
135+
return $response->getApiData();
136+
}
137+
138+
/**
139+
* Create futures APIs for sub-accounts.
140+
*
141+
* @param array $params
142+
* @return array
143+
* @throws \KuCoin\Futures\SDK\Exceptions\BusinessException
144+
* @throws \KuCoin\Futures\SDK\Exceptions\HttpException
145+
* @throws \KuCoin\Futures\SDK\Exceptions\InvalidApiUriException
146+
*/
147+
public function createSubApikey(array $params)
148+
{
149+
$response = $this->call(Request::METHOD_POST, '/api/v1/sub/api-key', $params);
150+
return $response->getApiData();
151+
}
152+
153+
/**
154+
* Modify futures APIs for sub-accounts.
155+
*
156+
* @param array $params
157+
* @return array
158+
* @throws \KuCoin\Futures\SDK\Exceptions\BusinessException
159+
* @throws \KuCoin\Futures\SDK\Exceptions\HttpException
160+
* @throws \KuCoin\Futures\SDK\Exceptions\InvalidApiUriException
161+
*/
162+
public function modifySubApikey(array $params)
163+
{
164+
$response = $this->call(Request::METHOD_POST, '/api/v1/sub/api-key/update', $params);
165+
return $response->getApiData();
166+
}
167+
168+
/**
169+
* Delete futures APIs for sub-accounts.
170+
*
171+
* @param array $params
172+
* @return array
173+
* @throws \KuCoin\Futures\SDK\Exceptions\BusinessException
174+
* @throws \KuCoin\Futures\SDK\Exceptions\HttpException
175+
* @throws \KuCoin\Futures\SDK\Exceptions\InvalidApiUriException
176+
*/
177+
public function deleteSubApikey(array $params)
178+
{
179+
$response = $this->call(Request::METHOD_DELETE, '/api/v1/sub/api-key', $params);
180+
return $response->getApiData();
181+
}
182+
183+
/**
184+
* kuCoin futures transfer to KuCoin account.
185+
*
186+
* @param string recAccountType
187+
* @param string amount
188+
* @param string currency
189+
* @return array
190+
* @throws \KuCoin\Futures\SDK\Exceptions\BusinessException
191+
* @throws \KuCoin\Futures\SDK\Exceptions\HttpException
192+
* @throws \KuCoin\Futures\SDK\Exceptions\InvalidApiUriException
193+
*/
194+
public function transferOutV3($recAccountType, $amount, $currency)
195+
{
196+
$response = $this->call(Request::METHOD_POST, '/api/v3/transfer-out', compact('recAccountType', 'amount', 'currency'));
197+
return $response->getApiData();
198+
}
125199
}

src/PrivateApi/Order.php

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class Order extends KuCoinFuturesApi
1515
/**
1616
* Place a new order.
1717
*
18-
* @param array $order
18+
* @param array $order
1919
* @return array
2020
* @throws \KuCoin\Futures\SDK\Exceptions\BusinessException
2121
* @throws \KuCoin\Futures\SDK\Exceptions\HttpException
@@ -30,7 +30,7 @@ public function create(array $order)
3030
/**
3131
* Cancel an order.
3232
*
33-
* @param string $orderId
33+
* @param string $orderId
3434
* @return array
3535
* @throws \KuCoin\Futures\SDK\Exceptions\BusinessException
3636
* @throws \KuCoin\Futures\SDK\Exceptions\HttpException
@@ -45,7 +45,7 @@ public function cancel($orderId)
4545
/**
4646
* Batch cancel orders.
4747
*
48-
* @param string|null $symbol
48+
* @param string|null $symbol
4949
* @return array
5050
* @throws \KuCoin\Futures\SDK\Exceptions\BusinessException
5151
* @throws \KuCoin\Futures\SDK\Exceptions\HttpException
@@ -60,7 +60,7 @@ public function batchCancel($symbol = null)
6060
/**
6161
* Batch cancel stop orders.
6262
*
63-
* @param string|null $symbol
63+
* @param string|null $symbol
6464
* @return array
6565
* @throws \KuCoin\Futures\SDK\Exceptions\BusinessException
6666
* @throws \KuCoin\Futures\SDK\Exceptions\HttpException
@@ -123,7 +123,7 @@ public function getRecentDoneOrders(array $params = [], array $pagination = [])
123123
/**
124124
* Get an order.
125125
*
126-
* @param string $orderId
126+
* @param string $orderId
127127
* @return array
128128
* @throws \KuCoin\Futures\SDK\Exceptions\BusinessException
129129
* @throws \KuCoin\Futures\SDK\Exceptions\HttpException
@@ -138,7 +138,7 @@ public function getDetail($orderId)
138138
/**
139139
* Get open order statistics.
140140
*
141-
* @param string|null $symbol
141+
* @param string|null $symbol
142142
* @return array
143143
* @throws \KuCoin\Futures\SDK\Exceptions\BusinessException
144144
* @throws \KuCoin\Futures\SDK\Exceptions\HttpException
@@ -149,4 +149,19 @@ public function getOpenOrderStatistics($symbol = null)
149149
$response = $this->call(Request::METHOD_GET, '/api/v1/openOrderStatistics', compact('symbol'));
150150
return $response->getApiData();
151151
}
152+
153+
/**
154+
* Get an order By ClientOid.
155+
*
156+
* @param $clientOid
157+
* @return array
158+
* @throws \KuCoin\Futures\SDK\Exceptions\BusinessException
159+
* @throws \KuCoin\Futures\SDK\Exceptions\HttpException
160+
* @throws \KuCoin\Futures\SDK\Exceptions\InvalidApiUriException
161+
*/
162+
public function getDetailByClientOid($clientOid)
163+
{
164+
$response = $this->call(Request::METHOD_GET, '/api/v1/orders/' . $clientOid, ['clientOid' => $clientOid]);
165+
return $response->getApiData();
166+
}
152167
}

src/PublicApi/Symbol.php

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class Symbol extends KuCoinFuturesApi
1515
/**
1616
* Get the ticker details of a symbol.
1717
*
18-
* @param string $symbol
18+
* @param string $symbol
1919
* @return array
2020
* @throws \KuCoin\Futures\SDK\Exceptions\BusinessException
2121
* @throws \KuCoin\Futures\SDK\Exceptions\HttpException
@@ -30,7 +30,7 @@ public function getTicker($symbol)
3030
/**
3131
* Get the snapshot details of a symbol.
3232
*
33-
* @param string $symbol
33+
* @param string $symbol
3434
* @return array
3535
* @throws \KuCoin\Futures\SDK\Exceptions\BusinessException
3636
* @throws \KuCoin\Futures\SDK\Exceptions\HttpException
@@ -45,7 +45,7 @@ public function getLevel2Snapshot($symbol)
4545
/**
4646
* Get the snapshot details of a symbol.
4747
*
48-
* @param string $symbol
48+
* @param string $symbol
4949
* @return array
5050
* @throws \KuCoin\Futures\SDK\Exceptions\BusinessException
5151
* @throws \KuCoin\Futures\SDK\Exceptions\HttpException
@@ -60,7 +60,7 @@ public function getLevel3Snapshot($symbol)
6060
/**
6161
* Get the snapshot details of a symbol.
6262
*
63-
* @param string $symbol
63+
* @param string $symbol
6464
* @return array
6565
* @throws \KuCoin\Futures\SDK\Exceptions\BusinessException
6666
* @throws \KuCoin\Futures\SDK\Exceptions\HttpException
@@ -75,13 +75,14 @@ public function getV2Level3Snapshot($symbol)
7575
/**
7676
* Get the level2 message of a symbol.
7777
*
78-
* @param string $symbol
79-
* @param number $start
80-
* @param number $end
78+
* @param string $symbol
79+
* @param int $start
80+
* @param int $end
8181
* @return array
8282
* @throws \KuCoin\Futures\SDK\Exceptions\BusinessException
8383
* @throws \KuCoin\Futures\SDK\Exceptions\HttpException
8484
* @throws \KuCoin\Futures\SDK\Exceptions\InvalidApiUriException
85+
* @deprecated
8586
*/
8687
public function getLevel2Message($symbol, $start, $end)
8788
{
@@ -92,17 +93,15 @@ public function getLevel2Message($symbol, $start, $end)
9293
}
9394

9495
/**
95-
* @deprecated
96-
*
9796
* Get the level3 message of a symbol.
98-
*
99-
* @param string $symbol
100-
* @param number $start
101-
* @param number $end
97+
* @param string $symbol
98+
* @param int $start
99+
* @param int $end
102100
* @return array
103101
* @throws \KuCoin\Futures\SDK\Exceptions\BusinessException
104102
* @throws \KuCoin\Futures\SDK\Exceptions\HttpException
105103
* @throws \KuCoin\Futures\SDK\Exceptions\InvalidApiUriException
104+
* @deprecated
106105
*/
107106
public function getLevel3Message($symbol, $start, $end)
108107
{
@@ -115,7 +114,7 @@ public function getLevel3Message($symbol, $start, $end)
115114
/**
116115
* Get the trade history details of a symbol.
117116
*
118-
* @param string $symbol
117+
* @param string $symbol
119118
* @return array
120119
* @throws \KuCoin\Futures\SDK\Exceptions\BusinessException
121120
* @throws \KuCoin\Futures\SDK\Exceptions\HttpException

0 commit comments

Comments
 (0)