ccxt 4.5.39 → 4.5.41
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 +6 -5
- package/dist/ccxt.browser.min.js +18 -18
- package/dist/cjs/ccxt.js +6 -1
- package/dist/cjs/src/abstract/lighter.js +11 -0
- package/dist/cjs/src/ascendex.js +73 -1
- package/dist/cjs/src/base/Exchange.js +211 -22
- package/dist/cjs/src/base/functions/generic.js +1 -0
- package/dist/cjs/src/base/functions/io.js +160 -0
- package/dist/cjs/src/base/functions.js +6 -0
- package/dist/cjs/src/base/ws/Client.js +1 -0
- package/dist/cjs/src/base/ws/WsClient.js +1 -0
- package/dist/cjs/src/binance.js +143 -0
- package/dist/cjs/src/bingx.js +150 -123
- package/dist/cjs/src/bitmart.js +20 -6
- package/dist/cjs/src/bitmex.js +436 -0
- package/dist/cjs/src/blofin.js +86 -1
- package/dist/cjs/src/bybit.js +135 -0
- package/dist/cjs/src/coinspot.js +7 -2
- package/dist/cjs/src/delta.js +367 -0
- package/dist/cjs/src/gate.js +11 -4
- package/dist/cjs/src/gemini.js +76 -1
- package/dist/cjs/src/htx.js +266 -3
- package/dist/cjs/src/hyperliquid.js +20 -7
- package/dist/cjs/src/independentreserve.js +7 -7
- package/dist/cjs/src/kraken.js +1 -1
- package/dist/cjs/src/krakenfutures.js +96 -5
- package/dist/cjs/src/kucoin.js +3 -3
- package/dist/cjs/src/kucoinfutures.js +121 -0
- package/dist/cjs/src/lighter.js +2931 -0
- package/dist/cjs/src/mexc.js +9 -2
- package/dist/cjs/src/phemex.js +359 -0
- package/dist/cjs/src/poloniex.js +5 -0
- package/dist/cjs/src/pro/binance.js +2 -2
- package/dist/cjs/src/pro/bingx.js +248 -35
- package/dist/cjs/src/pro/bitget.js +49 -90
- package/dist/cjs/src/pro/bitmart.js +68 -0
- package/dist/cjs/src/pro/blofin.js +52 -1
- package/dist/cjs/src/pro/coinbaseinternational.js +5 -2
- package/dist/cjs/src/pro/defx.js +1 -1
- package/dist/cjs/src/pro/kucoinfutures.js +1 -1
- package/dist/cjs/src/pro/lighter.js +787 -0
- package/dist/cjs/src/pro/mexc.js +73 -1
- package/dist/cjs/src/pro/okx.js +7 -4
- package/dist/cjs/src/pro/paradex.js +138 -1
- package/dist/cjs/src/pro/woo.js +43 -0
- package/dist/cjs/src/static_dependencies/ethers/abi-coder.js +1 -0
- package/dist/cjs/src/static_dependencies/ethers/address/address.js +1 -0
- package/dist/cjs/src/static_dependencies/ethers/coders/abstract-coder.js +1 -0
- package/dist/cjs/src/static_dependencies/ethers/coders/address.js +1 -0
- package/dist/cjs/src/static_dependencies/ethers/coders/array.js +1 -0
- package/dist/cjs/src/static_dependencies/ethers/coders/bytes.js +1 -0
- package/dist/cjs/src/static_dependencies/ethers/coders/fixed-bytes.js +1 -0
- package/dist/cjs/src/static_dependencies/ethers/coders/number.js +1 -0
- package/dist/cjs/src/static_dependencies/ethers/fragments.js +1 -0
- package/dist/cjs/src/static_dependencies/ethers/index.js +1 -0
- package/dist/cjs/src/static_dependencies/ethers/interface.js +1 -0
- package/dist/cjs/src/static_dependencies/ethers/typed.js +1 -0
- package/dist/cjs/src/static_dependencies/ethers/utils/index.js +1 -0
- package/dist/cjs/src/whitebit.js +118 -16
- package/dist/cjs/src/woo.js +103 -3
- package/js/ccxt.d.ts +9 -3
- package/js/ccxt.js +6 -2
- package/js/src/abstract/gemini.d.ts +27 -0
- package/js/src/abstract/lighter.d.ts +53 -0
- package/js/src/abstract/lighter.js +5 -0
- package/js/src/ascendex.d.ts +12 -1
- package/js/src/ascendex.js +73 -1
- package/js/src/base/Exchange.d.ts +29 -14
- package/js/src/base/Exchange.js +216 -23
- package/js/src/base/functions/generic.js +1 -0
- package/js/src/base/functions/io.d.ts +32 -0
- package/js/src/base/functions/io.js +131 -0
- package/js/src/base/functions.d.ts +1 -0
- package/js/src/base/functions.js +1 -0
- package/js/src/base/types.d.ts +9 -0
- package/js/src/binance.d.ts +27 -1
- package/js/src/binance.js +143 -0
- package/js/src/bingx.d.ts +113 -108
- package/js/src/bingx.js +150 -123
- package/js/src/bitmart.js +20 -6
- package/js/src/bitmex.d.ts +50 -1
- package/js/src/bitmex.js +436 -0
- package/js/src/blofin.d.ts +12 -1
- package/js/src/blofin.js +86 -1
- package/js/src/bybit.d.ts +12 -1
- package/js/src/bybit.js +135 -0
- package/js/src/coinspot.js +7 -2
- package/js/src/delta.d.ts +12 -1
- package/js/src/delta.js +367 -0
- package/js/src/gate.d.ts +1 -0
- package/js/src/gate.js +11 -4
- package/js/src/gemini.d.ts +11 -0
- package/js/src/gemini.js +76 -1
- package/js/src/htx.d.ts +15 -1
- package/js/src/htx.js +266 -3
- package/js/src/hyperliquid.js +20 -7
- package/js/src/independentreserve.js +7 -7
- package/js/src/kraken.js +1 -1
- package/js/src/krakenfutures.d.ts +1 -1
- package/js/src/krakenfutures.js +96 -5
- package/js/src/kucoin.d.ts +3 -3
- package/js/src/kucoin.js +3 -3
- package/js/src/kucoinfutures.d.ts +12 -1
- package/js/src/kucoinfutures.js +121 -0
- package/js/src/lighter.d.ts +424 -0
- package/js/src/lighter.js +2924 -0
- package/js/src/mexc.js +9 -2
- 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.js +2 -2
- package/js/src/pro/bingx.d.ts +50 -34
- package/js/src/pro/bingx.js +249 -36
- package/js/src/pro/bitget.d.ts +6 -6
- package/js/src/pro/bitget.js +49 -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/coinbaseinternational.d.ts +2 -2
- package/js/src/pro/coinbaseinternational.js +6 -3
- package/js/src/pro/defx.js +1 -1
- package/js/src/pro/kucoinfutures.js +1 -1
- package/js/src/pro/lighter.d.ts +161 -0
- package/js/src/pro/lighter.js +780 -0
- package/js/src/pro/mexc.d.ts +22 -1
- package/js/src/pro/mexc.js +73 -1
- package/js/src/pro/okx.d.ts +4 -4
- package/js/src/pro/okx.js +7 -4
- package/js/src/pro/paradex.d.ts +23 -1
- package/js/src/pro/paradex.js +138 -1
- package/js/src/pro/woo.d.ts +12 -1
- package/js/src/pro/woo.js +43 -0
- package/js/src/whitebit.d.ts +2 -1
- package/js/src/whitebit.js +118 -16
- package/js/src/woo.d.ts +12 -1
- package/js/src/woo.js +103 -3
- package/package.json +1 -1
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var platform = require('./platform.js');
|
|
6
|
+
|
|
7
|
+
function _interopNamespace(e) {
|
|
8
|
+
if (e && e.__esModule) return e;
|
|
9
|
+
var n = Object.create(null);
|
|
10
|
+
if (e) {
|
|
11
|
+
Object.keys(e).forEach(function (k) {
|
|
12
|
+
if (k !== 'default') {
|
|
13
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
14
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
15
|
+
enumerable: true,
|
|
16
|
+
get: function () { return e[k]; }
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
n["default"] = e;
|
|
22
|
+
return Object.freeze(n);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/* ------------------------------------------------------------------------ */
|
|
26
|
+
/* ------------------------------------------------------------------------ */
|
|
27
|
+
let fsSyncModule = null;
|
|
28
|
+
let osSyncModule = null;
|
|
29
|
+
let pathSyncModule = null;
|
|
30
|
+
/* ------------------------------------------------------------------------ */
|
|
31
|
+
/**
|
|
32
|
+
* Initialize synchronous file system module (Node.js only)
|
|
33
|
+
* Uses dynamic import to prevent bundling in browser builds
|
|
34
|
+
*/
|
|
35
|
+
async function initFileSystem() {
|
|
36
|
+
if (platform.isNode) {
|
|
37
|
+
if (fsSyncModule === null) {
|
|
38
|
+
try {
|
|
39
|
+
// Dynamic import with webpackIgnore to prevent bundling
|
|
40
|
+
fsSyncModule = await Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require(/* webpackIgnore: true */ 'node:fs')); });
|
|
41
|
+
}
|
|
42
|
+
catch (e) { } // Silent fail in browser or if fs is unavailable
|
|
43
|
+
}
|
|
44
|
+
if (osSyncModule === null) {
|
|
45
|
+
try {
|
|
46
|
+
osSyncModule = await Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require(/* webpackIgnore: true */ 'node:os')); });
|
|
47
|
+
}
|
|
48
|
+
catch (e) { } // Silent fail in browser or if os is unavailable
|
|
49
|
+
}
|
|
50
|
+
if (pathSyncModule === null) {
|
|
51
|
+
try {
|
|
52
|
+
pathSyncModule = await Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require(/* webpackIgnore: true */ 'node:path')); });
|
|
53
|
+
}
|
|
54
|
+
catch (e) { } // Silent fail in browser or if path is unavailable
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
if (platform.isNode) {
|
|
59
|
+
// Pre-initialize synchronous fs module for sync methods
|
|
60
|
+
initFileSystem();
|
|
61
|
+
}
|
|
62
|
+
/* ------------------------------------------------------------------------ */
|
|
63
|
+
/**
|
|
64
|
+
* Get system temporary directory (Node.js only)
|
|
65
|
+
* @returns Temporary directory path with trailing slash, or undefined
|
|
66
|
+
*/
|
|
67
|
+
function getTempDir() {
|
|
68
|
+
if (!platform.isNode || osSyncModule === null) {
|
|
69
|
+
return undefined;
|
|
70
|
+
}
|
|
71
|
+
try {
|
|
72
|
+
const tmpDir = pathSyncModule.resolve(osSyncModule.tmpdir());
|
|
73
|
+
const sep = pathSyncModule ? pathSyncModule.sep : '/';
|
|
74
|
+
return tmpDir.endsWith(sep) ? tmpDir : tmpDir + sep;
|
|
75
|
+
}
|
|
76
|
+
catch (e) {
|
|
77
|
+
return undefined;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Check if file path is ccxt-cache file, so users are ensured there is no access possible to other files
|
|
82
|
+
* @param path File path to check
|
|
83
|
+
*/
|
|
84
|
+
function ensureWhitelistedFile(filePath) {
|
|
85
|
+
if (pathSyncModule === null) {
|
|
86
|
+
throw new Error('path module is not available');
|
|
87
|
+
}
|
|
88
|
+
const sanitizedFilePath = pathSyncModule.resolve(filePath);
|
|
89
|
+
if ((sanitizedFilePath.startsWith(filePath) && sanitizedFilePath.endsWith('.ccxtfile')) || sanitizedFilePath.endsWith('.wasm')) {
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
throw new Error('invalid file path: ' + filePath);
|
|
93
|
+
}
|
|
94
|
+
/* ------------------------------------------------------------------------ */
|
|
95
|
+
/**
|
|
96
|
+
* Read file contents synchronously (Node.js only)
|
|
97
|
+
* @param path File path to read
|
|
98
|
+
* @param encoding File encoding (default: 'utf8')
|
|
99
|
+
* @returns File contents as string, or undefined in browser
|
|
100
|
+
*/
|
|
101
|
+
function readFile(path, encoding = 'utf8') {
|
|
102
|
+
if (!platform.isNode || fsSyncModule === null) {
|
|
103
|
+
// Sync module not initialized yet
|
|
104
|
+
return undefined;
|
|
105
|
+
}
|
|
106
|
+
ensureWhitelistedFile(path);
|
|
107
|
+
try {
|
|
108
|
+
return fsSyncModule.readFileSync(path, encoding);
|
|
109
|
+
}
|
|
110
|
+
catch (e) {
|
|
111
|
+
return undefined;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
/* ------------------------------------------------------------------------ */
|
|
115
|
+
/**
|
|
116
|
+
* Write file contents synchronously (Node.js only)
|
|
117
|
+
* @param path File path to write
|
|
118
|
+
* @param data Data to write
|
|
119
|
+
* @param encoding File encoding (default: 'utf8')
|
|
120
|
+
*/
|
|
121
|
+
function writeFile(path, data, encoding = 'utf8') {
|
|
122
|
+
if (!platform.isNode || fsSyncModule === null) {
|
|
123
|
+
return false;
|
|
124
|
+
}
|
|
125
|
+
ensureWhitelistedFile(path);
|
|
126
|
+
try {
|
|
127
|
+
fsSyncModule.writeFileSync(path, data, encoding);
|
|
128
|
+
return true;
|
|
129
|
+
}
|
|
130
|
+
catch (e) {
|
|
131
|
+
// Silent fail
|
|
132
|
+
return false;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
/* ------------------------------------------------------------------------ */
|
|
136
|
+
/**
|
|
137
|
+
* Check if file exists synchronously (Node.js only)
|
|
138
|
+
* @param path File path to check
|
|
139
|
+
* @returns true if file exists, false otherwise
|
|
140
|
+
*/
|
|
141
|
+
function existsFile(path) {
|
|
142
|
+
if (!platform.isNode || fsSyncModule === null) {
|
|
143
|
+
// Sync module not initialized yet
|
|
144
|
+
return false;
|
|
145
|
+
}
|
|
146
|
+
ensureWhitelistedFile(path);
|
|
147
|
+
try {
|
|
148
|
+
fsSyncModule.accessSync(path);
|
|
149
|
+
return true;
|
|
150
|
+
}
|
|
151
|
+
catch (e) {
|
|
152
|
+
return false;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
exports.existsFile = existsFile;
|
|
157
|
+
exports.getTempDir = getTempDir;
|
|
158
|
+
exports.initFileSystem = initFileSystem;
|
|
159
|
+
exports.readFile = readFile;
|
|
160
|
+
exports.writeFile = writeFile;
|
|
@@ -12,6 +12,7 @@ var crypto = require('./functions/crypto.js');
|
|
|
12
12
|
var time = require('./functions/time.js');
|
|
13
13
|
var throttle = require('./functions/throttle.js');
|
|
14
14
|
var misc = require('./functions/misc.js');
|
|
15
|
+
var io = require('./functions/io.js');
|
|
15
16
|
|
|
16
17
|
/* ------------------------------------------------------------------------ */
|
|
17
18
|
/* ------------------------------------------------------------------------ */
|
|
@@ -159,3 +160,8 @@ exports.parseTimeframe = misc.parseTimeframe;
|
|
|
159
160
|
exports.roundTimeframe = misc.roundTimeframe;
|
|
160
161
|
exports.selfIsDefined = misc.selfIsDefined;
|
|
161
162
|
exports.vwap = misc.vwap;
|
|
163
|
+
exports.existsFile = io.existsFile;
|
|
164
|
+
exports.getTempDir = io.getTempDir;
|
|
165
|
+
exports.initFileSystem = io.initFileSystem;
|
|
166
|
+
exports.readFile = io.readFile;
|
|
167
|
+
exports.writeFile = io.writeFile;
|
|
@@ -10,6 +10,7 @@ var generic = require('../functions/generic.js');
|
|
|
10
10
|
var encode = require('../functions/encode.js');
|
|
11
11
|
require('../functions/crypto.js');
|
|
12
12
|
var time = require('../functions/time.js');
|
|
13
|
+
require('../functions/io.js');
|
|
13
14
|
var index = require('../../static_dependencies/scure-base/index.js');
|
|
14
15
|
|
|
15
16
|
class Client {
|
|
@@ -9,6 +9,7 @@ require('../functions/encode.js');
|
|
|
9
9
|
require('../functions/crypto.js');
|
|
10
10
|
var time = require('../functions/time.js');
|
|
11
11
|
var misc = require('../functions/misc.js');
|
|
12
|
+
require('../functions/io.js');
|
|
12
13
|
var Future = require('./Future.js');
|
|
13
14
|
|
|
14
15
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
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,
|
|
@@ -6413,6 +6416,7 @@ class binance extends binance$1["default"] {
|
|
|
6413
6416
|
* @param {string} [params.stopLossOrTakeProfit] 'stopLoss' or 'takeProfit', required for spot trailing orders
|
|
6414
6417
|
* @param {string} [params.positionSide] *swap and portfolio margin only* "BOTH" for one-way mode, "LONG" for buy side of hedged mode, "SHORT" for sell side of hedged mode
|
|
6415
6418
|
* @param {bool} [params.hedged] *swap and portfolio margin only* true for hedged mode, false for one way mode, default is false
|
|
6419
|
+
* @param {string} [params.clientOrderId] the clientOrderId of the order
|
|
6416
6420
|
* @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
|
|
6417
6421
|
*/
|
|
6418
6422
|
async createOrder(symbol, type, side, amount, price = undefined, params = {}) {
|
|
@@ -14625,6 +14629,145 @@ class binance extends binance$1["default"] {
|
|
|
14625
14629
|
'longShortRatio': this.safeNumber(info, 'longShortRatio'),
|
|
14626
14630
|
};
|
|
14627
14631
|
}
|
|
14632
|
+
/**
|
|
14633
|
+
* @method
|
|
14634
|
+
* @name binance#fetchADLRank
|
|
14635
|
+
* @description fetches the auto deleveraging rank and risk percentage for a symbol
|
|
14636
|
+
* @see https://developers.binance.com/docs/derivatives/usds-margined-futures/market-data/rest-api/ADL-Risk
|
|
14637
|
+
* @param {string} symbol unified symbol of the market to fetch the auto deleveraging rank for
|
|
14638
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
14639
|
+
* @returns {object} an [auto de leverage structure]{@link https://docs.ccxt.com/?id=auto-de-leverage-structure}
|
|
14640
|
+
*/
|
|
14641
|
+
async fetchADLRank(symbol, params = {}) {
|
|
14642
|
+
await this.loadMarkets();
|
|
14643
|
+
const market = this.market(symbol);
|
|
14644
|
+
const request = {
|
|
14645
|
+
'symbol': market['id'],
|
|
14646
|
+
};
|
|
14647
|
+
let subType = undefined;
|
|
14648
|
+
[subType, params] = this.handleSubTypeAndParams('fetchADLRank', market, params);
|
|
14649
|
+
let response = undefined;
|
|
14650
|
+
if (subType === 'linear') {
|
|
14651
|
+
response = await this.fapiPublicGetSymbolAdlRisk(this.extend(request, params));
|
|
14652
|
+
//
|
|
14653
|
+
// {
|
|
14654
|
+
// "symbol": "BTCUSDT",
|
|
14655
|
+
// "adlRisk": "LOW",
|
|
14656
|
+
// "updateTime": 1766827800453
|
|
14657
|
+
// }
|
|
14658
|
+
//
|
|
14659
|
+
}
|
|
14660
|
+
else {
|
|
14661
|
+
throw new errors.BadRequest(this.id + ' fetchADLRank() supports linear subTypes only');
|
|
14662
|
+
}
|
|
14663
|
+
return this.parseADLRank(response, market);
|
|
14664
|
+
}
|
|
14665
|
+
/**
|
|
14666
|
+
* @method
|
|
14667
|
+
* @name binance#fetchPositionsADLRank
|
|
14668
|
+
* @description fetches the auto deleveraging rank and risk percentage for a list of symbols that have open positions
|
|
14669
|
+
* @see https://developers.binance.com/docs/derivatives/usds-margined-futures/trade/rest-api/Position-ADL-Quantile-Estimation
|
|
14670
|
+
* @see https://developers.binance.com/docs/derivatives/coin-margined-futures/trade/rest-api/Position-ADL-Quantile-Estimation
|
|
14671
|
+
* @see https://developers.binance.com/docs/derivatives/portfolio-margin/trade/UM-Position-ADL-Quantile-Estimation
|
|
14672
|
+
* @see https://developers.binance.com/docs/derivatives/portfolio-margin/trade/CM-Position-ADL-Quantile-Estimation
|
|
14673
|
+
* @param {string[]} [symbols] list of unified market symbols
|
|
14674
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
14675
|
+
* @param {boolean} [params.portfolioMargin] set to true for the portfolio margin account
|
|
14676
|
+
* @returns {object[]} an array of [auto de leverage structure]{@link https://docs.ccxt.com/?id=auto-de-leverage-structure}
|
|
14677
|
+
*/
|
|
14678
|
+
async fetchPositionsADLRank(symbols = undefined, params = {}) {
|
|
14679
|
+
await this.loadMarkets();
|
|
14680
|
+
symbols = this.marketSymbols(symbols, undefined, true, true, true);
|
|
14681
|
+
const market = this.getMarketFromSymbols(symbols);
|
|
14682
|
+
let subType = undefined;
|
|
14683
|
+
[subType, params] = this.handleSubTypeAndParams('fetchPositionsADLRank', market, params);
|
|
14684
|
+
let isPortfolioMargin = undefined;
|
|
14685
|
+
[isPortfolioMargin, params] = this.handleOptionAndParams2(params, 'fetchPositionsADLRank', 'papi', 'portfolioMargin', false);
|
|
14686
|
+
let response = undefined;
|
|
14687
|
+
if (subType === 'linear') {
|
|
14688
|
+
if (isPortfolioMargin) {
|
|
14689
|
+
response = await this.papiGetUmAdlQuantile(params);
|
|
14690
|
+
}
|
|
14691
|
+
else {
|
|
14692
|
+
response = await this.fapiPrivateGetAdlQuantile(params);
|
|
14693
|
+
}
|
|
14694
|
+
}
|
|
14695
|
+
else if (subType === 'inverse') {
|
|
14696
|
+
if (isPortfolioMargin) {
|
|
14697
|
+
response = await this.papiGetCmAdlQuantile(params);
|
|
14698
|
+
}
|
|
14699
|
+
else {
|
|
14700
|
+
response = await this.dapiPrivateGetAdlQuantile(params);
|
|
14701
|
+
}
|
|
14702
|
+
}
|
|
14703
|
+
else {
|
|
14704
|
+
throw new errors.BadRequest(this.id + ' fetchPositionsADLRank() supports linear and inverse subTypes only');
|
|
14705
|
+
}
|
|
14706
|
+
//
|
|
14707
|
+
// [
|
|
14708
|
+
// {
|
|
14709
|
+
// "symbol": "BTCUSDT",
|
|
14710
|
+
// "adlQuantile": {
|
|
14711
|
+
// "LONG": 0,
|
|
14712
|
+
// "SHORT": 0,
|
|
14713
|
+
// "BOTH": 1
|
|
14714
|
+
// }
|
|
14715
|
+
// }
|
|
14716
|
+
// ]
|
|
14717
|
+
//
|
|
14718
|
+
return this.parseADLRanks(response, symbols);
|
|
14719
|
+
}
|
|
14720
|
+
parseADLRank(info, market = undefined) {
|
|
14721
|
+
//
|
|
14722
|
+
// fetchADLRank
|
|
14723
|
+
//
|
|
14724
|
+
// {
|
|
14725
|
+
// "symbol": "BTCUSDT",
|
|
14726
|
+
// "adlRisk": "LOW",
|
|
14727
|
+
// "updateTime": 1766827800453
|
|
14728
|
+
// }
|
|
14729
|
+
//
|
|
14730
|
+
// fetchPositionADLRank
|
|
14731
|
+
//
|
|
14732
|
+
// {
|
|
14733
|
+
// "symbol": "BTCUSDT",
|
|
14734
|
+
// "adlQuantile": {
|
|
14735
|
+
// "LONG": 0,
|
|
14736
|
+
// "SHORT": 0,
|
|
14737
|
+
// "BOTH": 1
|
|
14738
|
+
// }
|
|
14739
|
+
// }
|
|
14740
|
+
//
|
|
14741
|
+
const adlQuantile = this.safeDict(info, 'adlQuantile', {});
|
|
14742
|
+
const longNum = this.safeNumber(adlQuantile, 'LONG');
|
|
14743
|
+
const shortNum = this.safeNumber(adlQuantile, 'SHORT');
|
|
14744
|
+
const both = this.safeNumber(adlQuantile, 'BOTH');
|
|
14745
|
+
let rank = undefined;
|
|
14746
|
+
if (both !== undefined) {
|
|
14747
|
+
rank = both;
|
|
14748
|
+
}
|
|
14749
|
+
else {
|
|
14750
|
+
if (longNum !== undefined && shortNum !== undefined) {
|
|
14751
|
+
if (longNum > shortNum) {
|
|
14752
|
+
rank = longNum;
|
|
14753
|
+
}
|
|
14754
|
+
else {
|
|
14755
|
+
rank = shortNum;
|
|
14756
|
+
}
|
|
14757
|
+
}
|
|
14758
|
+
}
|
|
14759
|
+
const marketId = this.safeString(info, 'symbol');
|
|
14760
|
+
const timestamp = this.safeInteger2(info, 'timestamp', 'updateTime');
|
|
14761
|
+
return {
|
|
14762
|
+
'info': info,
|
|
14763
|
+
'symbol': this.safeSymbol(marketId, market, undefined, 'contract'),
|
|
14764
|
+
'rank': rank,
|
|
14765
|
+
'rating': this.safeStringLower(info, 'adlRisk'),
|
|
14766
|
+
'percentage': undefined,
|
|
14767
|
+
'timestamp': timestamp,
|
|
14768
|
+
'datetime': this.iso8601(timestamp),
|
|
14769
|
+
};
|
|
14770
|
+
}
|
|
14628
14771
|
}
|
|
14629
14772
|
|
|
14630
14773
|
exports["default"] = binance;
|