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

Commit 47e4efc

Browse files
authored
Merge pull request #39 from Apexrsq/feature/supply-interface
feat: add reset interface and socket topic
2 parents e68a08f + fbe67f1 commit 47e4efc

File tree

13 files changed

+428
-13
lines changed

13 files changed

+428
-13
lines changed

README.md

Lines changed: 178 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,13 @@
2323
- [Place Order Test](#place-order-test)
2424
- [Place Multiple Orders](#place-multiple-orders)
2525
- [Place take profit and stop loss order](#place-take-profit-and-stop-loss-order)
26+
- [Batch cancel Orders](#batch-cancel-orders)
2627
- [Fills](#fills)
2728
- [Positions](#positions)
29+
- [Get Margin Mode](#get-margin-mode)
30+
- [Modify Margin Mode](#modify-margin-mode)
31+
- [Get Cross Margin Leverage](#get-cross-margin-leverage)
32+
- [Modify Cross Margin Leverage](#modify-cross-margin-leverage)
2833
- [Risk Limit Level](#risk-limit-level)
2934
- [Funding Fees](#funding-fees)
3035
- [Trade Fees](#trade-fees)
@@ -428,6 +433,58 @@ futuresSDK.futuresOrderMulti([...], console.log);
428433
futuresSDK.futuresOrderStp(params, console.log);
429434
```
430435

436+
##### Batch cancel Orders
437+
438+
| Param | Type | Mandatory | Description |
439+
|----------------|--------|-----------|--------------------------------------------------------------------------------|
440+
| symbol | String | No | symbol, this parameter is required when using clientOidsList to cancel orders. |
441+
| orderIdsList | String | No | Choose one of orderIdsList and clientOidsList |
442+
| clientOidsList | String | No | Choose one of orderIdsList and clientOidsList |
443+
```js
444+
//Request
445+
{
446+
"orderIdsList":
447+
[
448+
"80465574458560512",
449+
"80465575289094144"
450+
],
451+
"clientOidsList":
452+
[
453+
{
454+
"symbol": "XBTUSDTM",
455+
"clientOid": "clientOid123"
456+
},
457+
{
458+
"symbol": "ETHUSDTM",
459+
"clientOid": "clientOid321"
460+
}
461+
]
462+
}
463+
464+
//Response
465+
{
466+
"code": "200000",
467+
"data":
468+
[
469+
{
470+
"orderId": "80465574458560512",
471+
"clientOid": null,
472+
"code": "200",
473+
"msg": "success"
474+
},
475+
{
476+
"orderId": "80465575289094144",
477+
"clientOid": null,
478+
"code": "200",
479+
"msg": "success"
480+
}
481+
]
482+
}
483+
484+
futuresSDK.futuresMultiCancelOrder(params, console.log);
485+
```
486+
487+
431488

432489
#### Fills
433490

@@ -499,6 +556,100 @@ futuresSDK.futuresWithdrawMargin(
499556
);
500557
```
501558

559+
##### Get Margin Mode
560+
PARAMETERS
561+
| Param | Type | Mandatory | Description |
562+
|--------|--------|-----------|------------------------|
563+
| symbol | String | Yes | Symbol of the contract |
564+
565+
RESPONSES
566+
| Param | Description |
567+
|------------|---------------------------------------------------------|
568+
| symbol | Symbol of the contract |
569+
| marginMode | Margin mode: ISOLATED (isolated), CROSS (cross margin). |
570+
571+
572+
```js
573+
{
574+
"symbol":"XBTUSDTM", // symbol
575+
"marginMode":"CROSS" // Margin mode: ISOLATED (isolated), CROSS (cross margin).
576+
}
577+
578+
futuresSDK.futuresGetMarginMode({ symbol: 'ETHUSDTM' }, console.log);
579+
```
580+
581+
##### Modify Margin Mode
582+
PARAMETERS
583+
| Param | Type | Mandatory | Description |
584+
|------------|--------|-----------|-------------------------------------------------------------------|
585+
| symbol | String | Yes | Symbol of the contract |
586+
| marginMode | String | Yes | Modified margin model: ISOLATED (isolated), CROSS (cross margin). |
587+
588+
RESPONSES
589+
| Param | Description |
590+
|------------|---------------------------------------------------------|
591+
| symbol | Symbol of the contract |
592+
| marginMode | Margin mode: ISOLATED (isolated), CROSS (cross margin). |
593+
594+
595+
```js
596+
// request body
597+
{
598+
"symbol":"XBTUSDTM", // symbol
599+
"marginMode":"CROSS" // Margin mode: ISOLATED (isolated), CROSS (cross margin).
600+
}
601+
602+
// response body
603+
{
604+
"symbol":"XBTUSDTM", // symbol
605+
"marginMode":"CROSS" // Modified margin model:ISOLATED (isolated), CROSS (cross margin).
606+
}
607+
608+
futuresSDK.futuresChangeMarginMode({ symbol: 'ETHUSDTM', marginMode: 'CROSS' }, console.log);
609+
```
610+
611+
##### Get Cross Margin Leverage
612+
PARAMETERS
613+
| Param | Type | Mandatory | Description |
614+
|--------|--------|-----------|------------------------|
615+
| symbol | String | Yes | Symbol of the contract |
616+
617+
RESPONSES
618+
| Param | Description |
619+
|-----------------------------|--------------------------|
620+
| symbol | Symbol of the contract |
621+
| leverage | Leverage multiple |
622+
623+
```js
624+
{
625+
"symbol":"XBTUSDTM", // symbol
626+
"leverage":"3.00" // Leverage multiple
627+
}
628+
629+
futuresSDK.futuresGetCrossUserLeverage({ symbol: 'XBTUSDTM' }, console.log)
630+
```
631+
632+
##### Modify Cross Margin Leverage
633+
PARAMETERS
634+
| Param | Type | Mandatory | Description |
635+
|----------|--------|-----------|------------------------|
636+
| symbol | String | Yes | Symbol of the contract |
637+
| leverage | String | Yes | Leverage multiple |
638+
639+
RESPONSES
640+
| Param | Description |
641+
|-----------------------------|--------------------------|
642+
| data | Whether successful |
643+
644+
```js
645+
{
646+
"symbol":"XBTUSDTM", // symbol
647+
"leverage":"3.00" // Leverage multiple
648+
}
649+
650+
futuresSDK.futuresChangeCrossUserLeverage({ symbol: 'XBTUSDTM', leverage: 3 }, console.log)
651+
```
652+
502653
#### Risk Limit Level
503654

504655
```js
@@ -719,6 +870,33 @@ futuresSDK.websocket.position(['ETHUSDTM', 'XBTUSDTM']);
719870
// All Position Change Events
720871
// The subject is the same as the position change events above.
721872
futuresSDK.websocket.positionAll(console.log);
873+
874+
// {
875+
// "topic": "/contract/marginMode",
876+
// "type": "message",
877+
// "subject": "user.config",
878+
// "userId": "6687a53f5bda600012b84bf",
879+
// "channelType": "private",
880+
// "data": {
881+
// "ANTUSDTM": "CROSS"
882+
// }
883+
// }
884+
futuresSDK.websocket.marginMode(console.log);
885+
886+
// {
887+
// "topic": "/contract/crossLeverage",
888+
// "type": "message",
889+
// "subject": "user.config",
890+
// "userId": "6687a53f5bda600001284bf",
891+
// "channelType": "private",
892+
// "data": {
893+
// "ANTUSDTM": {
894+
// "leverage": 5
895+
// }
896+
// }
897+
// }
898+
futuresSDK.websocket.crossLeverage(console.log);
899+
722900
```
723901

724902
## License

example/index.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,8 @@ futuresSDK.futuresStatus(console.log);
131131
// console.log
132132
// );
133133

134+
// futuresSDK.futuresMultiCancelOrder({ orderIdsList: ['orderid'] });
135+
134136
// futuresSDK.futuresTransactionHistory(
135137
// {
136138
// startTime: new Date().getTime() - 7 * 24 * 60 * 60 * 1000,
@@ -208,6 +210,14 @@ futuresSDK.futuresStatus(console.log);
208210

209211
// futuresSDK.futuresMaxOpenPositionSize({ symbol: 'ETHUSDTM', price: '2200', leverage: 5 }, console.log);
210212

213+
// futuresSDK.futuresGetMarginMode({ symbol: 'XBTUSDTM' }, console.log);
214+
215+
// futuresSDK.futuresChangeMarginMode({ symbol: 'XBTUSDTM', marginMode: 'CROSS' }, console.log);
216+
217+
// futuresSDK.futuresGetCrossUserLeverage({ symbol: 'XBTUSDTM' }, console.log);
218+
219+
// futuresSDK.futuresChangeCrossUserLeverage({ symbol: 'XBTUSDTM', leverage: '5' }, console.log);
220+
211221
// futuresSDK.futuresRiskLimit('ETHUSDTM', console.log);
212222

213223
// futuresSDK.futuresChangeRiskLimit(
@@ -288,3 +298,7 @@ futuresSDK.futuresStatus(console.log);
288298
// futuresSDK.websocket.position(['ETHUSDTM', 'LINAUSDTM']);
289299

290300
// futuresSDK.websocket.positionAll();
301+
302+
// futuresSDK.websocket.marginMode();
303+
304+
// futuresSDK.websocket.crossLeverage();

lib/dataType/order.d.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,3 +80,8 @@ export interface StpOrderParams {
8080
iceberg?: boolean;
8181
visibleSize?: number | string;
8282
}
83+
export interface OrderMultiCancel {
84+
symbol?: string;
85+
orderIdsList?: Array<string>;
86+
clientOidsList?: Array<string>;
87+
}

lib/index.d.ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { WebSocketClient } from './websocket';
2-
import { CreateSubApiParams, FillsParams, FundingHistoryParams, OpenOrderListParams, StopOrderListParams, TransactionHistoryParams, TransferListParams, UpdateSubApiParams, IndexListParams, klineParams, Callback, FundingRatesParams, MultiOrderBody, HistoryPositionsParams, StpOrderParams } from './dataType';
2+
import { CreateSubApiParams, FillsParams, FundingHistoryParams, OpenOrderListParams, StopOrderListParams, TransactionHistoryParams, TransferListParams, UpdateSubApiParams, IndexListParams, klineParams, Callback, FundingRatesParams, MultiOrderBody, HistoryPositionsParams, StpOrderParams, OrderMultiCancel } from './dataType';
33
export default class KuCoinFutures {
44
private request;
55
private socketInstanceCache;
@@ -99,6 +99,7 @@ export default class KuCoinFutures {
9999
futuresCancelAllStopOrders: (symbol?: string, callback?: Function) => Promise<any>;
100100
futuresCancelAll: (symbol?: string, callback?: Function) => Promise<[any, any]>;
101101
futuresCancelOrderByClientOid: (symbol: string, clientOid: string, callback?: Function) => Promise<any>;
102+
futuresMultiCancelOrder: (params: OrderMultiCancel, callback?: Function) => Promise<any>;
102103
/**
103104
* search to open orders list
104105
* @param params.status --'active'|'done' default 'active'
@@ -168,6 +169,20 @@ export default class KuCoinFutures {
168169
price: string | number;
169170
leverage: string | number;
170171
}, callback?: Function) => Promise<any>;
172+
futuresGetMarginMode: (params: {
173+
symbol: string;
174+
}, callback?: Function) => Promise<any>;
175+
futuresChangeMarginMode: (params: {
176+
symbol: string;
177+
marginMode: string;
178+
}, callback?: Function) => Promise<any>;
179+
futuresGetCrossUserLeverage: (params: {
180+
symbol: string;
181+
}, callback?: Function) => Promise<any>;
182+
futuresChangeCrossUserLeverage: (params: {
183+
symbol: string;
184+
leverage: string;
185+
}, callback?: Function) => Promise<any>;
171186
futuresRiskLimit: (symbol?: string, callback?: Function) => Promise<any>;
172187
futuresChangeRiskLimit: (params: {
173188
symbol: string;
@@ -280,5 +295,7 @@ export default class KuCoinFutures {
280295
position: (symbols: string | [
281296
], callback?: (d: any) => void) => Promise<false | (false | undefined)[] | undefined>;
282297
positionAll: (callback?: (d: any) => void) => Promise<false | undefined>;
298+
marginMode: (callback?: (d: any) => void) => Promise<false | undefined>;
299+
crossLeverage: (callback?: (d: any) => void) => Promise<false | undefined>;
283300
};
284301
}

0 commit comments

Comments
 (0)