Skip to content
This repository was archived by the owner on Mar 4, 2025. It is now read-only.

Commit 653f8b0

Browse files
committed
feat: add reset interface
* add Cancel Order by clientOid * add Get 24hour futures transaction volume * add Get Public Funding History
1 parent 8b60942 commit 653f8b0

File tree

10 files changed

+203
-46
lines changed

10 files changed

+203
-46
lines changed

README.md

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# KuCoin Futures Node SDK
22

3-
[![KuCoin Futures Node SDK](https://docs.kucoin.com/futures/images/logo_en.svg)](https://docs.kucoin.com/futures/#introduction)
3+
[KuCoin Futures Node SDK](https://docs.kucoin.com/futures/#introduction)
44
[![Latest Version](https://img.shields.io/github/release/Kucoin/kucoin-futures-node-sdk.svg?style=flat-square)](https://github.com/Kucoin/kucoin-futures-node-sdk/releases)
55

66
- [KuCoin Futures Node SDK](#kucoin-futures-node-sdk)
@@ -35,6 +35,7 @@
3535
- [Server Time](#server-time)
3636
- [Server Status](#server-status)
3737
- [Get K Line Data of Contract](#get-k-line-data-of-contract)
38+
- [Get 24hour futures transaction volume](#get-24hour-futures-transaction-volume)
3839
- [WebSocket](#websocket)
3940
- [Public Channels](#public-channels)
4041
- [Private Channels](#private-channels)
@@ -256,6 +257,12 @@ futuresSDK.futuresCancelAllStopOrders('ETHUSDTM', console.log);
256257
// or cancelAll limit/stop order for symbol
257258
futuresSDK.futuresCancelAll('ETHUSDTM', console.log);
258259

260+
// Cancel Order by clientOid
261+
futuresSDK.futuresCancelOrderByClientOid({
262+
symbol: '[symbol]',
263+
clientOid: '[clientOid]',
264+
}, console.log);
265+
259266
// Get Order List
260267
futuresSDK.futuresOpenOrders({ status: 'active' }, console.log);
261268

@@ -338,6 +345,17 @@ futuresSDK.futuresChangeRiskLimit(
338345
#### Funding Fees
339346

340347
```js
348+
// Get Current Funding Rate
349+
futuresSDK.futuresFundingRate('XBTUSDM', console.log);
350+
351+
// Get Public Funding History
352+
futuresSDK.futuresFundingRates({
353+
symbol: 'XBTUSDTM',
354+
from: '1700310700000',
355+
to: '1702310700000',
356+
}, console.log);
357+
358+
// Get Private Funding History
341359
futuresSDK.futuresFundingHistory({ symbol: 'ETHUSDTM' }, console.log);
342360
```
343361

@@ -399,9 +417,6 @@ futuresSDK.futuresMarkPrice('XBTUSDM', console.log);
399417

400418
// Get Premium Index
401419
futuresSDK.futuresPremiums({ symbol: '.XBTUSDMPI' }, console.log);
402-
403-
// Get Current Funding Rate
404-
futuresSDK.futuresFundingRate('XBTUSDM', console.log);
405420
```
406421

407422
#### Server Time
@@ -430,6 +445,13 @@ futuresSDK.futuresKline(
430445
);
431446
```
432447

448+
#### Get 24hour futures transaction volume
449+
450+
```js
451+
// need auth
452+
futuresSDK.futuresTradeStatistics(console.log);
453+
```
454+
433455
---
434456

435457
## WebSocket

example/index.js

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ futuresSDK.futuresStatus(console.log);
1212

1313
// futuresSDK.futuresAccount('USDT', console.log);
1414

15-
futuresSDK.futuresAccountOverview('USDT', console.log);
15+
// futuresSDK.futuresAccountOverview('USDT', console.log);
1616

1717
// futuresSDK.futuresBuy(
1818
// {
@@ -32,17 +32,17 @@ futuresSDK.futuresAccountOverview('USDT', console.log);
3232
// futuresSDK.futuresSell(
3333
// {
3434
// symbol: 'ETHUSDTM',
35-
// price: 20000,
36-
// leverage: 5,
35+
// price: 3000,
36+
// leverage: 15,
3737
// size: 1,
3838
// // clientOid: uuidV4(),
39-
// optional: {
40-
// remark: 'test',
41-
// stop: 'up',
42-
// stopPriceType: 'TP',
43-
// stopPrice: '20000',
44-
// // ...
45-
// }
39+
// // optional: {
40+
// // remark: 'test',
41+
// // stop: 'up',
42+
// // stopPriceType: 'TP',
43+
// // stopPrice: '20000',
44+
// // // ...
45+
// // }
4646
// },
4747
// console.log
4848
// );
@@ -55,7 +55,15 @@ futuresSDK.futuresAccountOverview('USDT', console.log);
5555

5656
// futuresSDK.futuresCancelAll('ETHUSDTM', console.log);
5757

58-
// futuresSDK.futuresOpenOrders({ status: 'done' }, console.log);
58+
// futuresSDK.futuresCancelOrderByClientOid(
59+
// 'ETHUSDTM',
60+
// 'clientId',
61+
// console.log
62+
// );
63+
64+
// futuresSDK.futuresOpenOrders({ status: 'active' }, (data) =>
65+
// console.log(JSON.stringify(data))
66+
// );
5967

6068
// futuresSDK.futuresStopOrders({ type: 'market' }, console.log);
6169

@@ -179,6 +187,14 @@ futuresSDK.futuresAccountOverview('USDT', console.log);
179187
// console.log
180188
// );
181189

190+
// futuresSDK.futuresFundingRates({
191+
// symbol: 'XBTUSDTM',
192+
// from: '1700310700000',
193+
// to: '1702310700000',
194+
// }, console.log);
195+
196+
// futuresSDK.futuresTradeStatistics(console.log);
197+
182198
// === websocket === //
183199

184200
// futuresSDK.websocket.ticker(['ETHUSDTM', 'XBTUSDTM']);

lib/dataType/other.d.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,8 @@ export interface FundingHistoryParams extends PageOffsetParams {
33
symbol: string;
44
reverse?: boolean | true;
55
}
6+
export interface FundingRatesParams {
7+
symbol: string;
8+
startAt: string;
9+
endAt: string;
10+
}

lib/index.d.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { CreateSubApiParams, FillsParams, FundingHistoryParams, OpenOrderListParams, StopOrderListParams, TransactionHistoryParams, TransferListParams, UpdateSubApiParams, IndexListParams, klineParams, Callback } from './dataType';
1+
import { CreateSubApiParams, FillsParams, FundingHistoryParams, OpenOrderListParams, StopOrderListParams, TransactionHistoryParams, TransferListParams, UpdateSubApiParams, IndexListParams, klineParams, Callback, FundingRatesParams } from './dataType';
22
import { WebSocketClient } from './websocket';
33
export default class KuCoinFutures {
44
private request;
@@ -79,6 +79,7 @@ export default class KuCoinFutures {
7979
futuresCancelAllOpenOrders: (symbol?: string, callback?: Function) => Promise<any>;
8080
futuresCancelAllStopOrders: (symbol?: string, callback?: Function) => Promise<any>;
8181
futuresCancelAll: (symbol?: string, callback?: Function) => Promise<[any, any]>;
82+
futuresCancelOrderByClientOid: (symbol: string, clientOid: string, callback?: Function) => Promise<any>;
8283
/**
8384
* search to open orders list
8485
* @param params.status --'active'|'done' default 'active'
@@ -154,6 +155,15 @@ export default class KuCoinFutures {
154155
* @param callback -- callback function
155156
*/
156157
futuresFundingHistory: (params?: FundingHistoryParams, callback?: Function) => Promise<any>;
158+
/**
159+
* search to stop orders list
160+
* @param params.symbol -- string symbol
161+
* @param params.startAt -- timestamp
162+
* @param params.endAt -- timestamp
163+
* @param callback -- callback function
164+
*/
165+
futuresFundingRates: (params?: FundingRatesParams, callback?: Function) => Promise<any>;
166+
futuresFundingRate: (symbol: string, callback?: Function) => Promise<any>;
157167
futuresContractsActive: (callback?: Function) => Promise<any>;
158168
futuresContractDetail: (symbol: string, callback?: Function) => Promise<any>;
159169
futuresTicker: (symbol: string, callback?: Function) => Promise<any>;
@@ -171,6 +181,7 @@ export default class KuCoinFutures {
171181
* @param params.to -- boolean
172182
*/
173183
futuresKline: (params: klineParams, callback?: Function) => Promise<any>;
184+
futuresTradeStatistics: (callback?: Function) => Promise<any>;
174185
/**
175186
* search to interest list
176187
* @param params.symbol -- string symbol
@@ -208,7 +219,6 @@ export default class KuCoinFutures {
208219
* @param callback -- callback function
209220
*/
210221
futuresPremiums: (params?: IndexListParams, callback?: Function) => Promise<any>;
211-
futuresFundingRate: (symbol: string, callback?: Function) => Promise<any>;
212222
futuresGetSocketInstance: (isPrivate: boolean) => Promise<WebSocketClient>;
213223
futuresGetCacheSocketInstance: (isPrivate: boolean) => Promise<WebSocketClient>;
214224
futuresSocketSubscribe: (topic: string, callback?: Callback, isPrivate?: boolean, strict?: boolean) => Promise<false | undefined>;

lib/index.js

Lines changed: 47 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,16 @@ var KuCoinFutures = /** @class */ (function () {
294294
return [2 /*return*/, Promise.all([cancelAllOpenOrders, cancelAllStopOrders])];
295295
});
296296
}); };
297+
this.futuresCancelOrderByClientOid = function (symbol, clientOid, callback) { return __awaiter(_this_1, void 0, void 0, function () {
298+
return __generator(this, function (_a) {
299+
return [2 /*return*/, this.makeRequest({
300+
body: '',
301+
method: constants_1.DELETE,
302+
endpoint: "".concat(resetAPI_1.FUTURES_ORDER_CLIENT_ORDER_EP, "/").concat(clientOid, "?symbol=").concat(symbol),
303+
callback: callback
304+
})];
305+
});
306+
}); };
297307
/**
298308
* search to open orders list
299309
* @param params.status --'active'|'done' default 'active'
@@ -477,6 +487,34 @@ var KuCoinFutures = /** @class */ (function () {
477487
})];
478488
});
479489
}); };
490+
/**
491+
* search to stop orders list
492+
* @param params.symbol -- string symbol
493+
* @param params.startAt -- timestamp
494+
* @param params.endAt -- timestamp
495+
* @param callback -- callback function
496+
*/
497+
this.futuresFundingRates = function (params, callback) { return __awaiter(_this_1, void 0, void 0, function () {
498+
return __generator(this, function (_a) {
499+
return [2 /*return*/, this.makeRequest({
500+
body: params,
501+
method: constants_1.GET,
502+
endpoint: resetAPI_1.FUTURES_FUNDING_RATES_EP,
503+
callback: callback,
504+
isPrivate: false
505+
})];
506+
});
507+
}); };
508+
this.futuresFundingRate = function (symbol, callback) { return __awaiter(_this_1, void 0, void 0, function () {
509+
return __generator(this, function (_a) {
510+
return [2 /*return*/, this.makeRequest({
511+
method: constants_1.GET,
512+
endpoint: "".concat(resetAPI_1.FUTURES_FUNDING_RATE_EP, "/").concat(symbol, "/current"),
513+
callback: callback,
514+
isPrivate: false
515+
})];
516+
});
517+
}); };
480518
this.futuresContractsActive = function (callback) { return __awaiter(_this_1, void 0, void 0, function () {
481519
return __generator(this, function (_a) {
482520
return [2 /*return*/, this.makeRequest({
@@ -594,6 +632,15 @@ var KuCoinFutures = /** @class */ (function () {
594632
})];
595633
});
596634
}); };
635+
this.futuresTradeStatistics = function (callback) { return __awaiter(_this_1, void 0, void 0, function () {
636+
return __generator(this, function (_a) {
637+
return [2 /*return*/, this.makeRequest({
638+
method: constants_1.GET,
639+
endpoint: resetAPI_1.FUTURES_TRADE_STATISTICS_EP,
640+
callback: callback
641+
})];
642+
});
643+
}); };
597644
/**
598645
* search to interest list
599646
* @param params.symbol -- string symbol
@@ -670,16 +717,6 @@ var KuCoinFutures = /** @class */ (function () {
670717
})];
671718
});
672719
}); };
673-
this.futuresFundingRate = function (symbol, callback) { return __awaiter(_this_1, void 0, void 0, function () {
674-
return __generator(this, function (_a) {
675-
return [2 /*return*/, this.makeRequest({
676-
method: constants_1.GET,
677-
endpoint: "".concat(resetAPI_1.FUTURES_FUNDING_RATE_EP, "/").concat(symbol, "/current"),
678-
callback: callback,
679-
isPrivate: false
680-
})];
681-
});
682-
}); };
683720
this.futuresGetSocketInstance = function (isPrivate) { return __awaiter(_this_1, void 0, void 0, function () {
684721
var _a, instanceServers, token, wssUri, websocket, socketInstance;
685722
return __generator(this, function (_b) {

lib/resetAPI/constants.d.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ export declare const FUTURES_TRANSFER_LIST_EP = "/api/v1/transfer-list";
99
export declare const FUTURES_ORDER_EP = "/api/v1/orders";
1010
export declare const FUTURES_STOP_ORDER_EP = "/api/v1/stopOrders";
1111
export declare const FUTURES_RECENT_DONE_ORDERS_EP = "/api/v1/recentDoneOrders";
12+
export declare const FUTURES_ORDER_CLIENT_ORDER_EP = "/api/v1/orders/client-order";
1213
export declare const FUTURES_FILLS_EP = "/api/v1/fills";
1314
export declare const FUTURES_RECENT_FILLS_EP = "/api/v1/recentFills";
1415
export declare const FUTURES_TOTAL_OPEN_ORDERS_MARGIN_EP = "/api/v1/openOrderStatistics";
@@ -18,7 +19,9 @@ export declare const FUTURES_POSITION_AUTO_DEPOSIT_STATUS_EP = "/api/v1/position
1819
export declare const FUTURES_POSITION_MARGIN_EP = "/api/v1/position/margin/deposit-margin";
1920
export declare const FUTURES_RISK_LIMIT_EP = "/api/v1/contracts/risk-limit";
2021
export declare const FUTURES_CHANGE_RISK_LIMIT_EP = "/api/v1/position/risk-limit-level/change";
22+
export declare const FUTURES_FUNDING_RATE_EP = "/api/v1/funding-rate";
2123
export declare const FUTURES_FUNDING_HISTORY_EP = "/api/v1/funding-history";
24+
export declare const FUTURES_FUNDING_RATES_EP = "/api/v1/contract/funding-rates";
2225
export declare const FUTURES_CONTRACTS_ACTIVE_EP = "/api/v1/contracts/active";
2326
export declare const FUTURES_CONTRACTS_DETAIL_EP = "api/v1/contracts";
2427
export declare const FUTURES_TICKER_EP = "/api/v1/ticker";
@@ -30,7 +33,7 @@ export declare const FUTURES_INTEREST_EP = "/api/v1/interest/query";
3033
export declare const FUTURES_INDEX_EP = "/api/v1/index/query";
3134
export declare const FUTURES_MARK_PRICE_EP = "/api/v1/mark-price";
3235
export declare const FUTURES_PREMIUM_EP = "/api/v1/premium/query";
33-
export declare const FUTURES_FUNDING_RATE_EP = "/api/v1/funding-rate";
3436
export declare const FUTURES_TIMESTAMP_EP = "/api/v1/timestamp";
3537
export declare const FUTURES_SERVICE_STATUS_EP = "/api/v1/status";
3638
export declare const FUTURES_KLINE_EP = "/api/v1/kline/query";
39+
export declare const FUTURES_TRADE_STATISTICS_EP = "/api/v1/trade-statistics";

lib/resetAPI/constants.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"use strict";
22
Object.defineProperty(exports, "__esModule", { value: true });
3-
exports.FUTURES_KLINE_EP = exports.FUTURES_SERVICE_STATUS_EP = exports.FUTURES_TIMESTAMP_EP = exports.FUTURES_FUNDING_RATE_EP = exports.FUTURES_PREMIUM_EP = exports.FUTURES_MARK_PRICE_EP = exports.FUTURES_INDEX_EP = exports.FUTURES_INTEREST_EP = exports.FUTURES_TRADE_HISTORY_EP = exports.FUTURES_LEVEL2_100_EP = exports.FUTURES_LEVEL2_20_EP = exports.FUTURES_LEVEL2_EP = exports.FUTURES_TICKER_EP = exports.FUTURES_CONTRACTS_DETAIL_EP = exports.FUTURES_CONTRACTS_ACTIVE_EP = exports.FUTURES_FUNDING_HISTORY_EP = exports.FUTURES_CHANGE_RISK_LIMIT_EP = exports.FUTURES_RISK_LIMIT_EP = exports.FUTURES_POSITION_MARGIN_EP = exports.FUTURES_POSITION_AUTO_DEPOSIT_STATUS_EP = exports.FUTURES_POSITIONS_EP = exports.FUTURES_POSITION_EP = exports.FUTURES_TOTAL_OPEN_ORDERS_MARGIN_EP = exports.FUTURES_RECENT_FILLS_EP = exports.FUTURES_FILLS_EP = exports.FUTURES_RECENT_DONE_ORDERS_EP = exports.FUTURES_STOP_ORDER_EP = exports.FUTURES_ORDER_EP = exports.FUTURES_TRANSFER_LIST_EP = exports.FUTURES_TRANSFER_IN_EP = exports.FUTURES_TRANSFER_OUT_EP = exports.FUTURES_UPDATE_SUB_API_EP = exports.FUTURES_SUB_API_EP = exports.FUTURES_TRANSACTION_HISTORY_EP = exports.FUTURES_ACCOUNT_OVERVIEW_ALL_EP = exports.FUTURES_ACCOUNT_OVERVIEW_EP = void 0;
3+
exports.FUTURES_TRADE_STATISTICS_EP = exports.FUTURES_KLINE_EP = exports.FUTURES_SERVICE_STATUS_EP = exports.FUTURES_TIMESTAMP_EP = exports.FUTURES_PREMIUM_EP = exports.FUTURES_MARK_PRICE_EP = exports.FUTURES_INDEX_EP = exports.FUTURES_INTEREST_EP = exports.FUTURES_TRADE_HISTORY_EP = exports.FUTURES_LEVEL2_100_EP = exports.FUTURES_LEVEL2_20_EP = exports.FUTURES_LEVEL2_EP = exports.FUTURES_TICKER_EP = exports.FUTURES_CONTRACTS_DETAIL_EP = exports.FUTURES_CONTRACTS_ACTIVE_EP = exports.FUTURES_FUNDING_RATES_EP = exports.FUTURES_FUNDING_HISTORY_EP = exports.FUTURES_FUNDING_RATE_EP = exports.FUTURES_CHANGE_RISK_LIMIT_EP = exports.FUTURES_RISK_LIMIT_EP = exports.FUTURES_POSITION_MARGIN_EP = exports.FUTURES_POSITION_AUTO_DEPOSIT_STATUS_EP = exports.FUTURES_POSITIONS_EP = exports.FUTURES_POSITION_EP = exports.FUTURES_TOTAL_OPEN_ORDERS_MARGIN_EP = exports.FUTURES_RECENT_FILLS_EP = exports.FUTURES_FILLS_EP = exports.FUTURES_ORDER_CLIENT_ORDER_EP = exports.FUTURES_RECENT_DONE_ORDERS_EP = exports.FUTURES_STOP_ORDER_EP = exports.FUTURES_ORDER_EP = exports.FUTURES_TRANSFER_LIST_EP = exports.FUTURES_TRANSFER_IN_EP = exports.FUTURES_TRANSFER_OUT_EP = exports.FUTURES_UPDATE_SUB_API_EP = exports.FUTURES_SUB_API_EP = exports.FUTURES_TRANSACTION_HISTORY_EP = exports.FUTURES_ACCOUNT_OVERVIEW_ALL_EP = exports.FUTURES_ACCOUNT_OVERVIEW_EP = void 0;
44
// account endpoint
55
exports.FUTURES_ACCOUNT_OVERVIEW_EP = '/api/v1/account-overview';
66
exports.FUTURES_ACCOUNT_OVERVIEW_ALL_EP = '/api/v1/account-overview-all';
@@ -15,6 +15,7 @@ exports.FUTURES_TRANSFER_LIST_EP = '/api/v1/transfer-list';
1515
exports.FUTURES_ORDER_EP = '/api/v1/orders';
1616
exports.FUTURES_STOP_ORDER_EP = '/api/v1/stopOrders';
1717
exports.FUTURES_RECENT_DONE_ORDERS_EP = '/api/v1/recentDoneOrders';
18+
exports.FUTURES_ORDER_CLIENT_ORDER_EP = '/api/v1/orders/client-order';
1819
// fills endpoint
1920
exports.FUTURES_FILLS_EP = '/api/v1/fills';
2021
exports.FUTURES_RECENT_FILLS_EP = '/api/v1/recentFills';
@@ -24,10 +25,13 @@ exports.FUTURES_POSITION_EP = '/api/v1/position';
2425
exports.FUTURES_POSITIONS_EP = '/api/v1/positions';
2526
exports.FUTURES_POSITION_AUTO_DEPOSIT_STATUS_EP = '/api/v1/position/margin/auto-deposit-status';
2627
exports.FUTURES_POSITION_MARGIN_EP = '/api/v1/position/margin/deposit-margin';
27-
// other endpoint
28+
// risk limit endpoint
2829
exports.FUTURES_RISK_LIMIT_EP = '/api/v1/contracts/risk-limit';
2930
exports.FUTURES_CHANGE_RISK_LIMIT_EP = '/api/v1/position/risk-limit-level/change';
31+
// funding fees endpoint
32+
exports.FUTURES_FUNDING_RATE_EP = '/api/v1/funding-rate';
3033
exports.FUTURES_FUNDING_HISTORY_EP = '/api/v1/funding-history';
34+
exports.FUTURES_FUNDING_RATES_EP = '/api/v1/contract/funding-rates';
3135
// market endpoint
3236
exports.FUTURES_CONTRACTS_ACTIVE_EP = '/api/v1/contracts/active';
3337
exports.FUTURES_CONTRACTS_DETAIL_EP = 'api/v1/contracts';
@@ -40,7 +44,7 @@ exports.FUTURES_INTEREST_EP = '/api/v1/interest/query';
4044
exports.FUTURES_INDEX_EP = '/api/v1/index/query';
4145
exports.FUTURES_MARK_PRICE_EP = '/api/v1/mark-price';
4246
exports.FUTURES_PREMIUM_EP = '/api/v1/premium/query';
43-
exports.FUTURES_FUNDING_RATE_EP = '/api/v1/funding-rate';
4447
exports.FUTURES_TIMESTAMP_EP = '/api/v1/timestamp';
4548
exports.FUTURES_SERVICE_STATUS_EP = '/api/v1/status';
4649
exports.FUTURES_KLINE_EP = '/api/v1/kline/query';
50+
exports.FUTURES_TRADE_STATISTICS_EP = '/api/v1/trade-statistics';

src/dataType/other.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,9 @@ export interface FundingHistoryParams extends PageOffsetParams {
44
symbol: string;
55
reverse?: boolean | true; // This parameter functions to judge whether the lookup is forward or not. True means “yes” and False means “no”. This parameter is set as true by default
66
}
7+
8+
export interface FundingRatesParams {
9+
symbol: string;
10+
startAt: string;
11+
endAt: string;
12+
}

0 commit comments

Comments
 (0)