ccxt 4.4.8 → 4.4.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/dist/ccxt.browser.min.js +2 -2
- package/dist/cjs/ccxt.js +1 -1
- package/dist/cjs/src/bigone.js +35 -86
- package/dist/cjs/src/bingx.js +7 -2
- package/dist/cjs/src/bitget.js +3 -0
- package/dist/cjs/src/bybit.js +5 -1
- package/dist/cjs/src/gate.js +35 -1
- package/dist/cjs/src/htx.js +2 -0
- package/dist/cjs/src/kucoin.js +2 -1
- package/dist/cjs/src/kucoinfutures.js +162 -2
- package/dist/cjs/src/pro/binance.js +4 -4
- package/dist/cjs/src/pro/hitbtc.js +122 -48
- package/dist/cjs/src/pro/hollaex.js +5 -0
- package/dist/cjs/src/pro/okx.js +19 -3
- package/dist/cjs/src/pro/p2b.js +35 -1
- package/dist/cjs/src/pro/whitebit.js +31 -0
- package/js/ccxt.d.ts +1 -1
- package/js/ccxt.js +1 -1
- package/js/src/abstract/bigone.d.ts +1 -1
- package/js/src/abstract/kucoinfutures.d.ts +5 -0
- package/js/src/bigone.js +35 -86
- package/js/src/bingx.js +7 -2
- package/js/src/bitget.js +3 -0
- package/js/src/bybit.js +5 -1
- package/js/src/gate.js +35 -1
- package/js/src/htx.js +2 -0
- package/js/src/kucoin.js +2 -1
- package/js/src/kucoinfutures.d.ts +7 -1
- package/js/src/kucoinfutures.js +162 -2
- package/js/src/pro/binance.js +4 -4
- package/js/src/pro/hitbtc.d.ts +4 -1
- package/js/src/pro/hitbtc.js +122 -48
- package/js/src/pro/hollaex.js +5 -0
- package/js/src/pro/okx.js +19 -3
- package/js/src/pro/p2b.d.ts +2 -1
- package/js/src/pro/p2b.js +35 -1
- package/js/src/pro/whitebit.d.ts +2 -1
- package/js/src/pro/whitebit.js +31 -0
- package/package.json +1 -1
package/dist/cjs/ccxt.js
CHANGED
|
@@ -194,7 +194,7 @@ var xt$1 = require('./src/pro/xt.js');
|
|
|
194
194
|
|
|
195
195
|
//-----------------------------------------------------------------------------
|
|
196
196
|
// this is updated by vss.js when building
|
|
197
|
-
const version = '4.4.
|
|
197
|
+
const version = '4.4.9';
|
|
198
198
|
Exchange["default"].ccxtVersion = version;
|
|
199
199
|
const exchanges = {
|
|
200
200
|
'ace': ace,
|
package/dist/cjs/src/bigone.js
CHANGED
|
@@ -158,7 +158,7 @@ class bigone extends bigone$1 {
|
|
|
158
158
|
},
|
|
159
159
|
'webExchange': {
|
|
160
160
|
'get': [
|
|
161
|
-
'
|
|
161
|
+
'v3/assets',
|
|
162
162
|
],
|
|
163
163
|
},
|
|
164
164
|
},
|
|
@@ -338,7 +338,7 @@ class bigone extends bigone$1 {
|
|
|
338
338
|
* @returns {dict} an associative dictionary of currencies
|
|
339
339
|
*/
|
|
340
340
|
// we use undocumented link (possible, less informative alternative is : https://big.one/api/uc/v3/assets/accounts)
|
|
341
|
-
const data = await this.fetchWebEndpoint('fetchCurrencies', '
|
|
341
|
+
const data = await this.fetchWebEndpoint('fetchCurrencies', 'webExchangeGetV3Assets', true);
|
|
342
342
|
if (data === undefined) {
|
|
343
343
|
return undefined;
|
|
344
344
|
}
|
|
@@ -348,91 +348,40 @@ class bigone extends bigone$1 {
|
|
|
348
348
|
// "message": "",
|
|
349
349
|
// "data": [
|
|
350
350
|
// {
|
|
351
|
-
//
|
|
352
|
-
//
|
|
353
|
-
//
|
|
354
|
-
//
|
|
355
|
-
//
|
|
356
|
-
//
|
|
357
|
-
//
|
|
358
|
-
//
|
|
359
|
-
//
|
|
360
|
-
//
|
|
361
|
-
//
|
|
362
|
-
//
|
|
351
|
+
// "uuid": "17082d1c-0195-4fb6-8779-2cdbcb9eeb3c",
|
|
352
|
+
// "symbol": "USDT",
|
|
353
|
+
// "name": "TetherUS",
|
|
354
|
+
// "scale": 12,
|
|
355
|
+
// "is_fiat": false,
|
|
356
|
+
// "is_transfer_enabled": true,
|
|
357
|
+
// "transfer_scale": 12,
|
|
358
|
+
// "binding_gateways": [
|
|
359
|
+
// {
|
|
360
|
+
// "guid": "07efc37f-d1ec-4bc9-8339-a745256ea2ba",
|
|
361
|
+
// "is_deposit_enabled": true,
|
|
362
|
+
// "gateway_name": "Ethereum",
|
|
363
|
+
// "min_withdrawal_amount": "0.000001",
|
|
364
|
+
// "withdrawal_fee": "5.71",
|
|
365
|
+
// "is_withdrawal_enabled": true,
|
|
366
|
+
// "min_deposit_amount": "0.000001",
|
|
367
|
+
// "is_memo_required": false,
|
|
368
|
+
// "withdrawal_scale": 6,
|
|
369
|
+
// "scale": 12
|
|
370
|
+
// },
|
|
371
|
+
// {
|
|
372
|
+
// "guid": "4e387a9a-a480-40a3-b4ae-ed1773c2db5a",
|
|
373
|
+
// "is_deposit_enabled": true,
|
|
374
|
+
// "gateway_name": "BinanceSmartChain",
|
|
375
|
+
// "min_withdrawal_amount": "10",
|
|
376
|
+
// "withdrawal_fee": "5",
|
|
377
|
+
// "is_withdrawal_enabled": false,
|
|
378
|
+
// "min_deposit_amount": "1",
|
|
379
|
+
// "is_memo_required": false,
|
|
380
|
+
// "withdrawal_scale": 8,
|
|
381
|
+
// "scale": 12
|
|
382
|
+
// }
|
|
383
|
+
// ]
|
|
363
384
|
// },
|
|
364
|
-
// "info_link": null,
|
|
365
|
-
// "scale": "12",
|
|
366
|
-
// "default_gateway": ..., // one object from "gateways"
|
|
367
|
-
// "gateways": [
|
|
368
|
-
// {
|
|
369
|
-
// "uuid": "f0fa5a85-7f65-428a-b7b7-13aad55c2837",
|
|
370
|
-
// "name": "Mixin",
|
|
371
|
-
// "kind": "CHAIN",
|
|
372
|
-
// "required_confirmations": "0",
|
|
373
|
-
// },
|
|
374
|
-
// {
|
|
375
|
-
// "uuid": "b75446c6-1446-4c8d-b3d1-39f385b0a926",
|
|
376
|
-
// "name": "Ethereum",
|
|
377
|
-
// "kind": "CHAIN",
|
|
378
|
-
// "required_confirmations": "18",
|
|
379
|
-
// },
|
|
380
|
-
// {
|
|
381
|
-
// "uuid": "fe9b1b0b-e55c-4017-b5ce-16f524df5fc0",
|
|
382
|
-
// "name": "Tron",
|
|
383
|
-
// "kind": "CHAIN",
|
|
384
|
-
// "required_confirmations": "1",
|
|
385
|
-
// },
|
|
386
|
-
// ...
|
|
387
|
-
// ],
|
|
388
|
-
// "payments": [],
|
|
389
|
-
// "uuid": "17082d1c-0195-4fb6-8779-2cdbcb9eeb3c",
|
|
390
|
-
// "binding_gateways": [
|
|
391
|
-
// {
|
|
392
|
-
// "guid": "07efc37f-d1ec-4bc9-8339-a745256ea2ba",
|
|
393
|
-
// "contract_address": "0xdac17f958d2ee523a2206206994597c13d831ec7",
|
|
394
|
-
// "is_deposit_enabled": true,
|
|
395
|
-
// "display_name": "Ethereum(ERC20)",
|
|
396
|
-
// "gateway_name": "Ethereum",
|
|
397
|
-
// "min_withdrawal_amount": "0.000001",
|
|
398
|
-
// "min_internal_withdrawal_amount": "0.00000001",
|
|
399
|
-
// "withdrawal_fee": "14",
|
|
400
|
-
// "is_withdrawal_enabled": true,
|
|
401
|
-
// "min_deposit_amount": "0.000001",
|
|
402
|
-
// "is_memo_required": false,
|
|
403
|
-
// "withdrawal_scale": "2",
|
|
404
|
-
// "gateway": {
|
|
405
|
-
// "uuid": "b75446c6-1446-4c8d-b3d1-39f385b0a926",
|
|
406
|
-
// "name": "Ethereum",
|
|
407
|
-
// "kind": "CHAIN",
|
|
408
|
-
// "required_confirmations": "18",
|
|
409
|
-
// },
|
|
410
|
-
// "scale": "12",
|
|
411
|
-
// },
|
|
412
|
-
// {
|
|
413
|
-
// "guid": "b80a4d13-cac7-4319-842d-b33c3bfab8ec",
|
|
414
|
-
// "contract_address": "TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t",
|
|
415
|
-
// "is_deposit_enabled": true,
|
|
416
|
-
// "display_name": "Tron(TRC20)",
|
|
417
|
-
// "gateway_name": "Tron",
|
|
418
|
-
// "min_withdrawal_amount": "0.000001",
|
|
419
|
-
// "min_internal_withdrawal_amount": "0.00000001",
|
|
420
|
-
// "withdrawal_fee": "1",
|
|
421
|
-
// "is_withdrawal_enabled": true,
|
|
422
|
-
// "min_deposit_amount": "0.000001",
|
|
423
|
-
// "is_memo_required": false,
|
|
424
|
-
// "withdrawal_scale": "6",
|
|
425
|
-
// "gateway": {
|
|
426
|
-
// "uuid": "fe9b1b0b-e55c-4017-b5ce-16f524df5fc0",
|
|
427
|
-
// "name": "Tron",
|
|
428
|
-
// "kind": "CHAIN",
|
|
429
|
-
// "required_confirmations": "1",
|
|
430
|
-
// },
|
|
431
|
-
// "scale": "12",
|
|
432
|
-
// },
|
|
433
|
-
// ...
|
|
434
|
-
// ],
|
|
435
|
-
// },
|
|
436
385
|
// ...
|
|
437
386
|
// ],
|
|
438
387
|
// }
|
package/dist/cjs/src/bingx.js
CHANGED
|
@@ -648,7 +648,12 @@ class bingx extends bingx$1 {
|
|
|
648
648
|
// "maxNotional": 20000,
|
|
649
649
|
// "status": 1,
|
|
650
650
|
// "tickSize": 0.000001,
|
|
651
|
-
// "stepSize": 1
|
|
651
|
+
// "stepSize": 1,
|
|
652
|
+
// "apiStateSell": true,
|
|
653
|
+
// "apiStateBuy": true,
|
|
654
|
+
// "timeOnline": 0,
|
|
655
|
+
// "offTime": 0,
|
|
656
|
+
// "maintainTime": 0
|
|
652
657
|
// },
|
|
653
658
|
// ...
|
|
654
659
|
// ]
|
|
@@ -757,7 +762,7 @@ class bingx extends bingx$1 {
|
|
|
757
762
|
if ((this.safeString(market, 'apiStateOpen') === 'true') && (this.safeString(market, 'apiStateClose') === 'true')) {
|
|
758
763
|
isActive = true; // swap active
|
|
759
764
|
}
|
|
760
|
-
else if (this.safeBool(market, 'apiStateSell') && this.safeBool(market, 'apiStateBuy')) {
|
|
765
|
+
else if (this.safeBool(market, 'apiStateSell') && this.safeBool(market, 'apiStateBuy') && (this.safeNumber(market, 'status') === 1)) {
|
|
761
766
|
isActive = true; // spot active
|
|
762
767
|
}
|
|
763
768
|
const isInverse = (spot) ? undefined : checkIsInverse;
|
package/dist/cjs/src/bitget.js
CHANGED
|
@@ -1420,6 +1420,9 @@ class bitget extends bitget$1 {
|
|
|
1420
1420
|
'STARKNET': 'Starknet',
|
|
1421
1421
|
'OPTIMISM': 'Optimism',
|
|
1422
1422
|
'ARBITRUM': 'Arbitrum',
|
|
1423
|
+
'APT': 'APTOS',
|
|
1424
|
+
'MATIC': 'POLYGON',
|
|
1425
|
+
'VIC': 'VICTION',
|
|
1423
1426
|
},
|
|
1424
1427
|
'networksById': {},
|
|
1425
1428
|
'fetchPositions': {
|
package/dist/cjs/src/bybit.js
CHANGED
|
@@ -3709,6 +3709,7 @@ class bybit extends bybit$1 {
|
|
|
3709
3709
|
// Valid for option only.
|
|
3710
3710
|
// 'orderIv': '0', // Implied volatility; parameters are passed according to the real value; for example, for 10%, 0.1 is passed
|
|
3711
3711
|
};
|
|
3712
|
+
const hedged = this.safeBool(params, 'hedged', false);
|
|
3712
3713
|
let triggerPrice = this.safeValue2(params, 'triggerPrice', 'stopPrice');
|
|
3713
3714
|
const stopLossTriggerPrice = this.safeValue(params, 'stopLossPrice');
|
|
3714
3715
|
const takeProfitTriggerPrice = this.safeValue(params, 'takeProfitPrice');
|
|
@@ -3907,7 +3908,10 @@ class bybit extends bybit$1 {
|
|
|
3907
3908
|
}
|
|
3908
3909
|
}
|
|
3909
3910
|
}
|
|
3910
|
-
|
|
3911
|
+
if (!market['spot'] && hedged) {
|
|
3912
|
+
request['positionIdx'] = (side === 'buy') ? 1 : 2;
|
|
3913
|
+
}
|
|
3914
|
+
params = this.omit(params, ['stopPrice', 'timeInForce', 'stopLossPrice', 'takeProfitPrice', 'postOnly', 'clientOrderId', 'triggerPrice', 'stopLoss', 'takeProfit', 'trailingAmount', 'trailingTriggerPrice', 'hedged']);
|
|
3911
3915
|
return this.extend(request, params);
|
|
3912
3916
|
}
|
|
3913
3917
|
async createOrders(orders, params = {}) {
|
package/dist/cjs/src/gate.js
CHANGED
|
@@ -593,6 +593,8 @@ class gate extends gate$1 {
|
|
|
593
593
|
},
|
|
594
594
|
// copied from gatev2
|
|
595
595
|
'commonCurrencies': {
|
|
596
|
+
'ORT': 'XREATORS',
|
|
597
|
+
'ASS': 'ASSF',
|
|
596
598
|
'88MPH': 'MPH',
|
|
597
599
|
'AXIS': 'AXISDEFI',
|
|
598
600
|
'BIFI': 'BITCOINFILE',
|
|
@@ -627,6 +629,8 @@ class gate extends gate$1 {
|
|
|
627
629
|
},
|
|
628
630
|
'createMarketBuyOrderRequiresPrice': true,
|
|
629
631
|
'networks': {
|
|
632
|
+
'LINEA': 'LINEAETH',
|
|
633
|
+
'KON': 'KONET',
|
|
630
634
|
'AVAXC': 'AVAX_C',
|
|
631
635
|
'BEP20': 'BSC',
|
|
632
636
|
'EOS': 'EOS',
|
|
@@ -4709,6 +4713,7 @@ class gate extends gate$1 {
|
|
|
4709
4713
|
* @see https://www.gate.io/docs/developers/apiv4/en/#list-futures-orders-2
|
|
4710
4714
|
* @see https://www.gate.io/docs/developers/apiv4/en/#list-all-auto-orders-2
|
|
4711
4715
|
* @see https://www.gate.io/docs/developers/apiv4/en/#list-options-orders
|
|
4716
|
+
* @see https://www.gate.io/docs/developers/apiv4/en/#list-futures-orders-by-time-range
|
|
4712
4717
|
* @param {string} symbol unified market symbol of the market orders were made in
|
|
4713
4718
|
* @param {int} [since] the earliest time in ms to fetch orders for
|
|
4714
4719
|
* @param {int} [limit] the maximum number of order structures to retrieve
|
|
@@ -4716,9 +4721,38 @@ class gate extends gate$1 {
|
|
|
4716
4721
|
* @param {bool} [params.stop] true for fetching stop orders
|
|
4717
4722
|
* @param {string} [params.type] spot, swap or future, if not provided this.options['defaultType'] is used
|
|
4718
4723
|
* @param {string} [params.marginMode] 'cross' or 'isolated' - marginMode for margin trading if not provided this.options['defaultMarginMode'] is used
|
|
4724
|
+
* @param {boolean} [params.historical] *swap only* true for using historical endpoint
|
|
4719
4725
|
* @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
4720
4726
|
*/
|
|
4721
|
-
|
|
4727
|
+
await this.loadMarkets();
|
|
4728
|
+
const until = this.safeInteger(params, 'until');
|
|
4729
|
+
params = this.omit(params, 'until');
|
|
4730
|
+
let market = undefined;
|
|
4731
|
+
if (symbol !== undefined) {
|
|
4732
|
+
market = this.market(symbol);
|
|
4733
|
+
symbol = market['symbol'];
|
|
4734
|
+
}
|
|
4735
|
+
const res = this.handleMarketTypeAndParams('fetchClosedOrders', market, params);
|
|
4736
|
+
const type = this.safeString(res, 0);
|
|
4737
|
+
let useHistorical = false;
|
|
4738
|
+
[useHistorical, params] = this.handleOptionAndParams(params, 'fetchClosedOrders', 'historical', false);
|
|
4739
|
+
if (!useHistorical && ((since === undefined && until === undefined) || (type !== 'swap'))) {
|
|
4740
|
+
return await this.fetchOrdersByStatus('finished', symbol, since, limit, params);
|
|
4741
|
+
}
|
|
4742
|
+
params = this.omit(params, 'type');
|
|
4743
|
+
let request = {};
|
|
4744
|
+
[request, params] = this.prepareRequest(market, type, params);
|
|
4745
|
+
if (since !== undefined) {
|
|
4746
|
+
request['from'] = this.parseToInt(since / 1000);
|
|
4747
|
+
}
|
|
4748
|
+
if (until !== undefined) {
|
|
4749
|
+
request['to'] = this.parseToInt(until / 1000);
|
|
4750
|
+
}
|
|
4751
|
+
if (limit !== undefined) {
|
|
4752
|
+
request['limit'] = limit;
|
|
4753
|
+
}
|
|
4754
|
+
const response = await this.privateFuturesGetSettleOrdersTimerange(this.extend(request, params));
|
|
4755
|
+
return this.parseOrders(response, market, since, limit);
|
|
4722
4756
|
}
|
|
4723
4757
|
fetchOrdersByStatusRequest(status, symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
4724
4758
|
let market = undefined;
|
package/dist/cjs/src/htx.js
CHANGED
|
@@ -3124,6 +3124,7 @@ class htx extends htx$1 {
|
|
|
3124
3124
|
* @method
|
|
3125
3125
|
* @name htx#fetchAccounts
|
|
3126
3126
|
* @description fetch all the accounts associated with a profile
|
|
3127
|
+
* @see https://huobiapi.github.io/docs/spot/v1/en/#get-all-accounts-of-the-current-user
|
|
3127
3128
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
3128
3129
|
* @returns {object} a dictionary of [account structures]{@link https://docs.ccxt.com/#/?id=account-structure} indexed by the account type
|
|
3129
3130
|
*/
|
|
@@ -3197,6 +3198,7 @@ class htx extends htx$1 {
|
|
|
3197
3198
|
* @method
|
|
3198
3199
|
* @name htx#fetchCurrencies
|
|
3199
3200
|
* @description fetches all available currencies on an exchange
|
|
3201
|
+
* @see https://huobiapi.github.io/docs/spot/v1/en/#apiv2-currency-amp-chains
|
|
3200
3202
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
3201
3203
|
* @returns {object} an associative dictionary of currencies
|
|
3202
3204
|
*/
|
package/dist/cjs/src/kucoin.js
CHANGED
|
@@ -67,9 +67,10 @@ class kucoinfutures extends kucoinfutures$1 {
|
|
|
67
67
|
'fetchIsolatedBorrowRates': false,
|
|
68
68
|
'fetchL3OrderBook': true,
|
|
69
69
|
'fetchLedger': true,
|
|
70
|
+
'fetchLeverage': true,
|
|
70
71
|
'fetchLeverageTiers': false,
|
|
71
72
|
'fetchMarginAdjustmentHistory': false,
|
|
72
|
-
'fetchMarginMode':
|
|
73
|
+
'fetchMarginMode': true,
|
|
73
74
|
'fetchMarketLeverageTiers': true,
|
|
74
75
|
'fetchMarkets': true,
|
|
75
76
|
'fetchMarkOHLCV': false,
|
|
@@ -93,7 +94,7 @@ class kucoinfutures extends kucoinfutures$1 {
|
|
|
93
94
|
'fetchTransactionFee': false,
|
|
94
95
|
'fetchWithdrawals': true,
|
|
95
96
|
'setLeverage': false,
|
|
96
|
-
'setMarginMode':
|
|
97
|
+
'setMarginMode': true,
|
|
97
98
|
'transfer': true,
|
|
98
99
|
'withdraw': undefined,
|
|
99
100
|
},
|
|
@@ -170,12 +171,15 @@ class kucoinfutures extends kucoinfutures$1 {
|
|
|
170
171
|
'trade-fees': 1,
|
|
171
172
|
'history-positions': 1,
|
|
172
173
|
'getMaxOpenSize': 1,
|
|
174
|
+
'getCrossUserLeverage': 1,
|
|
175
|
+
'position/getMarginMode': 1,
|
|
173
176
|
},
|
|
174
177
|
'post': {
|
|
175
178
|
'withdrawals': 1,
|
|
176
179
|
'transfer-out': 1,
|
|
177
180
|
'transfer-in': 1,
|
|
178
181
|
'orders': 1.33,
|
|
182
|
+
'st-orders': 1.33,
|
|
179
183
|
'orders/test': 1.33,
|
|
180
184
|
'position/margin/auto-deposit-status': 1,
|
|
181
185
|
'position/margin/deposit-margin': 1,
|
|
@@ -183,6 +187,8 @@ class kucoinfutures extends kucoinfutures$1 {
|
|
|
183
187
|
'bullet-private': 1,
|
|
184
188
|
'sub/api-key': 1,
|
|
185
189
|
'sub/api-key/update': 1,
|
|
190
|
+
'changeCrossUserLeverage': 1,
|
|
191
|
+
'position/changeMarginMode': 1,
|
|
186
192
|
},
|
|
187
193
|
'delete': {
|
|
188
194
|
'withdrawals/{withdrawalId}': 1,
|
|
@@ -317,9 +323,13 @@ class kucoinfutures extends kucoinfutures$1 {
|
|
|
317
323
|
'futuresPrivate': {
|
|
318
324
|
'GET': {
|
|
319
325
|
'getMaxOpenSize': 'v2',
|
|
326
|
+
'getCrossUserLeverage': 'v2',
|
|
327
|
+
'position/getMarginMode': 'v2',
|
|
320
328
|
},
|
|
321
329
|
'POST': {
|
|
322
330
|
'transfer-out': 'v2',
|
|
331
|
+
'changeCrossUserLeverage': 'v2',
|
|
332
|
+
'position/changeMarginMode': 'v2',
|
|
323
333
|
},
|
|
324
334
|
},
|
|
325
335
|
'futuresPublic': {
|
|
@@ -2878,6 +2888,156 @@ class kucoinfutures extends kucoinfutures$1 {
|
|
|
2878
2888
|
'tierBased': true,
|
|
2879
2889
|
};
|
|
2880
2890
|
}
|
|
2891
|
+
async fetchMarginMode(symbol, params = {}) {
|
|
2892
|
+
/**
|
|
2893
|
+
* @method
|
|
2894
|
+
* @name kucoinfutures#fetchMarginMode
|
|
2895
|
+
* @description fetches the margin mode of a trading pair
|
|
2896
|
+
* @see https://www.kucoin.com/docs/rest/futures-trading/positions/get-margin-mode
|
|
2897
|
+
* @param {string} symbol unified symbol of the market to fetch the margin mode for
|
|
2898
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
2899
|
+
* @returns {object} a [margin mode structure]{@link https://docs.ccxt.com/#/?id=margin-mode-structure}
|
|
2900
|
+
*/
|
|
2901
|
+
await this.loadMarkets();
|
|
2902
|
+
const market = this.market(symbol);
|
|
2903
|
+
const request = {
|
|
2904
|
+
'symbol': market['id'],
|
|
2905
|
+
};
|
|
2906
|
+
const response = await this.futuresPrivateGetPositionGetMarginMode(this.extend(request, params));
|
|
2907
|
+
//
|
|
2908
|
+
// {
|
|
2909
|
+
// "code": "200000",
|
|
2910
|
+
// "data": {
|
|
2911
|
+
// "symbol": "XBTUSDTM",
|
|
2912
|
+
// "marginMode": "ISOLATED"
|
|
2913
|
+
// }
|
|
2914
|
+
// }
|
|
2915
|
+
//
|
|
2916
|
+
const data = this.safeDict(response, 'data', {});
|
|
2917
|
+
return this.parseMarginMode(data, market);
|
|
2918
|
+
}
|
|
2919
|
+
parseMarginMode(marginMode, market = undefined) {
|
|
2920
|
+
let marginType = this.safeString(marginMode, 'marginMode');
|
|
2921
|
+
marginType = (marginType === 'ISOLATED') ? 'isolated' : 'cross';
|
|
2922
|
+
return {
|
|
2923
|
+
'info': marginMode,
|
|
2924
|
+
'symbol': market['symbol'],
|
|
2925
|
+
'marginMode': marginType,
|
|
2926
|
+
};
|
|
2927
|
+
}
|
|
2928
|
+
async setMarginMode(marginMode, symbol = undefined, params = {}) {
|
|
2929
|
+
/**
|
|
2930
|
+
* @method
|
|
2931
|
+
* @name kucoinfutures#setMarginMode
|
|
2932
|
+
* @description set margin mode to 'cross' or 'isolated'
|
|
2933
|
+
* @see https://www.kucoin.com/docs/rest/futures-trading/positions/modify-margin-mode
|
|
2934
|
+
* @param {string} marginMode 'cross' or 'isolated'
|
|
2935
|
+
* @param {string} symbol unified market symbol
|
|
2936
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
2937
|
+
* @returns {object} response from the exchange
|
|
2938
|
+
*/
|
|
2939
|
+
if (symbol === undefined) {
|
|
2940
|
+
throw new errors.ArgumentsRequired(this.id + ' setMarginMode() requires a symbol argument');
|
|
2941
|
+
}
|
|
2942
|
+
this.checkRequiredArgument('setMarginMode', marginMode, 'marginMode', ['cross', 'isolated']);
|
|
2943
|
+
await this.loadMarkets();
|
|
2944
|
+
const market = this.market(symbol);
|
|
2945
|
+
const request = {
|
|
2946
|
+
'symbol': market['id'],
|
|
2947
|
+
'marginMode': marginMode.toUpperCase(),
|
|
2948
|
+
};
|
|
2949
|
+
const response = await this.futuresPrivatePostPositionChangeMarginMode(this.extend(request, params));
|
|
2950
|
+
//
|
|
2951
|
+
// {
|
|
2952
|
+
// "code": "200000",
|
|
2953
|
+
// "data": {
|
|
2954
|
+
// "symbol": "XBTUSDTM",
|
|
2955
|
+
// "marginMode": "ISOLATED"
|
|
2956
|
+
// }
|
|
2957
|
+
// }
|
|
2958
|
+
//
|
|
2959
|
+
const data = this.safeDict(response, 'data', {});
|
|
2960
|
+
return this.parseMarginMode(data, market);
|
|
2961
|
+
}
|
|
2962
|
+
async fetchLeverage(symbol, params = {}) {
|
|
2963
|
+
/**
|
|
2964
|
+
* @method
|
|
2965
|
+
* @name kucoin#fetchLeverage
|
|
2966
|
+
* @description fetch the set leverage for a market
|
|
2967
|
+
* @see https://www.kucoin.com/docs/rest/futures-trading/positions/get-cross-margin-leverage
|
|
2968
|
+
* @param {string} symbol unified market symbol
|
|
2969
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
2970
|
+
* @returns {object} a [leverage structure]{@link https://docs.ccxt.com/#/?id=leverage-structure}
|
|
2971
|
+
*/
|
|
2972
|
+
let marginMode = undefined;
|
|
2973
|
+
[marginMode, params] = this.handleMarginModeAndParams(symbol, params);
|
|
2974
|
+
if (marginMode !== 'cross') {
|
|
2975
|
+
throw new errors.NotSupported(this.id + ' fetchLeverage() currently supports only params["marginMode"] = "cross"');
|
|
2976
|
+
}
|
|
2977
|
+
await this.loadMarkets();
|
|
2978
|
+
const market = this.market(symbol);
|
|
2979
|
+
const request = {
|
|
2980
|
+
'symbol': market['id'],
|
|
2981
|
+
};
|
|
2982
|
+
const response = await this.futuresPrivateGetGetCrossUserLeverage(this.extend(request, params));
|
|
2983
|
+
//
|
|
2984
|
+
// {
|
|
2985
|
+
// "code": "200000",
|
|
2986
|
+
// "data": {
|
|
2987
|
+
// "symbol": "XBTUSDTM",
|
|
2988
|
+
// "leverage": "3"
|
|
2989
|
+
// }
|
|
2990
|
+
// }
|
|
2991
|
+
//
|
|
2992
|
+
const data = this.safeDict(response, 'data', {});
|
|
2993
|
+
const parsed = this.parseLeverage(data, market);
|
|
2994
|
+
return this.extend(parsed, {
|
|
2995
|
+
'marginMode': marginMode,
|
|
2996
|
+
});
|
|
2997
|
+
}
|
|
2998
|
+
async setLeverage(leverage, symbol = undefined, params = {}) {
|
|
2999
|
+
/**
|
|
3000
|
+
* @method
|
|
3001
|
+
* @name kucoinfutures#setLeverage
|
|
3002
|
+
* @description set the level of leverage for a market
|
|
3003
|
+
* @see https://www.kucoin.com/docs/rest/futures-trading/positions/modify-cross-margin-leverage
|
|
3004
|
+
* @param {float} leverage the rate of leverage
|
|
3005
|
+
* @param {string} symbol unified market symbol
|
|
3006
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
3007
|
+
* @returns {object} response from the exchange
|
|
3008
|
+
*/
|
|
3009
|
+
let marginMode = undefined;
|
|
3010
|
+
[marginMode, params] = this.handleMarginModeAndParams(symbol, params);
|
|
3011
|
+
if (marginMode !== 'cross') {
|
|
3012
|
+
throw new errors.NotSupported(this.id + ' setLeverage() currently supports only params["marginMode"] = "cross"');
|
|
3013
|
+
}
|
|
3014
|
+
await this.loadMarkets();
|
|
3015
|
+
const market = this.market(symbol);
|
|
3016
|
+
const request = {
|
|
3017
|
+
'symbol': market['id'],
|
|
3018
|
+
'leverage': leverage.toString(),
|
|
3019
|
+
};
|
|
3020
|
+
const response = await this.futuresPrivatePostChangeCrossUserLeverage(this.extend(request, params));
|
|
3021
|
+
//
|
|
3022
|
+
// {
|
|
3023
|
+
// "code": "200000",
|
|
3024
|
+
// "data": true
|
|
3025
|
+
// }
|
|
3026
|
+
//
|
|
3027
|
+
return this.parseLeverage(response, market);
|
|
3028
|
+
}
|
|
3029
|
+
parseLeverage(leverage, market = undefined) {
|
|
3030
|
+
const marketId = this.safeString(leverage, 'symbol');
|
|
3031
|
+
market = this.safeMarket(marketId, market);
|
|
3032
|
+
const leverageNum = this.safeInteger(leverage, 'leverage');
|
|
3033
|
+
return {
|
|
3034
|
+
'info': leverage,
|
|
3035
|
+
'symbol': market['symbol'],
|
|
3036
|
+
'marginMode': undefined,
|
|
3037
|
+
'longLeverage': leverageNum,
|
|
3038
|
+
'shortLeverage': leverageNum,
|
|
3039
|
+
};
|
|
3040
|
+
}
|
|
2881
3041
|
}
|
|
2882
3042
|
|
|
2883
3043
|
module.exports = kucoinfutures;
|
|
@@ -2643,16 +2643,16 @@ class binance extends binance$1 {
|
|
|
2643
2643
|
[subType, params] = this.handleSubTypeAndParams('watchBalance', undefined, params);
|
|
2644
2644
|
let isPortfolioMargin = undefined;
|
|
2645
2645
|
[isPortfolioMargin, params] = this.handleOptionAndParams2(params, 'watchBalance', 'papi', 'portfolioMargin', false);
|
|
2646
|
-
let urlType = type;
|
|
2647
|
-
if (isPortfolioMargin) {
|
|
2648
|
-
urlType = 'papi';
|
|
2649
|
-
}
|
|
2650
2646
|
if (this.isLinear(type, subType)) {
|
|
2651
2647
|
type = 'future';
|
|
2652
2648
|
}
|
|
2653
2649
|
else if (this.isInverse(type, subType)) {
|
|
2654
2650
|
type = 'delivery';
|
|
2655
2651
|
}
|
|
2652
|
+
let urlType = type;
|
|
2653
|
+
if (isPortfolioMargin) {
|
|
2654
|
+
urlType = 'papi';
|
|
2655
|
+
}
|
|
2656
2656
|
const url = this.urls['api']['ws'][urlType] + '/' + this.options[type]['listenKey'];
|
|
2657
2657
|
const client = this.client(url);
|
|
2658
2658
|
this.setBalanceCache(client, type, isPortfolioMargin);
|