ccxt 4.2.57 → 4.2.59
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/CHANGELOG.md +83 -0
- package/README.md +4 -5
- package/build.sh +1 -1
- package/cleanup.sh +3 -0
- package/dist/ccxt.browser.js +772 -497
- package/dist/ccxt.browser.min.js +7 -7
- package/dist/cjs/ccxt.js +1 -1
- package/dist/cjs/src/alpaca.js +90 -88
- package/dist/cjs/src/base/Exchange.js +24 -1
- package/dist/cjs/src/binance.js +43 -30
- package/dist/cjs/src/bingx.js +15 -4
- package/dist/cjs/src/bitget.js +72 -57
- package/dist/cjs/src/bitmex.js +13 -29
- package/dist/cjs/src/bitrue.js +24 -15
- package/dist/cjs/src/blofin.js +25 -2
- package/dist/cjs/src/bybit.js +11 -3
- package/dist/cjs/src/coinbase.js +24 -14
- package/dist/cjs/src/currencycom.js +15 -5
- package/dist/cjs/src/delta.js +14 -1
- package/dist/cjs/src/gate.js +1 -1
- package/dist/cjs/src/hitbtc.js +12 -1
- package/dist/cjs/src/krakenfutures.js +22 -7
- package/dist/cjs/src/kuna.js +14 -11
- package/dist/cjs/src/lbank.js +1 -1
- package/dist/cjs/src/mexc.js +20 -20
- package/dist/cjs/src/okx.js +32 -2
- package/dist/cjs/src/phemex.js +1 -1
- package/dist/cjs/src/pro/alpaca.js +1 -1
- package/dist/cjs/src/pro/binance.js +1 -1
- package/dist/cjs/src/pro/bitfinex2.js +1 -1
- package/dist/cjs/src/pro/bitget.js +1 -1
- package/dist/cjs/src/pro/bitmart.js +51 -89
- package/dist/cjs/src/pro/bitvavo.js +1 -1
- package/dist/cjs/src/pro/bybit.js +1 -1
- package/dist/cjs/src/pro/coinex.js +1 -1
- package/dist/cjs/src/pro/cryptocom.js +1 -1
- package/dist/cjs/src/pro/deribit.js +201 -84
- package/dist/cjs/src/pro/gate.js +1 -1
- package/dist/cjs/src/pro/independentreserve.js +1 -1
- package/dist/cjs/src/pro/kraken.js +1 -1
- package/dist/cjs/src/pro/kucoinfutures.js +1 -1
- package/dist/cjs/src/pro/mexc.js +5 -3
- package/dist/cjs/src/pro/okx.js +1 -1
- package/dist/cjs/src/pro/whitebit.js +4 -6
- package/dist/cjs/src/pro/woo.js +1 -1
- package/dist/cjs/src/probit.js +1 -1
- package/dist/cjs/src/wavesexchange.js +1 -1
- package/dist/cjs/src/woo.js +22 -6
- package/js/ccxt.d.ts +3 -3
- package/js/ccxt.js +1 -1
- package/js/src/alpaca.js +90 -88
- package/js/src/base/Exchange.d.ts +6 -4
- package/js/src/base/Exchange.js +24 -1
- package/js/src/base/types.d.ts +9 -0
- package/js/src/binance.d.ts +3 -2
- package/js/src/binance.js +43 -30
- package/js/src/bingx.d.ts +3 -2
- package/js/src/bingx.js +15 -4
- package/js/src/bitget.d.ts +3 -2
- package/js/src/bitget.js +72 -57
- package/js/src/bitmex.d.ts +3 -3
- package/js/src/bitmex.js +13 -29
- package/js/src/bitrue.js +24 -15
- package/js/src/blofin.d.ts +3 -2
- package/js/src/blofin.js +25 -2
- package/js/src/bybit.d.ts +3 -6
- package/js/src/bybit.js +11 -3
- package/js/src/coinbase.js +24 -14
- package/js/src/currencycom.d.ts +3 -2
- package/js/src/currencycom.js +15 -5
- package/js/src/delta.d.ts +3 -2
- package/js/src/delta.js +14 -1
- package/js/src/gate.js +1 -1
- package/js/src/hitbtc.d.ts +3 -2
- package/js/src/hitbtc.js +12 -1
- package/js/src/krakenfutures.d.ts +3 -2
- package/js/src/krakenfutures.js +22 -7
- package/js/src/kuna.js +14 -11
- package/js/src/lbank.js +1 -1
- package/js/src/mexc.d.ts +3 -13
- package/js/src/mexc.js +20 -20
- package/js/src/okx.d.ts +3 -2
- package/js/src/okx.js +32 -2
- package/js/src/phemex.js +1 -1
- package/js/src/pro/alpaca.js +1 -1
- package/js/src/pro/binance.js +1 -1
- package/js/src/pro/bitfinex2.js +1 -1
- package/js/src/pro/bitget.js +1 -1
- package/js/src/pro/bitmart.d.ts +2 -2
- package/js/src/pro/bitmart.js +51 -89
- package/js/src/pro/bitvavo.js +1 -1
- package/js/src/pro/bybit.js +1 -1
- package/js/src/pro/coinex.js +1 -1
- package/js/src/pro/cryptocom.js +1 -1
- package/js/src/pro/deribit.d.ts +5 -0
- package/js/src/pro/deribit.js +202 -85
- package/js/src/pro/gate.js +1 -1
- package/js/src/pro/independentreserve.js +1 -1
- package/js/src/pro/kraken.js +1 -1
- package/js/src/pro/kucoinfutures.js +1 -1
- package/js/src/pro/mexc.js +6 -4
- package/js/src/pro/okx.js +1 -1
- package/js/src/pro/whitebit.js +4 -6
- package/js/src/pro/woo.js +1 -1
- package/js/src/probit.js +1 -1
- package/js/src/wavesexchange.js +1 -1
- package/js/src/woo.d.ts +3 -5
- package/js/src/woo.js +22 -6
- package/package.json +1 -1
- package/skip-tests.json +8 -3
package/dist/cjs/ccxt.js
CHANGED
|
@@ -176,7 +176,7 @@ var woo$1 = require('./src/pro/woo.js');
|
|
|
176
176
|
|
|
177
177
|
//-----------------------------------------------------------------------------
|
|
178
178
|
// this is updated by vss.js when building
|
|
179
|
-
const version = '4.2.
|
|
179
|
+
const version = '4.2.59';
|
|
180
180
|
Exchange["default"].ccxtVersion = version;
|
|
181
181
|
const exchanges = {
|
|
182
182
|
'ace': ace,
|
package/dist/cjs/src/alpaca.js
CHANGED
|
@@ -440,7 +440,7 @@ class alpaca extends alpaca$1 {
|
|
|
440
440
|
'loc': loc,
|
|
441
441
|
};
|
|
442
442
|
params = this.omit(params, ['loc', 'method']);
|
|
443
|
-
let
|
|
443
|
+
let symbolTrades = undefined;
|
|
444
444
|
if (method === 'marketPublicGetV1beta3CryptoLocTrades') {
|
|
445
445
|
if (since !== undefined) {
|
|
446
446
|
request['start'] = this.iso8601(since);
|
|
@@ -448,47 +448,48 @@ class alpaca extends alpaca$1 {
|
|
|
448
448
|
if (limit !== undefined) {
|
|
449
449
|
request['limit'] = limit;
|
|
450
450
|
}
|
|
451
|
-
response = await this.marketPublicGetV1beta3CryptoLocTrades(this.extend(request, params));
|
|
451
|
+
const response = await this.marketPublicGetV1beta3CryptoLocTrades(this.extend(request, params));
|
|
452
|
+
//
|
|
453
|
+
// {
|
|
454
|
+
// "next_page_token": null,
|
|
455
|
+
// "trades": {
|
|
456
|
+
// "BTC/USD": [
|
|
457
|
+
// {
|
|
458
|
+
// "i": 36440704,
|
|
459
|
+
// "p": 22625,
|
|
460
|
+
// "s": 0.0001,
|
|
461
|
+
// "t": "2022-07-21T11:47:31.073391Z",
|
|
462
|
+
// "tks": "B"
|
|
463
|
+
// }
|
|
464
|
+
// ]
|
|
465
|
+
// }
|
|
466
|
+
// }
|
|
467
|
+
//
|
|
468
|
+
const trades = this.safeDict(response, 'trades', {});
|
|
469
|
+
symbolTrades = this.safeList(trades, marketId, []);
|
|
452
470
|
}
|
|
453
471
|
else if (method === 'marketPublicGetV1beta3CryptoLocLatestTrades') {
|
|
454
|
-
response = await this.marketPublicGetV1beta3CryptoLocLatestTrades(this.extend(request, params));
|
|
472
|
+
const response = await this.marketPublicGetV1beta3CryptoLocLatestTrades(this.extend(request, params));
|
|
473
|
+
//
|
|
474
|
+
// {
|
|
475
|
+
// "trades": {
|
|
476
|
+
// "BTC/USD": {
|
|
477
|
+
// "i": 36440704,
|
|
478
|
+
// "p": 22625,
|
|
479
|
+
// "s": 0.0001,
|
|
480
|
+
// "t": "2022-07-21T11:47:31.073391Z",
|
|
481
|
+
// "tks": "B"
|
|
482
|
+
// }
|
|
483
|
+
// }
|
|
484
|
+
// }
|
|
485
|
+
//
|
|
486
|
+
const trades = this.safeDict(response, 'trades', {});
|
|
487
|
+
symbolTrades = this.safeDict(trades, marketId, {});
|
|
488
|
+
symbolTrades = [symbolTrades];
|
|
455
489
|
}
|
|
456
490
|
else {
|
|
457
491
|
throw new errors.NotSupported(this.id + ' fetchTrades() does not support ' + method + ', marketPublicGetV1beta3CryptoLocTrades and marketPublicGetV1beta3CryptoLocLatestTrades are supported');
|
|
458
492
|
}
|
|
459
|
-
//
|
|
460
|
-
// {
|
|
461
|
-
// "next_page_token":null,
|
|
462
|
-
// "trades":{
|
|
463
|
-
// "BTC/USD":[
|
|
464
|
-
// {
|
|
465
|
-
// "i":36440704,
|
|
466
|
-
// "p":22625,
|
|
467
|
-
// "s":0.0001,
|
|
468
|
-
// "t":"2022-07-21T11:47:31.073391Z",
|
|
469
|
-
// "tks":"B"
|
|
470
|
-
// }
|
|
471
|
-
// ]
|
|
472
|
-
// }
|
|
473
|
-
// }
|
|
474
|
-
//
|
|
475
|
-
// {
|
|
476
|
-
// "trades":{
|
|
477
|
-
// "BTC/USD":{
|
|
478
|
-
// "i":36440704,
|
|
479
|
-
// "p":22625,
|
|
480
|
-
// "s":0.0001,
|
|
481
|
-
// "t":"2022-07-21T11:47:31.073391Z",
|
|
482
|
-
// "tks":"B"
|
|
483
|
-
// }
|
|
484
|
-
// }
|
|
485
|
-
// }
|
|
486
|
-
//
|
|
487
|
-
const trades = this.safeValue(response, 'trades', {});
|
|
488
|
-
let symbolTrades = this.safeValue(trades, marketId, {});
|
|
489
|
-
if (!Array.isArray(symbolTrades)) {
|
|
490
|
-
symbolTrades = [symbolTrades];
|
|
491
|
-
}
|
|
492
493
|
return this.parseTrades(symbolTrades, market, since, limit);
|
|
493
494
|
}
|
|
494
495
|
async fetchOrderBook(symbol, limit = undefined, params = {}) {
|
|
@@ -580,7 +581,7 @@ class alpaca extends alpaca$1 {
|
|
|
580
581
|
'loc': loc,
|
|
581
582
|
};
|
|
582
583
|
params = this.omit(params, ['loc', 'method']);
|
|
583
|
-
let
|
|
584
|
+
let ohlcvs = undefined;
|
|
584
585
|
if (method === 'marketPublicGetV1beta3CryptoLocBars') {
|
|
585
586
|
if (limit !== undefined) {
|
|
586
587
|
request['limit'] = limit;
|
|
@@ -589,63 +590,64 @@ class alpaca extends alpaca$1 {
|
|
|
589
590
|
request['start'] = this.yyyymmdd(since);
|
|
590
591
|
}
|
|
591
592
|
request['timeframe'] = this.safeString(this.timeframes, timeframe, timeframe);
|
|
592
|
-
response = await this.marketPublicGetV1beta3CryptoLocBars(this.extend(request, params));
|
|
593
|
+
const response = await this.marketPublicGetV1beta3CryptoLocBars(this.extend(request, params));
|
|
594
|
+
//
|
|
595
|
+
// {
|
|
596
|
+
// "bars": {
|
|
597
|
+
// "BTC/USD": [
|
|
598
|
+
// {
|
|
599
|
+
// "c": 22887,
|
|
600
|
+
// "h": 22888,
|
|
601
|
+
// "l": 22873,
|
|
602
|
+
// "n": 11,
|
|
603
|
+
// "o": 22883,
|
|
604
|
+
// "t": "2022-07-21T05:00:00Z",
|
|
605
|
+
// "v": 1.1138,
|
|
606
|
+
// "vw": 22883.0155324116
|
|
607
|
+
// },
|
|
608
|
+
// {
|
|
609
|
+
// "c": 22895,
|
|
610
|
+
// "h": 22895,
|
|
611
|
+
// "l": 22884,
|
|
612
|
+
// "n": 6,
|
|
613
|
+
// "o": 22884,
|
|
614
|
+
// "t": "2022-07-21T05:01:00Z",
|
|
615
|
+
// "v": 0.001,
|
|
616
|
+
// "vw": 22889.5
|
|
617
|
+
// }
|
|
618
|
+
// ]
|
|
619
|
+
// },
|
|
620
|
+
// "next_page_token": "QlRDL1VTRHxNfDIwMjItMDctMjFUMDU6MDE6MDAuMDAwMDAwMDAwWg=="
|
|
621
|
+
// }
|
|
622
|
+
//
|
|
623
|
+
const bars = this.safeDict(response, 'bars', {});
|
|
624
|
+
ohlcvs = this.safeList(bars, marketId, []);
|
|
593
625
|
}
|
|
594
626
|
else if (method === 'marketPublicGetV1beta3CryptoLocLatestBars') {
|
|
595
|
-
response = await this.marketPublicGetV1beta3CryptoLocLatestBars(this.extend(request, params));
|
|
627
|
+
const response = await this.marketPublicGetV1beta3CryptoLocLatestBars(this.extend(request, params));
|
|
628
|
+
//
|
|
629
|
+
// {
|
|
630
|
+
// "bars": {
|
|
631
|
+
// "BTC/USD": {
|
|
632
|
+
// "c": 22887,
|
|
633
|
+
// "h": 22888,
|
|
634
|
+
// "l": 22873,
|
|
635
|
+
// "n": 11,
|
|
636
|
+
// "o": 22883,
|
|
637
|
+
// "t": "2022-07-21T05:00:00Z",
|
|
638
|
+
// "v": 1.1138,
|
|
639
|
+
// "vw": 22883.0155324116
|
|
640
|
+
// }
|
|
641
|
+
// }
|
|
642
|
+
// }
|
|
643
|
+
//
|
|
644
|
+
const bars = this.safeDict(response, 'bars', {});
|
|
645
|
+
ohlcvs = this.safeDict(bars, marketId, {});
|
|
646
|
+
ohlcvs = [ohlcvs];
|
|
596
647
|
}
|
|
597
648
|
else {
|
|
598
649
|
throw new errors.NotSupported(this.id + ' fetchOHLCV() does not support ' + method + ', marketPublicGetV1beta3CryptoLocBars and marketPublicGetV1beta3CryptoLocLatestBars are supported');
|
|
599
650
|
}
|
|
600
|
-
//
|
|
601
|
-
// {
|
|
602
|
-
// "bars":{
|
|
603
|
-
// "BTC/USD":[
|
|
604
|
-
// {
|
|
605
|
-
// "c":22887,
|
|
606
|
-
// "h":22888,
|
|
607
|
-
// "l":22873,
|
|
608
|
-
// "n":11,
|
|
609
|
-
// "o":22883,
|
|
610
|
-
// "t":"2022-07-21T05:00:00Z",
|
|
611
|
-
// "v":1.1138,
|
|
612
|
-
// "vw":22883.0155324116
|
|
613
|
-
// },
|
|
614
|
-
// {
|
|
615
|
-
// "c":22895,
|
|
616
|
-
// "h":22895,
|
|
617
|
-
// "l":22884,
|
|
618
|
-
// "n":6,
|
|
619
|
-
// "o":22884,
|
|
620
|
-
// "t":"2022-07-21T05:01:00Z",
|
|
621
|
-
// "v":0.001,
|
|
622
|
-
// "vw":22889.5
|
|
623
|
-
// }
|
|
624
|
-
// ]
|
|
625
|
-
// },
|
|
626
|
-
// "next_page_token":"QlRDL1VTRHxNfDIwMjItMDctMjFUMDU6MDE6MDAuMDAwMDAwMDAwWg=="
|
|
627
|
-
// }
|
|
628
|
-
//
|
|
629
|
-
// {
|
|
630
|
-
// "bars":{
|
|
631
|
-
// "BTC/USD":{
|
|
632
|
-
// "c":22887,
|
|
633
|
-
// "h":22888,
|
|
634
|
-
// "l":22873,
|
|
635
|
-
// "n":11,
|
|
636
|
-
// "o":22883,
|
|
637
|
-
// "t":"2022-07-21T05:00:00Z",
|
|
638
|
-
// "v":1.1138,
|
|
639
|
-
// "vw":22883.0155324116
|
|
640
|
-
// }
|
|
641
|
-
// }
|
|
642
|
-
// }
|
|
643
|
-
//
|
|
644
|
-
const bars = this.safeValue(response, 'bars', {});
|
|
645
|
-
let ohlcvs = this.safeValue(bars, marketId, {});
|
|
646
|
-
if (!Array.isArray(ohlcvs)) {
|
|
647
|
-
ohlcvs = [ohlcvs];
|
|
648
|
-
}
|
|
649
651
|
return this.parseOHLCVs(ohlcvs, market, timeframe, since, limit);
|
|
650
652
|
}
|
|
651
653
|
parseOHLCV(ohlcv, market = undefined) {
|
|
@@ -1988,7 +1988,13 @@ class Exchange {
|
|
|
1988
1988
|
throw new errors.NotSupported(this.id + ' setLeverage() is not supported yet');
|
|
1989
1989
|
}
|
|
1990
1990
|
async fetchLeverage(symbol, params = {}) {
|
|
1991
|
-
|
|
1991
|
+
if (this.has['fetchLeverages']) {
|
|
1992
|
+
const leverages = await this.fetchLeverages([symbol], params);
|
|
1993
|
+
return this.safeDict(leverages, symbol);
|
|
1994
|
+
}
|
|
1995
|
+
else {
|
|
1996
|
+
throw new errors.NotSupported(this.id + ' fetchLeverage() is not supported yet');
|
|
1997
|
+
}
|
|
1992
1998
|
}
|
|
1993
1999
|
async fetchLeverages(symbols = undefined, params = {}) {
|
|
1994
2000
|
throw new errors.NotSupported(this.id + ' fetchLeverages() is not supported yet');
|
|
@@ -3889,6 +3895,8 @@ class Exchange {
|
|
|
3889
3895
|
params = this.omit(params, [optionName, defaultOptionName]);
|
|
3890
3896
|
}
|
|
3891
3897
|
else {
|
|
3898
|
+
// handle routed methods like "watchTrades > watchTradesForSymbols" (or "watchTicker > watchTickers")
|
|
3899
|
+
[methodName, params] = this.handleParamString(params, 'callerMethodName', methodName);
|
|
3892
3900
|
// check if exchange has properties for this method
|
|
3893
3901
|
const exchangeWideMethodOptions = this.safeValue(this.options, methodName);
|
|
3894
3902
|
if (exchangeWideMethodOptions !== undefined) {
|
|
@@ -5587,6 +5595,21 @@ class Exchange {
|
|
|
5587
5595
|
parseMarginMode(marginMode, market = undefined) {
|
|
5588
5596
|
throw new errors.NotSupported(this.id + ' parseMarginMode () is not supported yet');
|
|
5589
5597
|
}
|
|
5598
|
+
parseLeverages(response, symbols = undefined, symbolKey = undefined, marketType = undefined) {
|
|
5599
|
+
const leverageStructures = {};
|
|
5600
|
+
for (let i = 0; i < response.length; i++) {
|
|
5601
|
+
const info = response[i];
|
|
5602
|
+
const marketId = this.safeString(info, symbolKey);
|
|
5603
|
+
const market = this.safeMarket(marketId, undefined, undefined, marketType);
|
|
5604
|
+
if ((symbols === undefined) || this.inArray(market['symbol'], symbols)) {
|
|
5605
|
+
leverageStructures[market['symbol']] = this.parseLeverage(info, market);
|
|
5606
|
+
}
|
|
5607
|
+
}
|
|
5608
|
+
return leverageStructures;
|
|
5609
|
+
}
|
|
5610
|
+
parseLeverage(leverage, market = undefined) {
|
|
5611
|
+
throw new errors.NotSupported(this.id + ' parseLeverage() is not supported yet');
|
|
5612
|
+
}
|
|
5590
5613
|
}
|
|
5591
5614
|
|
|
5592
5615
|
exports.Exchange = Exchange;
|
package/dist/cjs/src/binance.js
CHANGED
|
@@ -94,7 +94,8 @@ class binance extends binance$1 {
|
|
|
94
94
|
'fetchLastPrices': true,
|
|
95
95
|
'fetchLedger': true,
|
|
96
96
|
'fetchLedgerEntry': true,
|
|
97
|
-
'fetchLeverage':
|
|
97
|
+
'fetchLeverage': 'emulated',
|
|
98
|
+
'fetchLeverages': true,
|
|
98
99
|
'fetchLeverageTiers': true,
|
|
99
100
|
'fetchLiquidations': false,
|
|
100
101
|
'fetchMarginMode': 'emulated',
|
|
@@ -4809,7 +4810,7 @@ class binance extends binance$1 {
|
|
|
4809
4810
|
let stopPriceIsRequired = false;
|
|
4810
4811
|
let quantityIsRequired = false;
|
|
4811
4812
|
if (uppercaseType === 'MARKET') {
|
|
4812
|
-
const quoteOrderQty = this.
|
|
4813
|
+
const quoteOrderQty = this.safeBool(this.options, 'quoteOrderQty', true);
|
|
4813
4814
|
if (quoteOrderQty) {
|
|
4814
4815
|
const quoteOrderQtyNew = this.safeValue2(params, 'quoteOrderQty', 'cost');
|
|
4815
4816
|
const precision = market['precision']['price'];
|
|
@@ -10317,7 +10318,7 @@ class binance extends binance$1 {
|
|
|
10317
10318
|
// POST https://fapi.binance.com/fapi/v1/marginType 400 Bad Request
|
|
10318
10319
|
// binanceusdm
|
|
10319
10320
|
if (e instanceof errors.MarginModeAlreadySet) {
|
|
10320
|
-
const throwMarginModeAlreadySet = this.
|
|
10321
|
+
const throwMarginModeAlreadySet = this.safeBool(this.options, 'throwMarginModeAlreadySet', false);
|
|
10321
10322
|
if (throwMarginModeAlreadySet) {
|
|
10322
10323
|
throw e;
|
|
10323
10324
|
}
|
|
@@ -10388,31 +10389,27 @@ class binance extends binance$1 {
|
|
|
10388
10389
|
//
|
|
10389
10390
|
return response;
|
|
10390
10391
|
}
|
|
10391
|
-
async
|
|
10392
|
+
async fetchLeverages(symbols = undefined, params = {}) {
|
|
10392
10393
|
/**
|
|
10393
10394
|
* @method
|
|
10394
|
-
* @name binance#
|
|
10395
|
-
* @description fetch the set leverage for
|
|
10395
|
+
* @name binance#fetchLeverages
|
|
10396
|
+
* @description fetch the set leverage for all markets
|
|
10396
10397
|
* @see https://binance-docs.github.io/apidocs/futures/en/#account-information-v2-user_data
|
|
10397
10398
|
* @see https://binance-docs.github.io/apidocs/delivery/en/#account-information-user_data
|
|
10398
10399
|
* @see https://binance-docs.github.io/apidocs/pm/en/#get-um-account-detail-user_data
|
|
10399
10400
|
* @see https://binance-docs.github.io/apidocs/pm/en/#get-cm-account-detail-user_data
|
|
10400
|
-
* @param {string}
|
|
10401
|
+
* @param {string[]} [symbols] a list of unified market symbols
|
|
10401
10402
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
10402
|
-
* @returns {object} a [leverage
|
|
10403
|
+
* @returns {object} a list of [leverage structures]{@link https://docs.ccxt.com/#/?id=leverage-structure}
|
|
10403
10404
|
*/
|
|
10404
10405
|
await this.loadMarkets();
|
|
10405
10406
|
await this.loadLeverageBrackets(false, params);
|
|
10406
|
-
const market = this.market(symbol);
|
|
10407
|
-
if (!market['contract']) {
|
|
10408
|
-
throw new errors.NotSupported(this.id + ' fetchLeverage() supports linear and inverse contracts only');
|
|
10409
|
-
}
|
|
10410
10407
|
let type = undefined;
|
|
10411
|
-
[type, params] = this.handleMarketTypeAndParams('
|
|
10408
|
+
[type, params] = this.handleMarketTypeAndParams('fetchLeverages', undefined, params);
|
|
10412
10409
|
let subType = undefined;
|
|
10413
|
-
[subType, params] = this.handleSubTypeAndParams('
|
|
10410
|
+
[subType, params] = this.handleSubTypeAndParams('fetchLeverages', undefined, params, 'linear');
|
|
10414
10411
|
let isPortfolioMargin = undefined;
|
|
10415
|
-
[isPortfolioMargin, params] = this.handleOptionAndParams2(params, '
|
|
10412
|
+
[isPortfolioMargin, params] = this.handleOptionAndParams2(params, 'fetchLeverages', 'papi', 'portfolioMargin', false);
|
|
10416
10413
|
let response = undefined;
|
|
10417
10414
|
if (this.isLinear(type, subType)) {
|
|
10418
10415
|
if (isPortfolioMargin) {
|
|
@@ -10431,23 +10428,39 @@ class binance extends binance$1 {
|
|
|
10431
10428
|
}
|
|
10432
10429
|
}
|
|
10433
10430
|
else {
|
|
10434
|
-
throw new errors.NotSupported(this.id + '
|
|
10431
|
+
throw new errors.NotSupported(this.id + ' fetchLeverages() supports linear and inverse contracts only');
|
|
10435
10432
|
}
|
|
10436
|
-
const
|
|
10437
|
-
|
|
10438
|
-
|
|
10439
|
-
|
|
10440
|
-
|
|
10441
|
-
|
|
10442
|
-
|
|
10443
|
-
|
|
10444
|
-
|
|
10445
|
-
'marginMode': marginMode,
|
|
10446
|
-
'leverage': this.safeInteger(position, 'leverage'),
|
|
10447
|
-
};
|
|
10448
|
-
}
|
|
10433
|
+
const leverages = this.safeList(response, 'positions', []);
|
|
10434
|
+
return this.parseLeverages(leverages, symbols, 'symbol');
|
|
10435
|
+
}
|
|
10436
|
+
parseLeverage(leverage, market = undefined) {
|
|
10437
|
+
const marketId = this.safeString(leverage, 'symbol');
|
|
10438
|
+
const marginModeRaw = this.safeBool(leverage, 'isolated');
|
|
10439
|
+
let marginMode = undefined;
|
|
10440
|
+
if (marginModeRaw !== undefined) {
|
|
10441
|
+
marginMode = marginModeRaw ? 'isolated' : 'cross';
|
|
10449
10442
|
}
|
|
10450
|
-
|
|
10443
|
+
const side = this.safeStringLower(leverage, 'positionSide');
|
|
10444
|
+
let longLeverage = undefined;
|
|
10445
|
+
let shortLeverage = undefined;
|
|
10446
|
+
const leverageValue = this.safeInteger(leverage, 'leverage');
|
|
10447
|
+
if (side === 'both') {
|
|
10448
|
+
longLeverage = leverageValue;
|
|
10449
|
+
shortLeverage = leverageValue;
|
|
10450
|
+
}
|
|
10451
|
+
else if (side === 'long') {
|
|
10452
|
+
longLeverage = leverageValue;
|
|
10453
|
+
}
|
|
10454
|
+
else if (side === 'short') {
|
|
10455
|
+
shortLeverage = leverageValue;
|
|
10456
|
+
}
|
|
10457
|
+
return {
|
|
10458
|
+
'info': leverage,
|
|
10459
|
+
'symbol': this.safeSymbol(marketId, market),
|
|
10460
|
+
'marginMode': marginMode,
|
|
10461
|
+
'longLeverage': longLeverage,
|
|
10462
|
+
'shortLeverage': shortLeverage,
|
|
10463
|
+
};
|
|
10451
10464
|
}
|
|
10452
10465
|
async fetchSettlementHistory(symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
10453
10466
|
/**
|
package/dist/cjs/src/bingx.js
CHANGED
|
@@ -449,7 +449,7 @@ class bingx extends bingx$1 {
|
|
|
449
449
|
if (!this.checkRequiredCredentials(false)) {
|
|
450
450
|
return undefined;
|
|
451
451
|
}
|
|
452
|
-
const isSandbox = this.
|
|
452
|
+
const isSandbox = this.safeBool(this.options, 'sandboxMode', false);
|
|
453
453
|
if (isSandbox) {
|
|
454
454
|
return undefined;
|
|
455
455
|
}
|
|
@@ -693,7 +693,7 @@ class bingx extends bingx$1 {
|
|
|
693
693
|
* @returns {object[]} an array of objects representing market data
|
|
694
694
|
*/
|
|
695
695
|
const requests = [this.fetchSwapMarkets(params)];
|
|
696
|
-
const isSandbox = this.
|
|
696
|
+
const isSandbox = this.safeBool(this.options, 'sandboxMode', false);
|
|
697
697
|
if (!isSandbox) {
|
|
698
698
|
requests.push(this.fetchSpotMarkets(params)); // sandbox is swap only
|
|
699
699
|
}
|
|
@@ -3496,7 +3496,18 @@ class bingx extends bingx$1 {
|
|
|
3496
3496
|
// }
|
|
3497
3497
|
// }
|
|
3498
3498
|
//
|
|
3499
|
-
|
|
3499
|
+
const data = this.safeDict(response, 'data', {});
|
|
3500
|
+
return this.parseLeverage(data, market);
|
|
3501
|
+
}
|
|
3502
|
+
parseLeverage(leverage, market = undefined) {
|
|
3503
|
+
const marketId = this.safeString(leverage, 'symbol');
|
|
3504
|
+
return {
|
|
3505
|
+
'info': leverage,
|
|
3506
|
+
'symbol': this.safeSymbol(marketId, market),
|
|
3507
|
+
'marginMode': undefined,
|
|
3508
|
+
'longLeverage': this.safeInteger(leverage, 'longLeverage'),
|
|
3509
|
+
'shortLeverage': this.safeInteger(leverage, 'shortLeverage'),
|
|
3510
|
+
};
|
|
3500
3511
|
}
|
|
3501
3512
|
async setLeverage(leverage, symbol = undefined, params = {}) {
|
|
3502
3513
|
/**
|
|
@@ -4159,7 +4170,7 @@ class bingx extends bingx$1 {
|
|
|
4159
4170
|
const type = section[0];
|
|
4160
4171
|
const version = section[1];
|
|
4161
4172
|
const access = section[2];
|
|
4162
|
-
const isSandbox = this.
|
|
4173
|
+
const isSandbox = this.safeBool(this.options, 'sandboxMode', false);
|
|
4163
4174
|
if (isSandbox && (type !== 'swap')) {
|
|
4164
4175
|
throw new errors.NotSupported(this.id + ' does not have a testnet/sandbox URL for ' + type + ' endpoints');
|
|
4165
4176
|
}
|