ccxt 4.3.98 → 4.4.2
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 +4 -4
- package/dist/ccxt.browser.min.js +3 -3
- package/dist/cjs/ccxt.js +1 -1
- package/dist/cjs/src/base/Exchange.js +69 -0
- package/dist/cjs/src/binance.js +78 -8
- package/dist/cjs/src/bitget.js +3 -2
- package/dist/cjs/src/cryptocom.js +1 -1
- package/dist/cjs/src/currencycom.js +1 -2
- package/dist/cjs/src/gate.js +1 -0
- package/dist/cjs/src/htx.js +1 -1
- package/dist/cjs/src/mexc.js +69 -1
- package/dist/cjs/src/pro/binance.js +3 -63
- package/dist/cjs/src/pro/bitget.js +1 -9
- package/dist/cjs/src/pro/bitmex.js +11 -1
- package/dist/cjs/src/pro/bybit.js +2 -54
- package/dist/cjs/src/pro/cryptocom.js +2 -40
- package/dist/cjs/src/pro/gate.js +1 -9
- package/dist/cjs/src/pro/hyperliquid.js +232 -11
- package/dist/cjs/src/pro/kucoin.js +2 -59
- package/dist/cjs/src/pro/kucoinfutures.js +139 -1
- package/dist/cjs/src/pro/okx.js +8 -36
- package/dist/cjs/src/xt.js +1 -1
- package/examples/js/cli.js +9 -5
- package/js/ccxt.d.ts +3 -3
- package/js/ccxt.js +1 -1
- package/js/src/base/Exchange.d.ts +2 -0
- package/js/src/base/Exchange.js +70 -1
- package/js/src/base/types.d.ts +5 -4
- package/js/src/binance.js +78 -8
- package/js/src/bitget.js +3 -2
- package/js/src/cryptocom.js +1 -1
- package/js/src/currencycom.js +1 -2
- package/js/src/gate.js +1 -0
- package/js/src/htx.js +1 -1
- package/js/src/mexc.js +69 -1
- package/js/src/pro/binance.d.ts +0 -1
- package/js/src/pro/binance.js +4 -64
- package/js/src/pro/bitget.js +1 -9
- package/js/src/pro/bitmex.js +11 -1
- package/js/src/pro/bybit.d.ts +1 -2
- package/js/src/pro/bybit.js +3 -55
- package/js/src/pro/cryptocom.d.ts +1 -2
- package/js/src/pro/cryptocom.js +3 -41
- package/js/src/pro/gate.js +2 -10
- package/js/src/pro/hyperliquid.d.ts +10 -1
- package/js/src/pro/hyperliquid.js +232 -11
- package/js/src/pro/kucoin.d.ts +0 -1
- package/js/src/pro/kucoin.js +3 -60
- package/js/src/pro/kucoinfutures.d.ts +7 -1
- package/js/src/pro/kucoinfutures.js +139 -1
- package/js/src/pro/okx.js +9 -37
- package/js/src/xt.js +1 -1
- package/package.json +1 -1
|
@@ -175,6 +175,27 @@ class kucoinfutures extends kucoinfutures$1 {
|
|
|
175
175
|
};
|
|
176
176
|
return await this.watchMultiple(url, messageHashes, this.extend(request, params), subscriptionHashes, subscriptionArgs);
|
|
177
177
|
}
|
|
178
|
+
async unSubscribeMultiple(url, messageHashes, topic, subscriptionHashes, params = {}, subscription = undefined) {
|
|
179
|
+
const requestId = this.requestId().toString();
|
|
180
|
+
const request = {
|
|
181
|
+
'id': requestId,
|
|
182
|
+
'type': 'unsubscribe',
|
|
183
|
+
'topic': topic,
|
|
184
|
+
'response': true,
|
|
185
|
+
};
|
|
186
|
+
const message = this.extend(request, params);
|
|
187
|
+
if (subscription !== undefined) {
|
|
188
|
+
subscription[requestId] = requestId;
|
|
189
|
+
}
|
|
190
|
+
const client = this.client(url);
|
|
191
|
+
for (let i = 0; i < subscriptionHashes.length; i++) {
|
|
192
|
+
const subscriptionHash = subscriptionHashes[i];
|
|
193
|
+
if (!(subscriptionHash in client.subscriptions)) {
|
|
194
|
+
client.subscriptions[requestId] = subscriptionHash;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
return await this.watchMultiple(url, messageHashes, message, subscriptionHashes, subscription);
|
|
198
|
+
}
|
|
178
199
|
async watchTicker(symbol, params = {}) {
|
|
179
200
|
/**
|
|
180
201
|
* @method
|
|
@@ -518,7 +539,7 @@ class kucoinfutures extends kucoinfutures$1 {
|
|
|
518
539
|
async watchTradesForSymbols(symbols, since = undefined, limit = undefined, params = {}) {
|
|
519
540
|
/**
|
|
520
541
|
* @method
|
|
521
|
-
* @name kucoinfutures#
|
|
542
|
+
* @name kucoinfutures#watchTradesForSymbols
|
|
522
543
|
* @description get the list of most recent trades for a particular symbol
|
|
523
544
|
* @param {string} symbol unified symbol of the market to fetch trades for
|
|
524
545
|
* @param {int} [since] timestamp in ms of the earliest trade to fetch
|
|
@@ -552,6 +573,49 @@ class kucoinfutures extends kucoinfutures$1 {
|
|
|
552
573
|
}
|
|
553
574
|
return this.filterBySinceLimit(trades, since, limit, 'timestamp', true);
|
|
554
575
|
}
|
|
576
|
+
async unWatchTrades(symbol, params = {}) {
|
|
577
|
+
/**
|
|
578
|
+
* @method
|
|
579
|
+
* @name kucoinfutures#unWatchTrades
|
|
580
|
+
* @description unWatches trades stream
|
|
581
|
+
* @see https://docs.kucoin.com/futures/#execution-data
|
|
582
|
+
* @param {string} symbol unified symbol of the market to fetch trades for
|
|
583
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
584
|
+
* @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=public-trades}
|
|
585
|
+
*/
|
|
586
|
+
return await this.unWatchTradesForSymbols([symbol], params);
|
|
587
|
+
}
|
|
588
|
+
async unWatchTradesForSymbols(symbols, params = {}) {
|
|
589
|
+
/**
|
|
590
|
+
* @method
|
|
591
|
+
* @name kucoinfutures#unWatchTradesForSymbols
|
|
592
|
+
* @description get the list of most recent trades for a particular symbol
|
|
593
|
+
* @param {string} symbol unified symbol of the market to fetch trades for
|
|
594
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
595
|
+
* @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=public-trades}
|
|
596
|
+
*/
|
|
597
|
+
await this.loadMarkets();
|
|
598
|
+
symbols = this.marketSymbols(symbols, undefined, false);
|
|
599
|
+
const url = await this.negotiate(false);
|
|
600
|
+
symbols = this.marketSymbols(symbols);
|
|
601
|
+
const marketIds = this.marketIds(symbols);
|
|
602
|
+
const topic = '/contractMarket/execution:' + marketIds.join(',');
|
|
603
|
+
const subscriptionHashes = [];
|
|
604
|
+
const messageHashes = [];
|
|
605
|
+
for (let i = 0; i < symbols.length; i++) {
|
|
606
|
+
const symbol = symbols[i];
|
|
607
|
+
messageHashes.push('unsubscribe:trades:' + symbol);
|
|
608
|
+
subscriptionHashes.push('trades:' + symbol);
|
|
609
|
+
}
|
|
610
|
+
const subscription = {
|
|
611
|
+
'messageHashes': messageHashes,
|
|
612
|
+
'subMessageHashes': subscriptionHashes,
|
|
613
|
+
'topic': 'trades',
|
|
614
|
+
'unsubscribe': true,
|
|
615
|
+
'symbols': symbols,
|
|
616
|
+
};
|
|
617
|
+
return await this.unSubscribeMultiple(url, messageHashes, topic, messageHashes, params, subscription);
|
|
618
|
+
}
|
|
555
619
|
handleTrade(client, message) {
|
|
556
620
|
//
|
|
557
621
|
// {
|
|
@@ -686,6 +750,7 @@ class kucoinfutures extends kucoinfutures$1 {
|
|
|
686
750
|
* @method
|
|
687
751
|
* @name kucoinfutures#watchOrderBookForSymbols
|
|
688
752
|
* @description watches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
|
|
753
|
+
* @see https://docs.kucoin.com/futures/#level-2-market-data
|
|
689
754
|
* @param {string[]} symbols unified array of symbols
|
|
690
755
|
* @param {int} [limit] the maximum amount of order book entries to return
|
|
691
756
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
@@ -719,6 +784,48 @@ class kucoinfutures extends kucoinfutures$1 {
|
|
|
719
784
|
const orderbook = await this.subscribeMultiple(url, messageHashes, topic, subscriptionHashes, subscriptionArgs, params);
|
|
720
785
|
return orderbook.limit();
|
|
721
786
|
}
|
|
787
|
+
async unWatchOrderBook(symbol, params = {}) {
|
|
788
|
+
/**
|
|
789
|
+
* @method
|
|
790
|
+
* @name kucoinfutures#unWatchOrderBook
|
|
791
|
+
* @description unWatches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
|
|
792
|
+
* @see https://docs.kucoin.com/futures/#level-2-market-data
|
|
793
|
+
* @param {string} symbol unified symbol of the market to fetch the order book for
|
|
794
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
795
|
+
* @returns {object} A dictionary of [order book structures]{@link https://docs.ccxt.com/#/?id=order-book-structure} indexed by market symbols
|
|
796
|
+
*/
|
|
797
|
+
return await this.unWatchOrderBookForSymbols([symbol], params);
|
|
798
|
+
}
|
|
799
|
+
async unWatchOrderBookForSymbols(symbols, params = {}) {
|
|
800
|
+
/**
|
|
801
|
+
* @method
|
|
802
|
+
* @name kucoinfutures#unWatchOrderBookForSymbols
|
|
803
|
+
* @description unWatches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
|
|
804
|
+
* @param {string[]} symbols unified array of symbols
|
|
805
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
806
|
+
* @returns {object} A dictionary of [order book structures]{@link https://docs.ccxt.com/#/?id=order-book-structure} indexed by market symbols
|
|
807
|
+
*/
|
|
808
|
+
await this.loadMarkets();
|
|
809
|
+
symbols = this.marketSymbols(symbols);
|
|
810
|
+
const marketIds = this.marketIds(symbols);
|
|
811
|
+
const url = await this.negotiate(false);
|
|
812
|
+
const topic = '/contractMarket/level2:' + marketIds.join(',');
|
|
813
|
+
const subscriptionHashes = [];
|
|
814
|
+
const messageHashes = [];
|
|
815
|
+
for (let i = 0; i < symbols.length; i++) {
|
|
816
|
+
const symbol = symbols[i];
|
|
817
|
+
messageHashes.push('unsubscribe:orderbook:' + symbol);
|
|
818
|
+
subscriptionHashes.push('orderbook:' + symbol);
|
|
819
|
+
}
|
|
820
|
+
const subscription = {
|
|
821
|
+
'messageHashes': messageHashes,
|
|
822
|
+
'symbols': symbols,
|
|
823
|
+
'unsubscribe': true,
|
|
824
|
+
'topic': 'orderbook',
|
|
825
|
+
'subMessageHashes': subscriptionHashes,
|
|
826
|
+
};
|
|
827
|
+
return await this.unSubscribeMultiple(url, messageHashes, topic, messageHashes, params, subscription);
|
|
828
|
+
}
|
|
722
829
|
handleDelta(orderbook, delta) {
|
|
723
830
|
orderbook['nonce'] = this.safeInteger(delta, 'sequence');
|
|
724
831
|
const timestamp = this.safeInteger(delta, 'timestamp');
|
|
@@ -1136,6 +1243,36 @@ class kucoinfutures extends kucoinfutures$1 {
|
|
|
1136
1243
|
}
|
|
1137
1244
|
this.handleErrors(undefined, undefined, client.url, undefined, undefined, data, message, undefined, undefined);
|
|
1138
1245
|
}
|
|
1246
|
+
handleSubscriptionStatus(client, message) {
|
|
1247
|
+
//
|
|
1248
|
+
// {
|
|
1249
|
+
// "id": "1578090438322",
|
|
1250
|
+
// "type": "ack"
|
|
1251
|
+
// }
|
|
1252
|
+
//
|
|
1253
|
+
const id = this.safeString(message, 'id');
|
|
1254
|
+
if (!(id in client.subscriptions)) {
|
|
1255
|
+
return;
|
|
1256
|
+
}
|
|
1257
|
+
const subscriptionHash = this.safeString(client.subscriptions, id);
|
|
1258
|
+
const subscription = this.safeValue(client.subscriptions, subscriptionHash);
|
|
1259
|
+
delete client.subscriptions[id];
|
|
1260
|
+
const method = this.safeValue(subscription, 'method');
|
|
1261
|
+
if (method !== undefined) {
|
|
1262
|
+
method.call(this, client, message, subscription);
|
|
1263
|
+
}
|
|
1264
|
+
const isUnSub = this.safeBool(subscription, 'unsubscribe', false);
|
|
1265
|
+
if (isUnSub) {
|
|
1266
|
+
const messageHashes = this.safeList(subscription, 'messageHashes', []);
|
|
1267
|
+
const subMessageHashes = this.safeList(subscription, 'subMessageHashes', []);
|
|
1268
|
+
for (let i = 0; i < messageHashes.length; i++) {
|
|
1269
|
+
const messageHash = messageHashes[i];
|
|
1270
|
+
const subHash = subMessageHashes[i];
|
|
1271
|
+
this.cleanUnsubscription(client, subHash, messageHash);
|
|
1272
|
+
}
|
|
1273
|
+
this.cleanCache(subscription);
|
|
1274
|
+
}
|
|
1275
|
+
}
|
|
1139
1276
|
handleMessage(client, message) {
|
|
1140
1277
|
const type = this.safeString(message, 'type');
|
|
1141
1278
|
const methods = {
|
|
@@ -1144,6 +1281,7 @@ class kucoinfutures extends kucoinfutures$1 {
|
|
|
1144
1281
|
'message': this.handleSubject,
|
|
1145
1282
|
'pong': this.handlePong,
|
|
1146
1283
|
'error': this.handleErrorMessage,
|
|
1284
|
+
'ack': this.handleSubscriptionStatus,
|
|
1147
1285
|
};
|
|
1148
1286
|
const method = this.safeValue(methods, type);
|
|
1149
1287
|
if (method !== undefined) {
|
package/dist/cjs/src/pro/okx.js
CHANGED
|
@@ -2331,64 +2331,36 @@ class okx extends okx$1 {
|
|
|
2331
2331
|
handleUnSubscriptionTrades(client, symbol) {
|
|
2332
2332
|
const subMessageHash = 'trades:' + symbol;
|
|
2333
2333
|
const messageHash = 'unsubscribe:trades:' + symbol;
|
|
2334
|
-
|
|
2335
|
-
|
|
2334
|
+
this.cleanUnsubscription(client, subMessageHash, messageHash);
|
|
2335
|
+
if (symbol in this.trades) {
|
|
2336
|
+
delete this.trades[symbol];
|
|
2336
2337
|
}
|
|
2337
|
-
if (messageHash in client.subscriptions) {
|
|
2338
|
-
delete client.subscriptions[messageHash];
|
|
2339
|
-
}
|
|
2340
|
-
delete this.trades[symbol];
|
|
2341
|
-
const error = new errors.UnsubscribeError(this.id + ' ' + subMessageHash);
|
|
2342
|
-
client.reject(error, subMessageHash);
|
|
2343
|
-
client.resolve(true, messageHash);
|
|
2344
2338
|
}
|
|
2345
2339
|
handleUnsubscriptionOrderBook(client, symbol, channel) {
|
|
2346
2340
|
const subMessageHash = channel + ':' + symbol;
|
|
2347
2341
|
const messageHash = 'unsubscribe:orderbook:' + symbol;
|
|
2348
|
-
|
|
2349
|
-
|
|
2350
|
-
|
|
2351
|
-
if (messageHash in client.subscriptions) {
|
|
2352
|
-
delete client.subscriptions[messageHash];
|
|
2342
|
+
this.cleanUnsubscription(client, subMessageHash, messageHash);
|
|
2343
|
+
if (symbol in this.orderbooks) {
|
|
2344
|
+
delete this.orderbooks[symbol];
|
|
2353
2345
|
}
|
|
2354
|
-
delete this.orderbooks[symbol];
|
|
2355
|
-
const error = new errors.UnsubscribeError(this.id + ' ' + subMessageHash);
|
|
2356
|
-
client.reject(error, subMessageHash);
|
|
2357
|
-
client.resolve(true, messageHash);
|
|
2358
2346
|
}
|
|
2359
2347
|
handleUnsubscriptionOHLCV(client, symbol, channel) {
|
|
2360
2348
|
const tf = channel.replace('candle', '');
|
|
2361
2349
|
const timeframe = this.findTimeframe(tf);
|
|
2362
2350
|
const subMessageHash = 'multi:' + channel + ':' + symbol;
|
|
2363
2351
|
const messageHash = 'unsubscribe:' + subMessageHash;
|
|
2364
|
-
|
|
2365
|
-
delete client.subscriptions[subMessageHash];
|
|
2366
|
-
}
|
|
2367
|
-
if (messageHash in client.subscriptions) {
|
|
2368
|
-
delete client.subscriptions[messageHash];
|
|
2369
|
-
}
|
|
2352
|
+
this.cleanUnsubscription(client, subMessageHash, messageHash);
|
|
2370
2353
|
if (timeframe in this.ohlcvs[symbol]) {
|
|
2371
2354
|
delete this.ohlcvs[symbol][timeframe];
|
|
2372
2355
|
}
|
|
2373
|
-
const error = new errors.UnsubscribeError(this.id + ' ' + subMessageHash);
|
|
2374
|
-
client.reject(error, subMessageHash);
|
|
2375
|
-
client.resolve(true, messageHash);
|
|
2376
2356
|
}
|
|
2377
2357
|
handleUnsubscriptionTicker(client, symbol, channel) {
|
|
2378
2358
|
const subMessageHash = channel + '::' + symbol;
|
|
2379
2359
|
const messageHash = 'unsubscribe:ticker:' + symbol;
|
|
2380
|
-
|
|
2381
|
-
delete client.subscriptions[subMessageHash];
|
|
2382
|
-
}
|
|
2383
|
-
if (messageHash in client.subscriptions) {
|
|
2384
|
-
delete client.subscriptions[messageHash];
|
|
2385
|
-
}
|
|
2360
|
+
this.cleanUnsubscription(client, subMessageHash, messageHash);
|
|
2386
2361
|
if (symbol in this.tickers) {
|
|
2387
2362
|
delete this.tickers[symbol];
|
|
2388
2363
|
}
|
|
2389
|
-
const error = new errors.UnsubscribeError(this.id + ' ' + subMessageHash);
|
|
2390
|
-
client.reject(error, subMessageHash);
|
|
2391
|
-
client.resolve(true, messageHash);
|
|
2392
2364
|
}
|
|
2393
2365
|
handleUnsubscription(client, message) {
|
|
2394
2366
|
//
|
package/dist/cjs/src/xt.js
CHANGED
|
@@ -1372,7 +1372,7 @@ class xt extends xt$1 {
|
|
|
1372
1372
|
this.safeNumber(ohlcv, 'h'),
|
|
1373
1373
|
this.safeNumber(ohlcv, 'l'),
|
|
1374
1374
|
this.safeNumber(ohlcv, 'c'),
|
|
1375
|
-
this.safeNumber2(ohlcv,
|
|
1375
|
+
this.safeNumber2(ohlcv, 'q', volumeIndex),
|
|
1376
1376
|
];
|
|
1377
1377
|
}
|
|
1378
1378
|
async fetchOrderBook(symbol, limit = undefined, params = {}) {
|
package/examples/js/cli.js
CHANGED
|
@@ -11,6 +11,10 @@ const fsPromises = fs.promises;
|
|
|
11
11
|
ansi.nice
|
|
12
12
|
const log = ololog.configure ({ locate: false }).unlimited
|
|
13
13
|
const { ExchangeError , NetworkError} = ccxt
|
|
14
|
+
|
|
15
|
+
function jsonStringify (obj, indent = undefined) {
|
|
16
|
+
return JSON.stringify (obj, function(k, v) { return v === undefined ? null : v; }, indent);
|
|
17
|
+
}
|
|
14
18
|
//-----------------------------------------------------------------------------
|
|
15
19
|
|
|
16
20
|
let [processPath, , exchangeId, methodName, ... params] = process.argv.filter (x => !x.startsWith ('--'))
|
|
@@ -164,7 +168,7 @@ function createResponseTemplate(exchange, methodName, args, result) {
|
|
|
164
168
|
}
|
|
165
169
|
log('Report: (paste inside static/response/' + exchange.id + '.json ->' + methodName + ')')
|
|
166
170
|
log.green('-------------------------------------------')
|
|
167
|
-
log (
|
|
171
|
+
log (jsonStringify (final, 2))
|
|
168
172
|
log.green('-------------------------------------------')
|
|
169
173
|
}
|
|
170
174
|
|
|
@@ -206,7 +210,7 @@ function printUsage () {
|
|
|
206
210
|
|
|
207
211
|
const printHumanReadable = (exchange, result) => {
|
|
208
212
|
if (raw) {
|
|
209
|
-
return log (
|
|
213
|
+
return log (jsonStringify (result))
|
|
210
214
|
}
|
|
211
215
|
if (!no_table && Array.isArray (result) || table) {
|
|
212
216
|
result = Object.values (result)
|
|
@@ -227,7 +231,7 @@ const printHumanReadable = (exchange, result) => {
|
|
|
227
231
|
dash: '-'.lightGray.dim,
|
|
228
232
|
print: x => {
|
|
229
233
|
if (typeof x === 'object') {
|
|
230
|
-
const j =
|
|
234
|
+
const j = jsonStringify (x).trim ()
|
|
231
235
|
if (j.length < 100) return j
|
|
232
236
|
}
|
|
233
237
|
return String (x)
|
|
@@ -302,7 +306,7 @@ async function run () {
|
|
|
302
306
|
} catch {
|
|
303
307
|
await exchange.loadMarkets ()
|
|
304
308
|
if (cache_markets) {
|
|
305
|
-
await fsPromises.writeFile (path,
|
|
309
|
+
await fsPromises.writeFile (path, jsonStringify (exchange.markets))
|
|
306
310
|
}
|
|
307
311
|
}
|
|
308
312
|
}
|
|
@@ -351,7 +355,7 @@ async function run () {
|
|
|
351
355
|
if (!isWsMethod && !raw) {
|
|
352
356
|
log (exchange.iso8601 (end), 'iteration', i++, 'passed in', end - start, 'ms\n')
|
|
353
357
|
}
|
|
354
|
-
printHumanReadable (exchange,
|
|
358
|
+
printHumanReadable (exchange, result)
|
|
355
359
|
if (!isWsMethod && !raw) {
|
|
356
360
|
log (exchange.iso8601 (end), 'iteration', i, 'passed in', end - start, 'ms\n')
|
|
357
361
|
}
|
package/js/ccxt.d.ts
CHANGED
|
@@ -2,9 +2,9 @@ import { Exchange } from './src/base/Exchange.js';
|
|
|
2
2
|
import { Precise } from './src/base/Precise.js';
|
|
3
3
|
import * as functions from './src/base/functions.js';
|
|
4
4
|
import * as errors from './src/base/errors.js';
|
|
5
|
-
import type { Int, int, Str, Strings, Num, Bool, IndexType, OrderSide, OrderType, MarketType, SubType, Dict, NullableDict, List, NullableList, Fee, OHLCV, OHLCVC, implicitReturnType, Market, Currency, Dictionary, MinMax, FeeInterface, TradingFeeInterface, MarketInterface, Trade, Order, OrderBook, Ticker, Transaction, Tickers, CurrencyInterface, Balance, BalanceAccount, Account, PartialBalances, Balances, DepositAddress, WithdrawalResponse, DepositAddressResponse, FundingRate, FundingRates, Position, BorrowInterest, LeverageTier, LedgerEntry, DepositWithdrawFeeNetwork, DepositWithdrawFee, TransferEntry, CrossBorrowRate, IsolatedBorrowRate, FundingRateHistory, OpenInterest, Liquidation, OrderRequest, CancellationRequest, FundingHistory, MarginMode, Greeks, Conversion, Option, LastPrice, Leverage, MarginModification, Leverages, LastPrices, Currencies, TradingFees, MarginModes, OptionChain, IsolatedBorrowRates, CrossBorrowRates, LeverageTiers } from './src/base/types.js';
|
|
5
|
+
import type { Int, int, Str, Strings, Num, Bool, IndexType, OrderSide, OrderType, MarketType, SubType, Dict, NullableDict, List, NullableList, Fee, OHLCV, OHLCVC, implicitReturnType, Market, Currency, Dictionary, MinMax, FeeInterface, TradingFeeInterface, MarketInterface, Trade, Order, OrderBook, Ticker, Transaction, Tickers, CurrencyInterface, Balance, BalanceAccount, Account, PartialBalances, Balances, DepositAddress, WithdrawalResponse, DepositAddressResponse, FundingRate, FundingRates, Position, BorrowInterest, LeverageTier, LedgerEntry, DepositWithdrawFeeNetwork, DepositWithdrawFee, TransferEntry, CrossBorrowRate, IsolatedBorrowRate, FundingRateHistory, OpenInterest, Liquidation, OrderRequest, CancellationRequest, FundingHistory, MarketMarginModes, MarginMode, Greeks, Conversion, Option, LastPrice, Leverage, MarginModification, Leverages, LastPrices, Currencies, TradingFees, MarginModes, OptionChain, IsolatedBorrowRates, CrossBorrowRates, LeverageTiers } from './src/base/types.js';
|
|
6
6
|
import { BaseError, ExchangeError, AuthenticationError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, OperationRejected, NoChange, MarginModeAlreadySet, MarketClosed, ManualInteractionNeeded, InsufficientFunds, InvalidAddress, AddressPending, InvalidOrder, OrderNotFound, OrderNotCached, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, ContractUnavailable, NotSupported, InvalidProxySettings, ExchangeClosedByUser, OperationFailed, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, ChecksumError, RequestTimeout, BadResponse, NullResponse, CancelPending, UnsubscribeError } from './src/base/errors.js';
|
|
7
|
-
declare const version = "4.
|
|
7
|
+
declare const version = "4.4.1";
|
|
8
8
|
import ace from './src/ace.js';
|
|
9
9
|
import alpaca from './src/alpaca.js';
|
|
10
10
|
import ascendex from './src/ascendex.js';
|
|
@@ -555,5 +555,5 @@ declare const ccxt: {
|
|
|
555
555
|
zaif: typeof zaif;
|
|
556
556
|
zonda: typeof zonda;
|
|
557
557
|
} & typeof functions & typeof errors;
|
|
558
|
-
export { version, Exchange, exchanges, pro, Precise, functions, errors, BaseError, ExchangeError, AuthenticationError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, OperationRejected, NoChange, MarginModeAlreadySet, MarketClosed, ManualInteractionNeeded, InsufficientFunds, InvalidAddress, AddressPending, InvalidOrder, OrderNotFound, OrderNotCached, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, ContractUnavailable, NotSupported, InvalidProxySettings, ExchangeClosedByUser, OperationFailed, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, ChecksumError, RequestTimeout, BadResponse, NullResponse, CancelPending, UnsubscribeError, Int, int, Str, Strings, Num, Bool, IndexType, OrderSide, OrderType, MarketType, SubType, Dict, NullableDict, List, NullableList, Fee, OHLCV, OHLCVC, implicitReturnType, Market, Currency, Dictionary, MinMax, FeeInterface, TradingFeeInterface, MarketInterface, Trade, Order, OrderBook, Ticker, Transaction, Tickers, CurrencyInterface, Balance, BalanceAccount, Account, PartialBalances, Balances, DepositAddress, WithdrawalResponse, DepositAddressResponse, FundingRate, FundingRates, Position, BorrowInterest, LeverageTier, LedgerEntry, DepositWithdrawFeeNetwork, DepositWithdrawFee, TransferEntry, CrossBorrowRate, IsolatedBorrowRate, FundingRateHistory, OpenInterest, Liquidation, OrderRequest, CancellationRequest, FundingHistory, MarginMode, Greeks, Conversion, Option, LastPrice, Leverage, MarginModification, Leverages, LastPrices, Currencies, TradingFees, MarginModes, OptionChain, IsolatedBorrowRates, CrossBorrowRates, LeverageTiers, ace, alpaca, ascendex, bequant, bigone, binance, binancecoinm, binanceus, binanceusdm, bingx, bit2c, bitbank, bitbns, bitcoincom, bitfinex, bitfinex2, bitflyer, bitget, bithumb, bitmart, bitmex, bitopro, bitpanda, bitrue, bitso, bitstamp, bitteam, bitvavo, bl3p, blockchaincom, blofin, btcalpha, btcbox, btcmarkets, btcturk, bybit, cex, coinbase, coinbaseadvanced, coinbaseexchange, coinbaseinternational, coincheck, coinex, coinlist, coinmate, coinmetro, coinone, coinsph, coinspot, cryptocom, currencycom, delta, deribit, digifinex, exmo, fmfwio, gate, gateio, gemini, hashkey, hitbtc, hollaex, htx, huobi, huobijp, hyperliquid, idex, independentreserve, indodax, kraken, krakenfutures, kucoin, kucoinfutures, kuna, latoken, lbank, luno, lykke, mercado, mexc, ndax, novadax, oceanex, okcoin, okx, onetrading, oxfun, p2b, paradex, paymium, phemex, poloniex, poloniexfutures, probit, timex, tokocrypto, tradeogre, upbit, vertex, wavesexchange, wazirx, whitebit, woo, woofipro, xt, yobit, zaif, zonda, };
|
|
558
|
+
export { version, Exchange, exchanges, pro, Precise, functions, errors, BaseError, ExchangeError, AuthenticationError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, OperationRejected, NoChange, MarginModeAlreadySet, MarketClosed, ManualInteractionNeeded, InsufficientFunds, InvalidAddress, AddressPending, InvalidOrder, OrderNotFound, OrderNotCached, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, ContractUnavailable, NotSupported, InvalidProxySettings, ExchangeClosedByUser, OperationFailed, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, ChecksumError, RequestTimeout, BadResponse, NullResponse, CancelPending, UnsubscribeError, Int, int, Str, Strings, Num, Bool, IndexType, OrderSide, OrderType, MarketType, SubType, Dict, NullableDict, List, NullableList, Fee, OHLCV, OHLCVC, implicitReturnType, Market, Currency, Dictionary, MinMax, FeeInterface, TradingFeeInterface, MarketMarginModes, MarketInterface, Trade, Order, OrderBook, Ticker, Transaction, Tickers, CurrencyInterface, Balance, BalanceAccount, Account, PartialBalances, Balances, DepositAddress, WithdrawalResponse, DepositAddressResponse, FundingRate, FundingRates, Position, BorrowInterest, LeverageTier, LedgerEntry, DepositWithdrawFeeNetwork, DepositWithdrawFee, TransferEntry, CrossBorrowRate, IsolatedBorrowRate, FundingRateHistory, OpenInterest, Liquidation, OrderRequest, CancellationRequest, FundingHistory, MarginMode, Greeks, Conversion, Option, LastPrice, Leverage, MarginModification, Leverages, LastPrices, Currencies, TradingFees, MarginModes, OptionChain, IsolatedBorrowRates, CrossBorrowRates, LeverageTiers, ace, alpaca, ascendex, bequant, bigone, binance, binancecoinm, binanceus, binanceusdm, bingx, bit2c, bitbank, bitbns, bitcoincom, bitfinex, bitfinex2, bitflyer, bitget, bithumb, bitmart, bitmex, bitopro, bitpanda, bitrue, bitso, bitstamp, bitteam, bitvavo, bl3p, blockchaincom, blofin, btcalpha, btcbox, btcmarkets, btcturk, bybit, cex, coinbase, coinbaseadvanced, coinbaseexchange, coinbaseinternational, coincheck, coinex, coinlist, coinmate, coinmetro, coinone, coinsph, coinspot, cryptocom, currencycom, delta, deribit, digifinex, exmo, fmfwio, gate, gateio, gemini, hashkey, hitbtc, hollaex, htx, huobi, huobijp, hyperliquid, idex, independentreserve, indodax, kraken, krakenfutures, kucoin, kucoinfutures, kuna, latoken, lbank, luno, lykke, mercado, mexc, ndax, novadax, oceanex, okcoin, okx, onetrading, oxfun, p2b, paradex, paymium, phemex, poloniex, poloniexfutures, probit, timex, tokocrypto, tradeogre, upbit, vertex, wavesexchange, wazirx, whitebit, woo, woofipro, xt, yobit, zaif, zonda, };
|
|
559
559
|
export default ccxt;
|
package/js/ccxt.js
CHANGED
|
@@ -38,7 +38,7 @@ import * as errors from './src/base/errors.js';
|
|
|
38
38
|
import { BaseError, ExchangeError, AuthenticationError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, OperationRejected, NoChange, MarginModeAlreadySet, MarketClosed, ManualInteractionNeeded, InsufficientFunds, InvalidAddress, AddressPending, InvalidOrder, OrderNotFound, OrderNotCached, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, ContractUnavailable, NotSupported, InvalidProxySettings, ExchangeClosedByUser, OperationFailed, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, ChecksumError, RequestTimeout, BadResponse, NullResponse, CancelPending, UnsubscribeError } from './src/base/errors.js';
|
|
39
39
|
//-----------------------------------------------------------------------------
|
|
40
40
|
// this is updated by vss.js when building
|
|
41
|
-
const version = '4.
|
|
41
|
+
const version = '4.4.2';
|
|
42
42
|
Exchange.ccxtVersion = version;
|
|
43
43
|
//-----------------------------------------------------------------------------
|
|
44
44
|
import ace from './src/ace.js';
|
|
@@ -1147,5 +1147,7 @@ export default class Exchange {
|
|
|
1147
1147
|
parseMarginModifications(response: object[], symbols?: Strings, symbolKey?: Str, marketType?: MarketType): MarginModification[];
|
|
1148
1148
|
fetchTransfer(id: string, code?: Str, params?: {}): Promise<TransferEntry>;
|
|
1149
1149
|
fetchTransfers(code?: Str, since?: Int, limit?: Int, params?: {}): Promise<TransferEntry[]>;
|
|
1150
|
+
cleanUnsubscription(client: any, subHash: string, unsubHash: string): void;
|
|
1151
|
+
cleanCache(subscription: Dict): void;
|
|
1150
1152
|
}
|
|
1151
1153
|
export { Exchange, };
|
package/js/src/base/Exchange.js
CHANGED
|
@@ -11,7 +11,7 @@ const { isNode, deepExtend, extend, clone, flatten, unique, indexBy, sortBy, sor
|
|
|
11
11
|
import { keys as keysFunc, values as valuesFunc, vwap as vwapFunc } from './functions.js';
|
|
12
12
|
// import exceptions from "./errors.js"
|
|
13
13
|
import { // eslint-disable-line object-curly-newline
|
|
14
|
-
ExchangeError, BadSymbol, NullResponse, InvalidAddress, InvalidOrder, NotSupported, BadResponse, AuthenticationError, DDoSProtection, RequestTimeout, NetworkError, InvalidProxySettings, ExchangeNotAvailable, ArgumentsRequired, RateLimitExceeded, BadRequest, ExchangeClosedByUser } from "./errors.js";
|
|
14
|
+
ExchangeError, BadSymbol, NullResponse, InvalidAddress, InvalidOrder, NotSupported, BadResponse, AuthenticationError, DDoSProtection, RequestTimeout, NetworkError, InvalidProxySettings, ExchangeNotAvailable, ArgumentsRequired, RateLimitExceeded, BadRequest, ExchangeClosedByUser, UnsubscribeError } from "./errors.js";
|
|
15
15
|
import { Precise } from './Precise.js';
|
|
16
16
|
//-----------------------------------------------------------------------------
|
|
17
17
|
import WsClient from './ws/WsClient.js';
|
|
@@ -2381,6 +2381,10 @@ export default class Exchange {
|
|
|
2381
2381
|
'max': undefined,
|
|
2382
2382
|
},
|
|
2383
2383
|
},
|
|
2384
|
+
'marginModes': {
|
|
2385
|
+
'cross': undefined,
|
|
2386
|
+
'isolated': undefined,
|
|
2387
|
+
},
|
|
2384
2388
|
'created': undefined,
|
|
2385
2389
|
'info': undefined,
|
|
2386
2390
|
};
|
|
@@ -6487,5 +6491,70 @@ export default class Exchange {
|
|
|
6487
6491
|
*/
|
|
6488
6492
|
throw new NotSupported(this.id + ' fetchTransfers () is not supported yet');
|
|
6489
6493
|
}
|
|
6494
|
+
cleanUnsubscription(client, subHash, unsubHash) {
|
|
6495
|
+
if (unsubHash in client.subscriptions) {
|
|
6496
|
+
delete client.subscriptions[unsubHash];
|
|
6497
|
+
}
|
|
6498
|
+
if (subHash in client.subscriptions) {
|
|
6499
|
+
delete client.subscriptions[subHash];
|
|
6500
|
+
}
|
|
6501
|
+
if (subHash in client.futures) {
|
|
6502
|
+
const error = new UnsubscribeError(this.id + ' ' + subHash);
|
|
6503
|
+
client.reject(error, subHash);
|
|
6504
|
+
}
|
|
6505
|
+
client.resolve(true, unsubHash);
|
|
6506
|
+
}
|
|
6507
|
+
cleanCache(subscription) {
|
|
6508
|
+
const topic = this.safeString(subscription, 'topic');
|
|
6509
|
+
const symbols = this.safeList(subscription, 'symbols', []);
|
|
6510
|
+
const symbolsLength = symbols.length;
|
|
6511
|
+
if (topic === 'ohlcv') {
|
|
6512
|
+
const symbolsAndTimeFrames = this.safeList(subscription, 'symbolsAndTimeframes', []);
|
|
6513
|
+
for (let i = 0; i < symbolsAndTimeFrames.length; i++) {
|
|
6514
|
+
const symbolAndTimeFrame = symbolsAndTimeFrames[i];
|
|
6515
|
+
const symbol = this.safeString(symbolAndTimeFrame, 0);
|
|
6516
|
+
const timeframe = this.safeString(symbolAndTimeFrame, 1);
|
|
6517
|
+
if (timeframe in this.ohlcvs[symbol]) {
|
|
6518
|
+
delete this.ohlcvs[symbol][timeframe];
|
|
6519
|
+
}
|
|
6520
|
+
}
|
|
6521
|
+
}
|
|
6522
|
+
else if (symbolsLength > 0) {
|
|
6523
|
+
for (let i = 0; i < symbols.length; i++) {
|
|
6524
|
+
const symbol = symbols[i];
|
|
6525
|
+
if (topic === 'trades') {
|
|
6526
|
+
delete this.trades[symbol];
|
|
6527
|
+
}
|
|
6528
|
+
else if (topic === 'orderbook') {
|
|
6529
|
+
delete this.orderbooks[symbol];
|
|
6530
|
+
}
|
|
6531
|
+
else if (topic === 'ticker') {
|
|
6532
|
+
delete this.tickers[symbol];
|
|
6533
|
+
}
|
|
6534
|
+
}
|
|
6535
|
+
}
|
|
6536
|
+
else {
|
|
6537
|
+
if (topic === 'myTrades') {
|
|
6538
|
+
// don't reset this.myTrades directly here
|
|
6539
|
+
// because in c# we need to use a different object
|
|
6540
|
+
const keys = Object.keys(this.myTrades);
|
|
6541
|
+
for (let i = 0; i < keys.length; i++) {
|
|
6542
|
+
delete this.myTrades[keys[i]];
|
|
6543
|
+
}
|
|
6544
|
+
}
|
|
6545
|
+
else if (topic === 'orders') {
|
|
6546
|
+
const orderSymbols = Object.keys(this.orders);
|
|
6547
|
+
for (let i = 0; i < orderSymbols.length; i++) {
|
|
6548
|
+
delete this.orders[orderSymbols[i]];
|
|
6549
|
+
}
|
|
6550
|
+
}
|
|
6551
|
+
else if (topic === 'ticker') {
|
|
6552
|
+
const tickerSymbols = Object.keys(this.tickers);
|
|
6553
|
+
for (let i = 0; i < tickerSymbols.length; i++) {
|
|
6554
|
+
delete this.tickers[tickerSymbols[i]];
|
|
6555
|
+
}
|
|
6556
|
+
}
|
|
6557
|
+
}
|
|
6558
|
+
}
|
|
6490
6559
|
}
|
|
6491
6560
|
export { Exchange, };
|
package/js/src/base/types.d.ts
CHANGED
|
@@ -35,6 +35,10 @@ export interface TradingFeeInterface {
|
|
|
35
35
|
tierBased: Bool;
|
|
36
36
|
}
|
|
37
37
|
export declare type Fee = FeeInterface | undefined;
|
|
38
|
+
export interface MarketMarginModes {
|
|
39
|
+
isolated: boolean;
|
|
40
|
+
cross: boolean;
|
|
41
|
+
}
|
|
38
42
|
export interface MarketInterface {
|
|
39
43
|
id: Str;
|
|
40
44
|
numericId?: Num;
|
|
@@ -74,10 +78,7 @@ export interface MarketInterface {
|
|
|
74
78
|
price: Num;
|
|
75
79
|
cost?: Num;
|
|
76
80
|
};
|
|
77
|
-
|
|
78
|
-
isolated: boolean;
|
|
79
|
-
cross: boolean;
|
|
80
|
-
};
|
|
81
|
+
marginModes?: MarketMarginModes;
|
|
81
82
|
limits: {
|
|
82
83
|
amount?: MinMax;
|
|
83
84
|
cost?: MinMax;
|
package/js/src/binance.js
CHANGED
|
@@ -2644,6 +2644,7 @@ export default class binance extends Exchange {
|
|
|
2644
2644
|
* @name binance#fetchCurrencies
|
|
2645
2645
|
* @description fetches all available currencies on an exchange
|
|
2646
2646
|
* @see https://developers.binance.com/docs/wallet/capital/all-coins-info
|
|
2647
|
+
* @see https://developers.binance.com/docs/margin_trading/market-data/Get-All-Margin-Assets
|
|
2647
2648
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
2648
2649
|
* @returns {object} an associative dictionary of currencies
|
|
2649
2650
|
*/
|
|
@@ -2663,9 +2664,13 @@ export default class binance extends Exchange {
|
|
|
2663
2664
|
if (apiBackup !== undefined) {
|
|
2664
2665
|
return undefined;
|
|
2665
2666
|
}
|
|
2666
|
-
const
|
|
2667
|
+
const promises = [this.sapiGetCapitalConfigGetall(params), this.sapiGetMarginAllAssets(params)];
|
|
2668
|
+
const results = await Promise.all(promises);
|
|
2669
|
+
const responseCurrencies = results[0];
|
|
2670
|
+
const responseMarginables = results[1];
|
|
2671
|
+
const marginablesById = this.indexBy(responseMarginables, 'assetName');
|
|
2667
2672
|
const result = {};
|
|
2668
|
-
for (let i = 0; i <
|
|
2673
|
+
for (let i = 0; i < responseCurrencies.length; i++) {
|
|
2669
2674
|
//
|
|
2670
2675
|
// {
|
|
2671
2676
|
// "coin": "LINK",
|
|
@@ -2761,7 +2766,7 @@ export default class binance extends Exchange {
|
|
|
2761
2766
|
// ]
|
|
2762
2767
|
// }
|
|
2763
2768
|
//
|
|
2764
|
-
const entry =
|
|
2769
|
+
const entry = responseCurrencies[i];
|
|
2765
2770
|
const id = this.safeString(entry, 'coin');
|
|
2766
2771
|
const name = this.safeString(entry, 'name');
|
|
2767
2772
|
const code = this.safeCurrencyCode(id);
|
|
@@ -2816,6 +2821,17 @@ export default class binance extends Exchange {
|
|
|
2816
2821
|
}
|
|
2817
2822
|
const trading = this.safeBool(entry, 'trading');
|
|
2818
2823
|
const active = (isWithdrawEnabled && isDepositEnabled && trading);
|
|
2824
|
+
const marginEntry = this.safeDict(marginablesById, id, {});
|
|
2825
|
+
//
|
|
2826
|
+
// {
|
|
2827
|
+
// assetName: "BTC",
|
|
2828
|
+
// assetFullName: "Bitcoin",
|
|
2829
|
+
// isBorrowable: true,
|
|
2830
|
+
// isMortgageable: true,
|
|
2831
|
+
// userMinBorrow: "0",
|
|
2832
|
+
// userMinRepay: "0",
|
|
2833
|
+
// }
|
|
2834
|
+
//
|
|
2819
2835
|
result[code] = {
|
|
2820
2836
|
'id': id,
|
|
2821
2837
|
'name': name,
|
|
@@ -2829,6 +2845,7 @@ export default class binance extends Exchange {
|
|
|
2829
2845
|
'fee': fee,
|
|
2830
2846
|
'fees': fees,
|
|
2831
2847
|
'limits': this.limits,
|
|
2848
|
+
'margin': this.safeBool(marginEntry, 'isBorrowable'),
|
|
2832
2849
|
};
|
|
2833
2850
|
}
|
|
2834
2851
|
return result;
|
|
@@ -2842,6 +2859,8 @@ export default class binance extends Exchange {
|
|
|
2842
2859
|
* @see https://developers.binance.com/docs/derivatives/usds-margined-futures/market-data/rest-api/Exchange-Information // swap
|
|
2843
2860
|
* @see https://developers.binance.com/docs/derivatives/coin-margined-futures/market-data/Exchange-Information // future
|
|
2844
2861
|
* @see https://developers.binance.com/docs/derivatives/option/market-data/Exchange-Information // option
|
|
2862
|
+
* @see https://developers.binance.com/docs/margin_trading/market-data/Get-All-Cross-Margin-Pairs // cross margin
|
|
2863
|
+
* @see https://developers.binance.com/docs/margin_trading/market-data/Get-All-Isolated-Margin-Symbol // isolated margin
|
|
2845
2864
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
2846
2865
|
* @returns {object[]} an array of objects representing market data
|
|
2847
2866
|
*/
|
|
@@ -2856,10 +2875,16 @@ export default class binance extends Exchange {
|
|
|
2856
2875
|
}
|
|
2857
2876
|
fetchMarkets.push(type);
|
|
2858
2877
|
}
|
|
2878
|
+
let fetchMargins = false;
|
|
2859
2879
|
for (let i = 0; i < fetchMarkets.length; i++) {
|
|
2860
2880
|
const marketType = fetchMarkets[i];
|
|
2861
2881
|
if (marketType === 'spot') {
|
|
2862
2882
|
promisesRaw.push(this.publicGetExchangeInfo(params));
|
|
2883
|
+
if (this.checkRequiredCredentials(false) && !sandboxMode) {
|
|
2884
|
+
fetchMargins = true;
|
|
2885
|
+
promisesRaw.push(this.sapiGetMarginAllPairs(params));
|
|
2886
|
+
promisesRaw.push(this.sapiGetMarginIsolatedAllPairs(params));
|
|
2887
|
+
}
|
|
2863
2888
|
}
|
|
2864
2889
|
else if (marketType === 'linear') {
|
|
2865
2890
|
promisesRaw.push(this.fapiPublicGetExchangeInfo(params));
|
|
@@ -2874,12 +2899,27 @@ export default class binance extends Exchange {
|
|
|
2874
2899
|
throw new ExchangeError(this.id + ' fetchMarkets() this.options fetchMarkets "' + marketType + '" is not a supported market type');
|
|
2875
2900
|
}
|
|
2876
2901
|
}
|
|
2877
|
-
const
|
|
2902
|
+
const results = await Promise.all(promisesRaw);
|
|
2878
2903
|
let markets = [];
|
|
2879
|
-
|
|
2880
|
-
|
|
2881
|
-
|
|
2882
|
-
|
|
2904
|
+
this.options['crossMarginPairsData'] = [];
|
|
2905
|
+
this.options['isolatedMarginPairsData'] = [];
|
|
2906
|
+
for (let i = 0; i < results.length; i++) {
|
|
2907
|
+
const res = this.safeValue(results, i);
|
|
2908
|
+
if (fetchMargins && Array.isArray(res)) {
|
|
2909
|
+
const keysList = Object.keys(this.indexBy(res, 'symbol'));
|
|
2910
|
+
const length = (Object.keys(this.options['crossMarginPairsData'])).length;
|
|
2911
|
+
// first one is the cross-margin promise
|
|
2912
|
+
if (length === 0) {
|
|
2913
|
+
this.options['crossMarginPairsData'] = keysList;
|
|
2914
|
+
}
|
|
2915
|
+
else {
|
|
2916
|
+
this.options['isolatedMarginPairsData'] = keysList;
|
|
2917
|
+
}
|
|
2918
|
+
}
|
|
2919
|
+
else {
|
|
2920
|
+
const resultMarkets = this.safeList2(res, 'symbols', 'optionSymbols', []);
|
|
2921
|
+
markets = this.arrayConcat(markets, resultMarkets);
|
|
2922
|
+
}
|
|
2883
2923
|
}
|
|
2884
2924
|
//
|
|
2885
2925
|
// spot / margin
|
|
@@ -2925,6 +2965,20 @@ export default class binance extends Exchange {
|
|
|
2925
2965
|
// ],
|
|
2926
2966
|
// }
|
|
2927
2967
|
//
|
|
2968
|
+
// cross & isolated pairs response:
|
|
2969
|
+
//
|
|
2970
|
+
// [
|
|
2971
|
+
// {
|
|
2972
|
+
// symbol: "BTCUSDT",
|
|
2973
|
+
// base: "BTC",
|
|
2974
|
+
// quote: "USDT",
|
|
2975
|
+
// isMarginTrade: true,
|
|
2976
|
+
// isBuyAllowed: true,
|
|
2977
|
+
// isSellAllowed: true,
|
|
2978
|
+
// id: "376870555451677893", // doesn't exist in isolated
|
|
2979
|
+
// },
|
|
2980
|
+
// ]
|
|
2981
|
+
//
|
|
2928
2982
|
// futures/usdt-margined (fapi)
|
|
2929
2983
|
//
|
|
2930
2984
|
// {
|
|
@@ -3159,6 +3213,21 @@ export default class binance extends Exchange {
|
|
|
3159
3213
|
}
|
|
3160
3214
|
}
|
|
3161
3215
|
const isMarginTradingAllowed = this.safeBool(market, 'isMarginTradingAllowed', false);
|
|
3216
|
+
let marginModes = undefined;
|
|
3217
|
+
if (spot) {
|
|
3218
|
+
const hasCrossMargin = this.inArray(id, this.options['crossMarginPairsData']);
|
|
3219
|
+
const hasIsolatedMargin = this.inArray(id, this.options['isolatedMarginPairsData']);
|
|
3220
|
+
marginModes = {
|
|
3221
|
+
'cross': hasCrossMargin,
|
|
3222
|
+
'isolated': hasIsolatedMargin,
|
|
3223
|
+
};
|
|
3224
|
+
}
|
|
3225
|
+
else if (linear || inverse) {
|
|
3226
|
+
marginModes = {
|
|
3227
|
+
'cross': true,
|
|
3228
|
+
'isolated': true,
|
|
3229
|
+
};
|
|
3230
|
+
}
|
|
3162
3231
|
let unifiedType = undefined;
|
|
3163
3232
|
if (spot) {
|
|
3164
3233
|
unifiedType = 'spot';
|
|
@@ -3190,6 +3259,7 @@ export default class binance extends Exchange {
|
|
|
3190
3259
|
'type': unifiedType,
|
|
3191
3260
|
'spot': spot,
|
|
3192
3261
|
'margin': spot && isMarginTradingAllowed,
|
|
3262
|
+
'marginModes': marginModes,
|
|
3193
3263
|
'swap': swap,
|
|
3194
3264
|
'future': future,
|
|
3195
3265
|
'option': option,
|