ccxt 4.5.38 → 4.5.40
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 +5 -7
- package/dist/ccxt.browser.min.js +3 -3
- package/dist/cjs/ccxt.js +1 -6
- package/dist/cjs/src/base/Exchange.js +62 -5
- package/dist/cjs/src/binance.js +151 -2
- package/dist/cjs/src/bingx.js +137 -120
- package/dist/cjs/src/bitget.js +47 -1
- package/dist/cjs/src/bitmart.js +23 -8
- package/dist/cjs/src/bitmex.js +416 -0
- package/dist/cjs/src/bitstamp.js +264 -43
- package/dist/cjs/src/bitvavo.js +10 -0
- package/dist/cjs/src/blofin.js +85 -0
- package/dist/cjs/src/btcmarkets.js +1 -1
- package/dist/cjs/src/bybit.js +135 -0
- package/dist/cjs/src/coinspot.js +77 -7
- package/dist/cjs/src/delta.js +367 -0
- package/dist/cjs/src/htx.js +265 -2
- package/dist/cjs/src/hyperliquid.js +37 -8
- package/dist/cjs/src/krakenfutures.js +4 -0
- package/dist/cjs/src/kucoinfutures.js +121 -0
- package/dist/cjs/src/mexc.js +9 -1
- package/dist/cjs/src/phemex.js +359 -0
- package/dist/cjs/src/poloniex.js +5 -0
- package/dist/cjs/src/pro/binance.js +111 -26
- package/dist/cjs/src/pro/bingx.js +33 -33
- package/dist/cjs/src/pro/bitget.js +48 -90
- package/dist/cjs/src/pro/bitmart.js +68 -0
- package/dist/cjs/src/pro/blofin.js +52 -1
- package/dist/cjs/src/pro/bybit.js +2 -2
- package/dist/cjs/src/pro/coinbaseinternational.js +5 -2
- package/dist/cjs/src/pro/mexc.js +72 -0
- package/dist/cjs/src/pro/okx.js +8 -5
- package/dist/cjs/src/pro/paradex.js +137 -0
- package/dist/cjs/src/pro/woo.js +43 -0
- package/dist/cjs/src/tokocrypto.js +23 -0
- package/dist/cjs/src/toobit.js +20 -0
- package/dist/cjs/src/whitebit.js +11 -10
- package/dist/cjs/src/woo.js +103 -3
- package/js/ccxt.d.ts +3 -9
- package/js/ccxt.js +2 -6
- package/js/src/abstract/binance.d.ts +5 -0
- package/js/src/abstract/binancecoinm.d.ts +5 -0
- package/js/src/abstract/binanceus.d.ts +5 -0
- package/js/src/abstract/binanceusdm.d.ts +5 -0
- package/js/src/abstract/bitget.d.ts +47 -1
- package/js/src/abstract/bitstamp.d.ts +1 -1
- package/js/src/abstract/bitvavo.d.ts +10 -0
- package/js/src/abstract/coinspot.d.ts +45 -0
- package/js/src/base/Exchange.d.ts +11 -8
- package/js/src/base/Exchange.js +65 -5
- package/js/src/base/types.d.ts +9 -0
- package/js/src/binance.d.ts +26 -1
- package/js/src/binance.js +151 -2
- package/js/src/bingx.d.ts +113 -108
- package/js/src/bingx.js +137 -120
- package/js/src/bitget.js +47 -1
- package/js/src/bitmart.js +23 -8
- package/js/src/bitmex.d.ts +50 -1
- package/js/src/bitmex.js +416 -0
- package/js/src/bitstamp.d.ts +52 -1
- package/js/src/bitstamp.js +264 -43
- package/js/src/bitvavo.js +10 -0
- package/js/src/blofin.d.ts +12 -1
- package/js/src/blofin.js +85 -0
- package/js/src/btcmarkets.js +1 -1
- package/js/src/bybit.d.ts +12 -1
- package/js/src/bybit.js +135 -0
- package/js/src/coinspot.js +77 -7
- package/js/src/delta.d.ts +12 -1
- package/js/src/delta.js +367 -0
- package/js/src/htx.d.ts +15 -1
- package/js/src/htx.js +265 -2
- package/js/src/hyperliquid.js +37 -8
- package/js/src/krakenfutures.js +4 -0
- package/js/src/kucoinfutures.d.ts +12 -1
- package/js/src/kucoinfutures.js +121 -0
- package/js/src/mexc.js +9 -1
- package/js/src/phemex.d.ts +16 -1
- package/js/src/phemex.js +359 -0
- package/js/src/poloniex.js +5 -0
- package/js/src/pro/binance.d.ts +13 -0
- package/js/src/pro/binance.js +111 -26
- package/js/src/pro/bingx.d.ts +33 -33
- package/js/src/pro/bingx.js +33 -33
- package/js/src/pro/bitget.d.ts +6 -6
- package/js/src/pro/bitget.js +48 -90
- package/js/src/pro/bitmart.d.ts +22 -1
- package/js/src/pro/bitmart.js +69 -1
- package/js/src/pro/blofin.d.ts +12 -1
- package/js/src/pro/blofin.js +52 -1
- package/js/src/pro/bybit.d.ts +1 -1
- package/js/src/pro/bybit.js +2 -2
- package/js/src/pro/coinbaseinternational.d.ts +2 -2
- package/js/src/pro/coinbaseinternational.js +6 -3
- package/js/src/pro/mexc.d.ts +22 -1
- package/js/src/pro/mexc.js +72 -0
- package/js/src/pro/okx.d.ts +4 -4
- package/js/src/pro/okx.js +8 -5
- package/js/src/pro/paradex.d.ts +23 -1
- package/js/src/pro/paradex.js +137 -0
- package/js/src/pro/woo.d.ts +12 -1
- package/js/src/pro/woo.js +43 -0
- package/js/src/tokocrypto.js +23 -0
- package/js/src/toobit.js +20 -0
- package/js/src/whitebit.js +8 -8
- package/js/src/woo.d.ts +12 -1
- package/js/src/woo.js +103 -3
- package/package.json +1 -1
- package/dist/cjs/src/abstract/probit.js +0 -11
- package/dist/cjs/src/pro/probit.js +0 -594
- package/dist/cjs/src/probit.js +0 -1936
- package/js/src/abstract/probit.d.ts +0 -26
- package/js/src/abstract/probit.js +0 -11
- package/js/src/pro/probit.d.ts +0 -91
- package/js/src/pro/probit.js +0 -593
- package/js/src/probit.d.ts +0 -283
- package/js/src/probit.js +0 -1935
package/dist/cjs/ccxt.js
CHANGED
|
@@ -105,7 +105,6 @@ var paradex = require('./src/paradex.js');
|
|
|
105
105
|
var paymium = require('./src/paymium.js');
|
|
106
106
|
var phemex = require('./src/phemex.js');
|
|
107
107
|
var poloniex = require('./src/poloniex.js');
|
|
108
|
-
var probit = require('./src/probit.js');
|
|
109
108
|
var timex = require('./src/timex.js');
|
|
110
109
|
var tokocrypto = require('./src/tokocrypto.js');
|
|
111
110
|
var toobit = require('./src/toobit.js');
|
|
@@ -190,7 +189,6 @@ var p2b$1 = require('./src/pro/p2b.js');
|
|
|
190
189
|
var paradex$1 = require('./src/pro/paradex.js');
|
|
191
190
|
var phemex$1 = require('./src/pro/phemex.js');
|
|
192
191
|
var poloniex$1 = require('./src/pro/poloniex.js');
|
|
193
|
-
var probit$1 = require('./src/pro/probit.js');
|
|
194
192
|
var toobit$1 = require('./src/pro/toobit.js');
|
|
195
193
|
var upbit$1 = require('./src/pro/upbit.js');
|
|
196
194
|
var whitebit$1 = require('./src/pro/whitebit.js');
|
|
@@ -200,7 +198,7 @@ var xt$1 = require('./src/pro/xt.js');
|
|
|
200
198
|
|
|
201
199
|
//-----------------------------------------------------------------------------
|
|
202
200
|
// this is updated by vss.js when building
|
|
203
|
-
const version = '4.5.
|
|
201
|
+
const version = '4.5.40';
|
|
204
202
|
Exchange["default"].ccxtVersion = version;
|
|
205
203
|
const exchanges = {
|
|
206
204
|
'alp': alp["default"],
|
|
@@ -300,7 +298,6 @@ const exchanges = {
|
|
|
300
298
|
'paymium': paymium["default"],
|
|
301
299
|
'phemex': phemex["default"],
|
|
302
300
|
'poloniex': poloniex["default"],
|
|
303
|
-
'probit': probit["default"],
|
|
304
301
|
'timex': timex["default"],
|
|
305
302
|
'tokocrypto': tokocrypto["default"],
|
|
306
303
|
'toobit': toobit["default"],
|
|
@@ -387,7 +384,6 @@ const pro = {
|
|
|
387
384
|
'paradex': paradex$1["default"],
|
|
388
385
|
'phemex': phemex$1["default"],
|
|
389
386
|
'poloniex': poloniex$1["default"],
|
|
390
|
-
'probit': probit$1["default"],
|
|
391
387
|
'toobit': toobit$1["default"],
|
|
392
388
|
'upbit': upbit$1["default"],
|
|
393
389
|
'whitebit': whitebit$1["default"],
|
|
@@ -543,7 +539,6 @@ exports.paradex = paradex["default"];
|
|
|
543
539
|
exports.paymium = paymium["default"];
|
|
544
540
|
exports.phemex = phemex["default"];
|
|
545
541
|
exports.poloniex = poloniex["default"];
|
|
546
|
-
exports.probit = probit["default"];
|
|
547
542
|
exports.timex = timex["default"];
|
|
548
543
|
exports.tokocrypto = tokocrypto["default"];
|
|
549
544
|
exports.toobit = toobit["default"];
|
|
@@ -33,7 +33,6 @@ var typedData$1 = require('../static_dependencies/starknet/utils/typedData.js');
|
|
|
33
33
|
var sha1 = require('../static_dependencies/noble-hashes/sha1.js');
|
|
34
34
|
var onboarding = require('../static_dependencies/dydx-v4-client/onboarding.js');
|
|
35
35
|
require('../static_dependencies/dydx-v4-client/helpers.js');
|
|
36
|
-
var generic = require('./functions/generic.js');
|
|
37
36
|
var misc = require('./functions/misc.js');
|
|
38
37
|
var index$3 = require('../static_dependencies/dydx-v4-client/long/index.cjs.js');
|
|
39
38
|
|
|
@@ -191,8 +190,6 @@ class Exchange {
|
|
|
191
190
|
this.deepExtend = deepExtend;
|
|
192
191
|
this.deepExtendSafe = deepExtend;
|
|
193
192
|
this.isNode = isNode;
|
|
194
|
-
this.keys = generic.keys;
|
|
195
|
-
this.values = generic.values;
|
|
196
193
|
this.extend = extend;
|
|
197
194
|
this.clone = clone;
|
|
198
195
|
this.flatten = flatten;
|
|
@@ -1706,6 +1703,7 @@ class Exchange {
|
|
|
1706
1703
|
'editOrders': undefined,
|
|
1707
1704
|
'editOrderWs': undefined,
|
|
1708
1705
|
'fetchAccounts': undefined,
|
|
1706
|
+
'fetchADLRank': undefined,
|
|
1709
1707
|
'fetchBalance': true,
|
|
1710
1708
|
'fetchBalanceWs': undefined,
|
|
1711
1709
|
'fetchBidsAsks': undefined,
|
|
@@ -1791,6 +1789,8 @@ class Exchange {
|
|
|
1791
1789
|
'fetchOrderTrades': undefined,
|
|
1792
1790
|
'fetchOrderWs': undefined,
|
|
1793
1791
|
'fetchPosition': undefined,
|
|
1792
|
+
'fetchPositionADLRank': undefined,
|
|
1793
|
+
'fetchPositionsADLRank': undefined,
|
|
1794
1794
|
'fetchPositionHistory': undefined,
|
|
1795
1795
|
'fetchPositionsHistory': undefined,
|
|
1796
1796
|
'fetchPositionWs': undefined,
|
|
@@ -2624,9 +2624,12 @@ class Exchange {
|
|
|
2624
2624
|
async watchFundingRate(symbol, params = {}) {
|
|
2625
2625
|
throw new errors.NotSupported(this.id + ' watchFundingRate() is not supported yet');
|
|
2626
2626
|
}
|
|
2627
|
-
async watchFundingRates(symbols, params = {}) {
|
|
2627
|
+
async watchFundingRates(symbols = undefined, params = {}) {
|
|
2628
2628
|
throw new errors.NotSupported(this.id + ' watchFundingRates() is not supported yet');
|
|
2629
2629
|
}
|
|
2630
|
+
async unWatchFundingRates(symbols = undefined, params = {}) {
|
|
2631
|
+
throw new errors.NotSupported(this.id + ' unWatchFundingRates() is not supported yet');
|
|
2632
|
+
}
|
|
2630
2633
|
async watchFundingRatesForSymbols(symbols, params = {}) {
|
|
2631
2634
|
return await this.watchFundingRates(symbols, params);
|
|
2632
2635
|
}
|
|
@@ -2696,7 +2699,13 @@ class Exchange {
|
|
|
2696
2699
|
throw new errors.NotSupported(this.id + ' fetchOpenInterestHistory() is not supported yet');
|
|
2697
2700
|
}
|
|
2698
2701
|
async fetchOpenInterest(symbol, params = {}) {
|
|
2699
|
-
|
|
2702
|
+
if (this.has['fetchOpenInterests']) {
|
|
2703
|
+
const openInterests = await this.fetchOpenInterests([symbol], params);
|
|
2704
|
+
return this.safeDict(openInterests, symbol);
|
|
2705
|
+
}
|
|
2706
|
+
else {
|
|
2707
|
+
throw new errors.NotSupported(this.id + ' fetchOpenInterest() is not supported yet');
|
|
2708
|
+
}
|
|
2700
2709
|
}
|
|
2701
2710
|
async fetchOpenInterests(symbols = undefined, params = {}) {
|
|
2702
2711
|
throw new errors.NotSupported(this.id + ' fetchOpenInterests() is not supported yet');
|
|
@@ -4636,6 +4645,19 @@ class Exchange {
|
|
|
4636
4645
|
}
|
|
4637
4646
|
return this.filterByArrayPositions(result, 'symbol', symbols, false);
|
|
4638
4647
|
}
|
|
4648
|
+
parseADLRank(info, market = undefined) {
|
|
4649
|
+
throw new errors.NotSupported(this.id + ' parseADLRank() is not supported yet');
|
|
4650
|
+
}
|
|
4651
|
+
parseADLRanks(ranks, symbols = undefined, params = {}) {
|
|
4652
|
+
symbols = this.marketSymbols(symbols);
|
|
4653
|
+
ranks = this.toArray(ranks);
|
|
4654
|
+
const result = [];
|
|
4655
|
+
for (let i = 0; i < ranks.length; i++) {
|
|
4656
|
+
const rank = this.extend(this.parseADLRank(ranks[i], undefined), params);
|
|
4657
|
+
result.push(rank);
|
|
4658
|
+
}
|
|
4659
|
+
return this.filterByArrayPositions(result, 'symbol', symbols, false);
|
|
4660
|
+
}
|
|
4639
4661
|
parseAccounts(accounts, params = {}) {
|
|
4640
4662
|
accounts = this.toArray(accounts);
|
|
4641
4663
|
const result = [];
|
|
@@ -5475,6 +5497,9 @@ class Exchange {
|
|
|
5475
5497
|
async unWatchTickers(symbols = undefined, params = {}) {
|
|
5476
5498
|
throw new errors.NotSupported(this.id + ' unWatchTickers() is not supported yet');
|
|
5477
5499
|
}
|
|
5500
|
+
async unWatchFundingRate(symbol, params = {}) {
|
|
5501
|
+
throw new errors.NotSupported(this.id + ' unWatchFundingRate() is not supported yet');
|
|
5502
|
+
}
|
|
5478
5503
|
async fetchOrder(id, symbol = undefined, params = {}) {
|
|
5479
5504
|
throw new errors.NotSupported(this.id + ' fetchOrder() is not supported yet');
|
|
5480
5505
|
}
|
|
@@ -5521,6 +5546,30 @@ class Exchange {
|
|
|
5521
5546
|
async fetchPositionMode(symbol = undefined, params = {}) {
|
|
5522
5547
|
throw new errors.NotSupported(this.id + ' fetchPositionMode() is not supported yet');
|
|
5523
5548
|
}
|
|
5549
|
+
async fetchADLRank(symbol, params = {}) {
|
|
5550
|
+
throw new errors.NotSupported(this.id + ' fetchADLRank() is not supported yet');
|
|
5551
|
+
}
|
|
5552
|
+
async fetchPositionsADLRank(symbols = undefined, params = {}) {
|
|
5553
|
+
throw new errors.NotSupported(this.id + ' fetchPositionsADLRank() is not supported yet');
|
|
5554
|
+
}
|
|
5555
|
+
async fetchPositionADLRank(symbol, params = {}) {
|
|
5556
|
+
if (this.has['fetchPositionsADLRank']) {
|
|
5557
|
+
await this.loadMarkets();
|
|
5558
|
+
const market = this.market(symbol);
|
|
5559
|
+
symbol = market['symbol'];
|
|
5560
|
+
const ranks = await this.fetchPositionsADLRank([symbol], params);
|
|
5561
|
+
const rank = this.safeDict(ranks, 0);
|
|
5562
|
+
if (rank === undefined) {
|
|
5563
|
+
throw new errors.NullResponse(this.id + ' fetchPositionsADLRank() could not find a rank for ' + symbol);
|
|
5564
|
+
}
|
|
5565
|
+
else {
|
|
5566
|
+
return rank;
|
|
5567
|
+
}
|
|
5568
|
+
}
|
|
5569
|
+
else {
|
|
5570
|
+
throw new errors.NotSupported(this.id + ' fetchPositionsADLRank() is not supported yet');
|
|
5571
|
+
}
|
|
5572
|
+
}
|
|
5524
5573
|
async createTrailingAmountOrder(symbol, type, side, amount, price = undefined, trailingAmount = undefined, trailingTriggerPrice = undefined, params = {}) {
|
|
5525
5574
|
/**
|
|
5526
5575
|
* @method
|
|
@@ -7181,6 +7230,14 @@ class Exchange {
|
|
|
7181
7230
|
*/
|
|
7182
7231
|
return this.filterByArray(objects, key, values, indexed);
|
|
7183
7232
|
}
|
|
7233
|
+
filterByArrayADLRanks(objects, key, values = undefined, indexed = true) {
|
|
7234
|
+
/**
|
|
7235
|
+
* @ignore
|
|
7236
|
+
* @method
|
|
7237
|
+
* @description Typed wrapper for filterByArray that returns a list of ADL Ranks
|
|
7238
|
+
*/
|
|
7239
|
+
return this.filterByArray(objects, key, values, indexed);
|
|
7240
|
+
}
|
|
7184
7241
|
createOHLCVObject(symbol, timeframe, data) {
|
|
7185
7242
|
const res = {};
|
|
7186
7243
|
res[symbol] = {};
|
package/dist/cjs/src/binance.js
CHANGED
|
@@ -66,6 +66,7 @@ class binance extends binance$1["default"] {
|
|
|
66
66
|
'editOrder': true,
|
|
67
67
|
'editOrders': true,
|
|
68
68
|
'fetchAccounts': undefined,
|
|
69
|
+
'fetchADLRank': true,
|
|
69
70
|
'fetchAllGreeks': true,
|
|
70
71
|
'fetchBalance': true,
|
|
71
72
|
'fetchBidsAsks': true,
|
|
@@ -135,9 +136,11 @@ class binance extends binance$1["default"] {
|
|
|
135
136
|
'fetchOrders': true,
|
|
136
137
|
'fetchOrderTrades': true,
|
|
137
138
|
'fetchPosition': true,
|
|
139
|
+
'fetchPositionADLRank': true,
|
|
138
140
|
'fetchPositionHistory': false,
|
|
139
141
|
'fetchPositionMode': true,
|
|
140
142
|
'fetchPositions': true,
|
|
143
|
+
'fetchPositionsADLRank': true,
|
|
141
144
|
'fetchPositionsHistory': false,
|
|
142
145
|
'fetchPositionsRisk': true,
|
|
143
146
|
'fetchPremiumIndexOHLCV': true,
|
|
@@ -540,6 +543,10 @@ class binance extends binance$1["default"] {
|
|
|
540
543
|
'dci/product/list': 0.1,
|
|
541
544
|
'dci/product/positions': 0.1,
|
|
542
545
|
'dci/product/accounts': 0.1,
|
|
546
|
+
// Discount Buy
|
|
547
|
+
'accumulator/product/list': 0.1,
|
|
548
|
+
'accumulator/product/position/list': 0.1,
|
|
549
|
+
'accumulator/product/sum-holding': 0.1,
|
|
543
550
|
},
|
|
544
551
|
'post': {
|
|
545
552
|
'asset/dust': 0.06667,
|
|
@@ -581,6 +588,7 @@ class binance extends binance$1["default"] {
|
|
|
581
588
|
'managed-subaccount/withdraw': 0.1,
|
|
582
589
|
'userDataStream': 0.1,
|
|
583
590
|
'userDataStream/isolated': 0.1,
|
|
591
|
+
'userListenToken': 0.1,
|
|
584
592
|
'futures/transfer': 0.1,
|
|
585
593
|
// lending
|
|
586
594
|
'lending/customizedFixed/purchase': 0.1,
|
|
@@ -677,6 +685,8 @@ class binance extends binance$1["default"] {
|
|
|
677
685
|
// convert
|
|
678
686
|
'dci/product/subscribe': 0.1,
|
|
679
687
|
'dci/product/auto_compound/edit': 0.1,
|
|
688
|
+
// discount buy
|
|
689
|
+
'accumulator/product/subscribe': 0.1,
|
|
680
690
|
},
|
|
681
691
|
'put': {
|
|
682
692
|
'userDataStream': 0.1,
|
|
@@ -4722,7 +4732,7 @@ class binance extends binance$1["default"] {
|
|
|
4722
4732
|
// binance docs say that the default limit 500, max 1500 for futures, max 1000 for spot markets
|
|
4723
4733
|
// the reality is that the time range wider than 500 candles won't work right
|
|
4724
4734
|
const defaultLimit = 500;
|
|
4725
|
-
const maxLimit =
|
|
4735
|
+
const maxLimit = 1000;
|
|
4726
4736
|
const price = this.safeString(params, 'price');
|
|
4727
4737
|
const until = this.safeInteger(params, 'until');
|
|
4728
4738
|
params = this.omit(params, ['price', 'until']);
|
|
@@ -12204,7 +12214,7 @@ class binance extends binance$1["default"] {
|
|
|
12204
12214
|
throw new errors.AuthenticationError(this.id + ' historicalTrades endpoint requires `apiKey` credential');
|
|
12205
12215
|
}
|
|
12206
12216
|
}
|
|
12207
|
-
const userDataStream = (path === 'userDataStream') || (path === 'listenKey');
|
|
12217
|
+
const userDataStream = (path === 'userDataStream') || (path === 'listenKey') || (path === 'userListenToken');
|
|
12208
12218
|
if (userDataStream) {
|
|
12209
12219
|
if (this.apiKey) {
|
|
12210
12220
|
// v1 special case for userDataStream
|
|
@@ -14618,6 +14628,145 @@ class binance extends binance$1["default"] {
|
|
|
14618
14628
|
'longShortRatio': this.safeNumber(info, 'longShortRatio'),
|
|
14619
14629
|
};
|
|
14620
14630
|
}
|
|
14631
|
+
/**
|
|
14632
|
+
* @method
|
|
14633
|
+
* @name binance#fetchADLRank
|
|
14634
|
+
* @description fetches the auto deleveraging rank and risk percentage for a symbol
|
|
14635
|
+
* @see https://developers.binance.com/docs/derivatives/usds-margined-futures/market-data/rest-api/ADL-Risk
|
|
14636
|
+
* @param {string} symbol unified symbol of the market to fetch the auto deleveraging rank for
|
|
14637
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
14638
|
+
* @returns {object} an [auto de leverage structure]{@link https://docs.ccxt.com/?id=auto-de-leverage-structure}
|
|
14639
|
+
*/
|
|
14640
|
+
async fetchADLRank(symbol, params = {}) {
|
|
14641
|
+
await this.loadMarkets();
|
|
14642
|
+
const market = this.market(symbol);
|
|
14643
|
+
const request = {
|
|
14644
|
+
'symbol': market['id'],
|
|
14645
|
+
};
|
|
14646
|
+
let subType = undefined;
|
|
14647
|
+
[subType, params] = this.handleSubTypeAndParams('fetchADLRank', market, params);
|
|
14648
|
+
let response = undefined;
|
|
14649
|
+
if (subType === 'linear') {
|
|
14650
|
+
response = await this.fapiPublicGetSymbolAdlRisk(this.extend(request, params));
|
|
14651
|
+
//
|
|
14652
|
+
// {
|
|
14653
|
+
// "symbol": "BTCUSDT",
|
|
14654
|
+
// "adlRisk": "LOW",
|
|
14655
|
+
// "updateTime": 1766827800453
|
|
14656
|
+
// }
|
|
14657
|
+
//
|
|
14658
|
+
}
|
|
14659
|
+
else {
|
|
14660
|
+
throw new errors.BadRequest(this.id + ' fetchADLRank() supports linear subTypes only');
|
|
14661
|
+
}
|
|
14662
|
+
return this.parseADLRank(response, market);
|
|
14663
|
+
}
|
|
14664
|
+
/**
|
|
14665
|
+
* @method
|
|
14666
|
+
* @name binance#fetchPositionsADLRank
|
|
14667
|
+
* @description fetches the auto deleveraging rank and risk percentage for a list of symbols that have open positions
|
|
14668
|
+
* @see https://developers.binance.com/docs/derivatives/usds-margined-futures/trade/rest-api/Position-ADL-Quantile-Estimation
|
|
14669
|
+
* @see https://developers.binance.com/docs/derivatives/coin-margined-futures/trade/rest-api/Position-ADL-Quantile-Estimation
|
|
14670
|
+
* @see https://developers.binance.com/docs/derivatives/portfolio-margin/trade/UM-Position-ADL-Quantile-Estimation
|
|
14671
|
+
* @see https://developers.binance.com/docs/derivatives/portfolio-margin/trade/CM-Position-ADL-Quantile-Estimation
|
|
14672
|
+
* @param {string[]} [symbols] list of unified market symbols
|
|
14673
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
14674
|
+
* @param {boolean} [params.portfolioMargin] set to true for the portfolio margin account
|
|
14675
|
+
* @returns {object[]} an array of [auto de leverage structure]{@link https://docs.ccxt.com/?id=auto-de-leverage-structure}
|
|
14676
|
+
*/
|
|
14677
|
+
async fetchPositionsADLRank(symbols = undefined, params = {}) {
|
|
14678
|
+
await this.loadMarkets();
|
|
14679
|
+
symbols = this.marketSymbols(symbols, undefined, true, true, true);
|
|
14680
|
+
const market = this.getMarketFromSymbols(symbols);
|
|
14681
|
+
let subType = undefined;
|
|
14682
|
+
[subType, params] = this.handleSubTypeAndParams('fetchPositionsADLRank', market, params);
|
|
14683
|
+
let isPortfolioMargin = undefined;
|
|
14684
|
+
[isPortfolioMargin, params] = this.handleOptionAndParams2(params, 'fetchPositionsADLRank', 'papi', 'portfolioMargin', false);
|
|
14685
|
+
let response = undefined;
|
|
14686
|
+
if (subType === 'linear') {
|
|
14687
|
+
if (isPortfolioMargin) {
|
|
14688
|
+
response = await this.papiGetUmAdlQuantile(params);
|
|
14689
|
+
}
|
|
14690
|
+
else {
|
|
14691
|
+
response = await this.fapiPrivateGetAdlQuantile(params);
|
|
14692
|
+
}
|
|
14693
|
+
}
|
|
14694
|
+
else if (subType === 'inverse') {
|
|
14695
|
+
if (isPortfolioMargin) {
|
|
14696
|
+
response = await this.papiGetCmAdlQuantile(params);
|
|
14697
|
+
}
|
|
14698
|
+
else {
|
|
14699
|
+
response = await this.dapiPrivateGetAdlQuantile(params);
|
|
14700
|
+
}
|
|
14701
|
+
}
|
|
14702
|
+
else {
|
|
14703
|
+
throw new errors.BadRequest(this.id + ' fetchPositionsADLRank() supports linear and inverse subTypes only');
|
|
14704
|
+
}
|
|
14705
|
+
//
|
|
14706
|
+
// [
|
|
14707
|
+
// {
|
|
14708
|
+
// "symbol": "BTCUSDT",
|
|
14709
|
+
// "adlQuantile": {
|
|
14710
|
+
// "LONG": 0,
|
|
14711
|
+
// "SHORT": 0,
|
|
14712
|
+
// "BOTH": 1
|
|
14713
|
+
// }
|
|
14714
|
+
// }
|
|
14715
|
+
// ]
|
|
14716
|
+
//
|
|
14717
|
+
return this.parseADLRanks(response, symbols);
|
|
14718
|
+
}
|
|
14719
|
+
parseADLRank(info, market = undefined) {
|
|
14720
|
+
//
|
|
14721
|
+
// fetchADLRank
|
|
14722
|
+
//
|
|
14723
|
+
// {
|
|
14724
|
+
// "symbol": "BTCUSDT",
|
|
14725
|
+
// "adlRisk": "LOW",
|
|
14726
|
+
// "updateTime": 1766827800453
|
|
14727
|
+
// }
|
|
14728
|
+
//
|
|
14729
|
+
// fetchPositionADLRank
|
|
14730
|
+
//
|
|
14731
|
+
// {
|
|
14732
|
+
// "symbol": "BTCUSDT",
|
|
14733
|
+
// "adlQuantile": {
|
|
14734
|
+
// "LONG": 0,
|
|
14735
|
+
// "SHORT": 0,
|
|
14736
|
+
// "BOTH": 1
|
|
14737
|
+
// }
|
|
14738
|
+
// }
|
|
14739
|
+
//
|
|
14740
|
+
const adlQuantile = this.safeDict(info, 'adlQuantile', {});
|
|
14741
|
+
const longNum = this.safeNumber(adlQuantile, 'LONG');
|
|
14742
|
+
const shortNum = this.safeNumber(adlQuantile, 'SHORT');
|
|
14743
|
+
const both = this.safeNumber(adlQuantile, 'BOTH');
|
|
14744
|
+
let rank = undefined;
|
|
14745
|
+
if (both !== undefined) {
|
|
14746
|
+
rank = both;
|
|
14747
|
+
}
|
|
14748
|
+
else {
|
|
14749
|
+
if (longNum !== undefined && shortNum !== undefined) {
|
|
14750
|
+
if (longNum > shortNum) {
|
|
14751
|
+
rank = longNum;
|
|
14752
|
+
}
|
|
14753
|
+
else {
|
|
14754
|
+
rank = shortNum;
|
|
14755
|
+
}
|
|
14756
|
+
}
|
|
14757
|
+
}
|
|
14758
|
+
const marketId = this.safeString(info, 'symbol');
|
|
14759
|
+
const timestamp = this.safeInteger2(info, 'timestamp', 'updateTime');
|
|
14760
|
+
return {
|
|
14761
|
+
'info': info,
|
|
14762
|
+
'symbol': this.safeSymbol(marketId, market, undefined, 'contract'),
|
|
14763
|
+
'rank': rank,
|
|
14764
|
+
'rating': this.safeStringLower(info, 'adlRisk'),
|
|
14765
|
+
'percentage': undefined,
|
|
14766
|
+
'timestamp': timestamp,
|
|
14767
|
+
'datetime': this.iso8601(timestamp),
|
|
14768
|
+
};
|
|
14769
|
+
}
|
|
14621
14770
|
}
|
|
14622
14771
|
|
|
14623
14772
|
exports["default"] = binance;
|