ccxt 4.2.58 → 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 +3 -3
- package/cleanup.sh +3 -0
- package/dist/ccxt.browser.js +311 -218
- package/dist/ccxt.browser.min.js +3 -3
- package/dist/cjs/ccxt.js +1 -1
- package/dist/cjs/src/base/Exchange.js +2 -0
- package/dist/cjs/src/binance.js +2 -2
- package/dist/cjs/src/bingx.js +3 -3
- package/dist/cjs/src/bitget.js +1 -1
- package/dist/cjs/src/bitmex.js +1 -1
- package/dist/cjs/src/blofin.js +1 -1
- package/dist/cjs/src/coinbase.js +24 -14
- package/dist/cjs/src/lbank.js +1 -1
- package/dist/cjs/src/mexc.js +1 -1
- package/dist/cjs/src/okx.js +1 -1
- package/dist/cjs/src/phemex.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/woo.js +1 -1
- package/dist/cjs/src/woo.js +2 -2
- package/js/ccxt.d.ts +1 -1
- package/js/ccxt.js +1 -1
- package/js/src/base/Exchange.js +2 -0
- package/js/src/binance.js +2 -2
- package/js/src/bingx.js +3 -3
- package/js/src/bitget.js +1 -1
- package/js/src/bitmex.js +1 -1
- package/js/src/blofin.js +1 -1
- package/js/src/coinbase.js +24 -14
- package/js/src/lbank.js +1 -1
- package/js/src/mexc.js +1 -1
- package/js/src/okx.js +1 -1
- package/js/src/phemex.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/woo.js +1 -1
- package/js/src/woo.js +2 -2
- package/package.json +1 -1
- package/skip-tests.json +2 -2
|
@@ -16,10 +16,13 @@ class deribit extends deribit$1 {
|
|
|
16
16
|
'watchTicker': true,
|
|
17
17
|
'watchTickers': false,
|
|
18
18
|
'watchTrades': true,
|
|
19
|
+
'watchTradesForSymbols': true,
|
|
19
20
|
'watchMyTrades': true,
|
|
20
21
|
'watchOrders': true,
|
|
21
22
|
'watchOrderBook': true,
|
|
23
|
+
'watchOrderBookForSymbols': true,
|
|
22
24
|
'watchOHLCV': true,
|
|
25
|
+
'watchOHLCVForSymbols': true,
|
|
23
26
|
},
|
|
24
27
|
'urls': {
|
|
25
28
|
'test': {
|
|
@@ -30,18 +33,31 @@ class deribit extends deribit$1 {
|
|
|
30
33
|
},
|
|
31
34
|
},
|
|
32
35
|
'options': {
|
|
33
|
-
'
|
|
34
|
-
'
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
36
|
+
'ws': {
|
|
37
|
+
'timeframes': {
|
|
38
|
+
'1m': '1',
|
|
39
|
+
'3m': '3',
|
|
40
|
+
'5m': '5',
|
|
41
|
+
'15m': '15',
|
|
42
|
+
'30m': '30',
|
|
43
|
+
'1h': '60',
|
|
44
|
+
'2h': '120',
|
|
45
|
+
'4h': '180',
|
|
46
|
+
'6h': '360',
|
|
47
|
+
'12h': '720',
|
|
48
|
+
'1d': '1D',
|
|
49
|
+
},
|
|
50
|
+
// watchTrades replacement
|
|
51
|
+
'watchTradesForSymbols': {
|
|
52
|
+
'interval': '100ms', // 100ms, agg2, raw
|
|
53
|
+
},
|
|
54
|
+
// watchOrderBook replacement
|
|
55
|
+
'watchOrderBookForSymbols': {
|
|
56
|
+
'interval': '100ms',
|
|
57
|
+
'useDepthEndpoint': false,
|
|
58
|
+
'depth': '20',
|
|
59
|
+
'group': 'none', // none, 1, 2, 5, 10, 25, 100, 250
|
|
60
|
+
},
|
|
45
61
|
},
|
|
46
62
|
'currencies': ['BTC', 'ETH', 'SOL', 'USDC'],
|
|
47
63
|
},
|
|
@@ -221,27 +237,31 @@ class deribit extends deribit$1 {
|
|
|
221
237
|
* @param {str} [params.interval] specify aggregation and frequency of notifications. Possible values: 100ms, raw
|
|
222
238
|
* @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=public-trades}
|
|
223
239
|
*/
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
240
|
+
params['callerMethodName'] = 'watchTrades';
|
|
241
|
+
return await this.watchTradesForSymbols([symbol], since, limit, params);
|
|
242
|
+
}
|
|
243
|
+
async watchTradesForSymbols(symbols, since = undefined, limit = undefined, params = {}) {
|
|
244
|
+
/**
|
|
245
|
+
* @method
|
|
246
|
+
* @name deribit#watchTradesForSymbols
|
|
247
|
+
* @description get the list of most recent trades for a list of symbols
|
|
248
|
+
* @see https://docs.deribit.com/#trades-instrument_name-interval
|
|
249
|
+
* @param {string[]} symbols unified symbol of the market to fetch trades for
|
|
250
|
+
* @param {int} [since] timestamp in ms of the earliest trade to fetch
|
|
251
|
+
* @param {int} [limit] the maximum amount of trades to fetch
|
|
252
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
253
|
+
* @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=public-trades}
|
|
254
|
+
*/
|
|
255
|
+
let interval = undefined;
|
|
256
|
+
[interval, params] = this.handleOptionAndParams(params, 'watchTradesForSymbols', 'interval', '100ms');
|
|
230
257
|
if (interval === 'raw') {
|
|
231
258
|
await this.authenticate();
|
|
232
259
|
}
|
|
233
|
-
const
|
|
234
|
-
'jsonrpc': '2.0',
|
|
235
|
-
'method': 'public/subscribe',
|
|
236
|
-
'params': {
|
|
237
|
-
'channels': [channel],
|
|
238
|
-
},
|
|
239
|
-
'id': this.requestId(),
|
|
240
|
-
};
|
|
241
|
-
const request = this.deepExtend(message, params);
|
|
242
|
-
const trades = await this.watch(url, channel, request, channel, request);
|
|
260
|
+
const trades = await this.watchMultipleWrapper('trades', interval, symbols, params);
|
|
243
261
|
if (this.newUpdates) {
|
|
244
|
-
|
|
262
|
+
const first = this.safeDict(trades, 0);
|
|
263
|
+
const tradeSymbol = this.safeString(first, 'symbol');
|
|
264
|
+
limit = trades.getLimit(tradeSymbol, limit);
|
|
245
265
|
}
|
|
246
266
|
return this.filterBySinceLimit(trades, since, limit, 'timestamp', true);
|
|
247
267
|
}
|
|
@@ -267,26 +287,27 @@ class deribit extends deribit$1 {
|
|
|
267
287
|
// }
|
|
268
288
|
// }
|
|
269
289
|
//
|
|
270
|
-
const params = this.
|
|
290
|
+
const params = this.safeDict(message, 'params', {});
|
|
271
291
|
const channel = this.safeString(params, 'channel', '');
|
|
272
292
|
const parts = channel.split('.');
|
|
273
293
|
const marketId = this.safeString(parts, 1);
|
|
294
|
+
const interval = this.safeString(parts, 2);
|
|
274
295
|
const symbol = this.safeSymbol(marketId);
|
|
275
296
|
const market = this.safeMarket(marketId);
|
|
276
|
-
const trades = this.
|
|
277
|
-
|
|
278
|
-
if (stored === undefined) {
|
|
297
|
+
const trades = this.safeList(params, 'data', []);
|
|
298
|
+
if (this.safeValue(this.trades, symbol) === undefined) {
|
|
279
299
|
const limit = this.safeInteger(this.options, 'tradesLimit', 1000);
|
|
280
|
-
|
|
281
|
-
this.trades[symbol] = stored;
|
|
300
|
+
this.trades[symbol] = new Cache.ArrayCache(limit);
|
|
282
301
|
}
|
|
302
|
+
const stored = this.trades[symbol];
|
|
283
303
|
for (let i = 0; i < trades.length; i++) {
|
|
284
304
|
const trade = trades[i];
|
|
285
305
|
const parsed = this.parseTrade(trade, market);
|
|
286
306
|
stored.append(parsed);
|
|
287
307
|
}
|
|
288
308
|
this.trades[symbol] = stored;
|
|
289
|
-
|
|
309
|
+
const messageHash = 'trades|' + symbol + '|' + interval;
|
|
310
|
+
client.resolve(this.trades[symbol], messageHash);
|
|
290
311
|
}
|
|
291
312
|
async watchMyTrades(symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
292
313
|
/**
|
|
@@ -375,7 +396,7 @@ class deribit extends deribit$1 {
|
|
|
375
396
|
/**
|
|
376
397
|
* @method
|
|
377
398
|
* @name deribit#watchOrderBook
|
|
378
|
-
* @see https://docs.deribit.com/#
|
|
399
|
+
* @see https://docs.deribit.com/#book-instrument_name-group-depth-interval
|
|
379
400
|
* @description watches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
|
|
380
401
|
* @param {string} symbol unified symbol of the market to fetch the order book for
|
|
381
402
|
* @param {int} [limit] the maximum amount of order book entries to return
|
|
@@ -383,25 +404,39 @@ class deribit extends deribit$1 {
|
|
|
383
404
|
* @param {string} [params.interval] Frequency of notifications. Events will be aggregated over this interval. Possible values: 100ms, raw
|
|
384
405
|
* @returns {object} A dictionary of [order book structures]{@link https://docs.ccxt.com/#/?id=order-book-structure} indexed by market symbols
|
|
385
406
|
*/
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
407
|
+
params['callerMethodName'] = 'watchOrderBook';
|
|
408
|
+
return await this.watchOrderBookForSymbols([symbol], limit, params);
|
|
409
|
+
}
|
|
410
|
+
async watchOrderBookForSymbols(symbols, limit = undefined, params = {}) {
|
|
411
|
+
/**
|
|
412
|
+
* @method
|
|
413
|
+
* @name deribit#watchOrderBookForSymbols
|
|
414
|
+
* @description watches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
|
|
415
|
+
* @see https://docs.deribit.com/#book-instrument_name-group-depth-interval
|
|
416
|
+
* @param {string[]} symbols unified array of symbols
|
|
417
|
+
* @param {int} [limit] the maximum amount of order book entries to return
|
|
418
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
419
|
+
* @returns {object} A dictionary of [order book structures]{@link https://docs.ccxt.com/#/?id=order-book-structure} indexed by market symbols
|
|
420
|
+
*/
|
|
421
|
+
let interval = undefined;
|
|
422
|
+
[interval, params] = this.handleOptionAndParams(params, 'watchOrderBookForSymbols', 'interval', '100ms');
|
|
391
423
|
if (interval === 'raw') {
|
|
392
424
|
await this.authenticate();
|
|
393
425
|
}
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
426
|
+
let descriptor = '';
|
|
427
|
+
let useDepthEndpoint = undefined; // for more info, see comment in .options
|
|
428
|
+
[useDepthEndpoint, params] = this.handleOptionAndParams(params, 'watchOrderBookForSymbols', 'useDepthEndpoint', false);
|
|
429
|
+
if (useDepthEndpoint) {
|
|
430
|
+
let depth = undefined;
|
|
431
|
+
[depth, params] = this.handleOptionAndParams(params, 'watchOrderBookForSymbols', 'depth', '20');
|
|
432
|
+
let group = undefined;
|
|
433
|
+
[group, params] = this.handleOptionAndParams(params, 'watchOrderBookForSymbols', 'group', 'none');
|
|
434
|
+
descriptor = group + '.' + depth + '.' + interval;
|
|
435
|
+
}
|
|
436
|
+
else {
|
|
437
|
+
descriptor = interval;
|
|
438
|
+
}
|
|
439
|
+
const orderbook = await this.watchMultipleWrapper('book', descriptor, symbols, params);
|
|
405
440
|
return orderbook.limit();
|
|
406
441
|
}
|
|
407
442
|
handleOrderBook(client, message) {
|
|
@@ -453,6 +488,20 @@ class deribit extends deribit$1 {
|
|
|
453
488
|
const params = this.safeValue(message, 'params', {});
|
|
454
489
|
const data = this.safeValue(params, 'data', {});
|
|
455
490
|
const channel = this.safeString(params, 'channel');
|
|
491
|
+
const parts = channel.split('.');
|
|
492
|
+
let descriptor = '';
|
|
493
|
+
const partsLength = parts.length;
|
|
494
|
+
const isDetailed = partsLength === 5;
|
|
495
|
+
if (isDetailed) {
|
|
496
|
+
const group = this.safeString(parts, 2);
|
|
497
|
+
const depth = this.safeString(parts, 3);
|
|
498
|
+
const interval = this.safeString(parts, 4);
|
|
499
|
+
descriptor = group + '.' + depth + '.' + interval;
|
|
500
|
+
}
|
|
501
|
+
else {
|
|
502
|
+
const interval = this.safeString(parts, 2);
|
|
503
|
+
descriptor = interval;
|
|
504
|
+
}
|
|
456
505
|
const marketId = this.safeString(data, 'instrument_name');
|
|
457
506
|
const symbol = this.safeSymbol(marketId);
|
|
458
507
|
const timestamp = this.safeInteger(data, 'timestamp');
|
|
@@ -469,7 +518,8 @@ class deribit extends deribit$1 {
|
|
|
469
518
|
storedOrderBook['datetime'] = this.iso8601(timestamp);
|
|
470
519
|
storedOrderBook['symbol'] = symbol;
|
|
471
520
|
this.orderbooks[symbol] = storedOrderBook;
|
|
472
|
-
|
|
521
|
+
const messageHash = 'book|' + symbol + '|' + descriptor;
|
|
522
|
+
client.resolve(storedOrderBook, messageHash);
|
|
473
523
|
}
|
|
474
524
|
cleanOrderBook(data) {
|
|
475
525
|
const bids = this.safeValue(data, 'bids', []);
|
|
@@ -609,28 +659,32 @@ class deribit extends deribit$1 {
|
|
|
609
659
|
* @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
|
|
610
660
|
*/
|
|
611
661
|
await this.loadMarkets();
|
|
612
|
-
|
|
613
|
-
const
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
662
|
+
symbol = this.symbol(symbol);
|
|
663
|
+
const ohlcvs = await this.watchOHLCVForSymbols([[symbol, timeframe]], since, limit, params);
|
|
664
|
+
return ohlcvs[symbol][timeframe];
|
|
665
|
+
}
|
|
666
|
+
async watchOHLCVForSymbols(symbolsAndTimeframes, since = undefined, limit = undefined, params = {}) {
|
|
667
|
+
/**
|
|
668
|
+
* @method
|
|
669
|
+
* @name deribit#watchOHLCVForSymbols
|
|
670
|
+
* @description watches historical candlestick data containing the open, high, low, and close price, and the volume of a market
|
|
671
|
+
* @see https://docs.deribit.com/#chart-trades-instrument_name-resolution
|
|
672
|
+
* @param {string[][]} symbolsAndTimeframes array of arrays containing unified symbols and timeframes to fetch OHLCV data for, example [['BTC/USDT', '1m'], ['LTC/USDT', '5m']]
|
|
673
|
+
* @param {int} [since] timestamp in ms of the earliest candle to fetch
|
|
674
|
+
* @param {int} [limit] the maximum amount of candles to fetch
|
|
675
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
676
|
+
* @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
|
|
677
|
+
*/
|
|
678
|
+
const symbolsLength = symbolsAndTimeframes.length;
|
|
679
|
+
if (symbolsLength === 0 || !Array.isArray(symbolsAndTimeframes[0])) {
|
|
680
|
+
throw new errors.ArgumentsRequired(this.id + " watchOHLCVForSymbols() requires a an array of symbols and timeframes, like [['BTC/USDT', '1m'], ['LTC/USDT', '5m']]");
|
|
618
681
|
}
|
|
619
|
-
const
|
|
620
|
-
const message = {
|
|
621
|
-
'jsonrpc': '2.0',
|
|
622
|
-
'method': 'public/subscribe',
|
|
623
|
-
'params': {
|
|
624
|
-
'channels': [channel],
|
|
625
|
-
},
|
|
626
|
-
'id': this.requestId(),
|
|
627
|
-
};
|
|
628
|
-
const request = this.deepExtend(message, params);
|
|
629
|
-
const ohlcv = await this.watch(url, channel, request, channel, request);
|
|
682
|
+
const [symbol, timeframe, candles] = await this.watchMultipleWrapper('chart.trades', undefined, symbolsAndTimeframes, params);
|
|
630
683
|
if (this.newUpdates) {
|
|
631
|
-
limit =
|
|
684
|
+
limit = candles.getLimit(symbol, limit);
|
|
632
685
|
}
|
|
633
|
-
|
|
686
|
+
const filtered = this.filterBySinceLimit(candles, since, limit, 0, true);
|
|
687
|
+
return this.createOHLCVObject(symbol, timeframe, filtered);
|
|
634
688
|
}
|
|
635
689
|
handleOHLCV(client, message) {
|
|
636
690
|
//
|
|
@@ -651,13 +705,44 @@ class deribit extends deribit$1 {
|
|
|
651
705
|
// }
|
|
652
706
|
// }
|
|
653
707
|
//
|
|
654
|
-
const params = this.
|
|
708
|
+
const params = this.safeDict(message, 'params', {});
|
|
655
709
|
const channel = this.safeString(params, 'channel', '');
|
|
656
710
|
const parts = channel.split('.');
|
|
657
711
|
const marketId = this.safeString(parts, 2);
|
|
658
|
-
const
|
|
659
|
-
const
|
|
660
|
-
const
|
|
712
|
+
const rawTimeframe = this.safeString(parts, 3);
|
|
713
|
+
const market = this.safeMarket(marketId);
|
|
714
|
+
const symbol = market['symbol'];
|
|
715
|
+
const wsOptions = this.safeDict(this.options, 'ws', {});
|
|
716
|
+
const timeframes = this.safeDict(wsOptions, 'timeframes', {});
|
|
717
|
+
const unifiedTimeframe = this.findTimeframe(rawTimeframe, timeframes);
|
|
718
|
+
this.ohlcvs[symbol] = this.safeDict(this.ohlcvs, symbol, {});
|
|
719
|
+
if (this.safeValue(this.ohlcvs[symbol], unifiedTimeframe) === undefined) {
|
|
720
|
+
const limit = this.safeInteger(this.options, 'OHLCVLimit', 1000);
|
|
721
|
+
this.ohlcvs[symbol][unifiedTimeframe] = new Cache.ArrayCacheByTimestamp(limit);
|
|
722
|
+
}
|
|
723
|
+
const stored = this.ohlcvs[symbol][unifiedTimeframe];
|
|
724
|
+
const ohlcv = this.safeDict(params, 'data', {});
|
|
725
|
+
// data contains a single OHLCV candle
|
|
726
|
+
const parsed = this.parseWsOHLCV(ohlcv, market);
|
|
727
|
+
stored.append(parsed);
|
|
728
|
+
this.ohlcvs[symbol][unifiedTimeframe] = stored;
|
|
729
|
+
const resolveData = [symbol, unifiedTimeframe, stored];
|
|
730
|
+
const messageHash = 'chart.trades|' + symbol + '|' + rawTimeframe;
|
|
731
|
+
client.resolve(resolveData, messageHash);
|
|
732
|
+
}
|
|
733
|
+
parseWsOHLCV(ohlcv, market = undefined) {
|
|
734
|
+
//
|
|
735
|
+
// {
|
|
736
|
+
// "c": "28909.0",
|
|
737
|
+
// "o": "28915.4",
|
|
738
|
+
// "h": "28915.4",
|
|
739
|
+
// "l": "28896.1",
|
|
740
|
+
// "v": "27.6919",
|
|
741
|
+
// "T": 1696687499999,
|
|
742
|
+
// "t": 1696687440000
|
|
743
|
+
// }
|
|
744
|
+
//
|
|
745
|
+
return [
|
|
661
746
|
this.safeInteger(ohlcv, 'tick'),
|
|
662
747
|
this.safeNumber(ohlcv, 'open'),
|
|
663
748
|
this.safeNumber(ohlcv, 'high'),
|
|
@@ -665,14 +750,46 @@ class deribit extends deribit$1 {
|
|
|
665
750
|
this.safeNumber(ohlcv, 'close'),
|
|
666
751
|
this.safeNumber(ohlcv, 'volume'),
|
|
667
752
|
];
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
753
|
+
}
|
|
754
|
+
async watchMultipleWrapper(channelName, channelDescriptor, symbolsArray = undefined, params = {}) {
|
|
755
|
+
await this.loadMarkets();
|
|
756
|
+
const url = this.urls['api']['ws'];
|
|
757
|
+
const rawSubscriptions = [];
|
|
758
|
+
const messageHashes = [];
|
|
759
|
+
const isOHLCV = (channelName === 'chart.trades');
|
|
760
|
+
const symbols = isOHLCV ? this.getListFromObjectValues(symbolsArray, 0) : symbolsArray;
|
|
761
|
+
this.marketSymbols(symbols, undefined, false);
|
|
762
|
+
for (let i = 0; i < symbolsArray.length; i++) {
|
|
763
|
+
const current = symbolsArray[i];
|
|
764
|
+
let market = undefined;
|
|
765
|
+
if (isOHLCV) {
|
|
766
|
+
market = this.market(current[0]);
|
|
767
|
+
const unifiedTf = current[1];
|
|
768
|
+
const rawTf = this.safeString(this.timeframes, unifiedTf, unifiedTf);
|
|
769
|
+
channelDescriptor = rawTf;
|
|
770
|
+
}
|
|
771
|
+
else {
|
|
772
|
+
market = this.market(current);
|
|
773
|
+
}
|
|
774
|
+
const message = channelName + '.' + market['id'] + '.' + channelDescriptor;
|
|
775
|
+
rawSubscriptions.push(message);
|
|
776
|
+
messageHashes.push(channelName + '|' + market['symbol'] + '|' + channelDescriptor);
|
|
672
777
|
}
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
778
|
+
const request = {
|
|
779
|
+
'jsonrpc': '2.0',
|
|
780
|
+
'method': 'public/subscribe',
|
|
781
|
+
'params': {
|
|
782
|
+
'channels': rawSubscriptions,
|
|
783
|
+
},
|
|
784
|
+
'id': this.requestId(),
|
|
785
|
+
};
|
|
786
|
+
const extendedRequest = this.deepExtend(request, params);
|
|
787
|
+
const maxMessageByteLimit = 32768 - 1; // 'Message Too Big: limit 32768B'
|
|
788
|
+
const jsonedText = this.json(extendedRequest);
|
|
789
|
+
if (jsonedText.length >= maxMessageByteLimit) {
|
|
790
|
+
throw new errors.ExchangeError(this.id + ' requested subscription length over limit, try to reduce symbols amount');
|
|
791
|
+
}
|
|
792
|
+
return await this.watchMultiple(url, messageHashes, extendedRequest, rawSubscriptions);
|
|
676
793
|
}
|
|
677
794
|
handleMessage(client, message) {
|
|
678
795
|
//
|
package/dist/cjs/src/pro/gate.js
CHANGED
|
@@ -822,7 +822,7 @@ class gate extends gate$1 {
|
|
|
822
822
|
const client = this.client(url);
|
|
823
823
|
this.setPositionsCache(client, type, symbols);
|
|
824
824
|
const fetchPositionsSnapshot = this.handleOption('watchPositions', 'fetchPositionsSnapshot', true);
|
|
825
|
-
const awaitPositionsSnapshot = this.
|
|
825
|
+
const awaitPositionsSnapshot = this.safeBool('watchPositions', 'awaitPositionsSnapshot', true);
|
|
826
826
|
const cache = this.safeValue(this.positions, type);
|
|
827
827
|
if (fetchPositionsSnapshot && awaitPositionsSnapshot && cache === undefined) {
|
|
828
828
|
return await client.future(type + ':fetchPositionsSnapshot');
|
|
@@ -196,7 +196,7 @@ class independentreserve extends independentreserve$1 {
|
|
|
196
196
|
orderbook['timestamp'] = timestamp;
|
|
197
197
|
orderbook['datetime'] = this.iso8601(timestamp);
|
|
198
198
|
}
|
|
199
|
-
const checksum = this.
|
|
199
|
+
const checksum = this.safeBool(this.options, 'checksum', true);
|
|
200
200
|
if (checksum && receivedSnapshot) {
|
|
201
201
|
const storedAsks = orderbook['asks'];
|
|
202
202
|
const storedBids = orderbook['bids'];
|
|
@@ -697,7 +697,7 @@ class kraken extends kraken$1 {
|
|
|
697
697
|
}
|
|
698
698
|
// don't remove this line or I will poop on your face
|
|
699
699
|
orderbook.limit();
|
|
700
|
-
const checksum = this.
|
|
700
|
+
const checksum = this.safeBool(this.options, 'checksum', true);
|
|
701
701
|
if (checksum) {
|
|
702
702
|
const priceString = this.safeString(example, 0);
|
|
703
703
|
const amountString = this.safeString(example, 1);
|
|
@@ -238,7 +238,7 @@ class kucoinfutures extends kucoinfutures$1 {
|
|
|
238
238
|
const client = this.client(url);
|
|
239
239
|
this.setPositionCache(client, symbol);
|
|
240
240
|
const fetchPositionSnapshot = this.handleOption('watchPosition', 'fetchPositionSnapshot', true);
|
|
241
|
-
const awaitPositionSnapshot = this.
|
|
241
|
+
const awaitPositionSnapshot = this.safeBool('watchPosition', 'awaitPositionSnapshot', true);
|
|
242
242
|
const currentPosition = this.getCurrentPosition(symbol);
|
|
243
243
|
if (fetchPositionSnapshot && awaitPositionSnapshot && currentPosition === undefined) {
|
|
244
244
|
const snapshot = await client.future('fetchPositionSnapshot:' + symbol);
|
package/dist/cjs/src/pro/mexc.js
CHANGED
|
@@ -500,10 +500,12 @@ class mexc extends mexc$1 {
|
|
|
500
500
|
}
|
|
501
501
|
}
|
|
502
502
|
handleDelta(orderbook, delta) {
|
|
503
|
-
const
|
|
503
|
+
const existingNonce = this.safeInteger(orderbook, 'nonce');
|
|
504
504
|
const deltaNonce = this.safeInteger2(delta, 'r', 'version');
|
|
505
|
-
if (deltaNonce
|
|
506
|
-
|
|
505
|
+
if (deltaNonce < existingNonce) {
|
|
506
|
+
// even when doing < comparison, this happens: https://app.travis-ci.com/github/ccxt/ccxt/builds/269234741#L1809
|
|
507
|
+
// so, we just skip old updates
|
|
508
|
+
return;
|
|
507
509
|
}
|
|
508
510
|
orderbook['nonce'] = deltaNonce;
|
|
509
511
|
const asks = this.safeValue(delta, 'asks', []);
|
package/dist/cjs/src/pro/okx.js
CHANGED
|
@@ -559,7 +559,7 @@ class okx extends okx$1 {
|
|
|
559
559
|
const storedBids = orderbook['bids'];
|
|
560
560
|
this.handleDeltas(storedAsks, asks);
|
|
561
561
|
this.handleDeltas(storedBids, bids);
|
|
562
|
-
const checksum = this.
|
|
562
|
+
const checksum = this.safeBool(this.options, 'checksum', true);
|
|
563
563
|
if (checksum) {
|
|
564
564
|
const asksLength = storedAsks.length;
|
|
565
565
|
const bidsLength = storedBids.length;
|
package/dist/cjs/src/pro/woo.js
CHANGED
|
@@ -629,7 +629,7 @@ class woo extends woo$1 {
|
|
|
629
629
|
const client = this.client(url);
|
|
630
630
|
this.setPositionsCache(client, symbols);
|
|
631
631
|
const fetchPositionsSnapshot = this.handleOption('watchPositions', 'fetchPositionsSnapshot', true);
|
|
632
|
-
const awaitPositionsSnapshot = this.
|
|
632
|
+
const awaitPositionsSnapshot = this.safeBool('watchPositions', 'awaitPositionsSnapshot', true);
|
|
633
633
|
if (fetchPositionsSnapshot && awaitPositionsSnapshot && this.positions === undefined) {
|
|
634
634
|
const snapshot = await client.future('fetchPositionsSnapshot');
|
|
635
635
|
return this.filterBySymbolsSinceLimit(snapshot, symbols, since, limit, true);
|
package/dist/cjs/src/woo.js
CHANGED
|
@@ -490,7 +490,7 @@ class woo extends woo$1 {
|
|
|
490
490
|
// ]
|
|
491
491
|
// }
|
|
492
492
|
//
|
|
493
|
-
const resultResponse = this.
|
|
493
|
+
const resultResponse = this.safeList(response, 'rows', []);
|
|
494
494
|
return this.parseTrades(resultResponse, market, since, limit);
|
|
495
495
|
}
|
|
496
496
|
parseTrade(trade, market = undefined) {
|
|
@@ -2334,7 +2334,7 @@ class woo extends woo$1 {
|
|
|
2334
2334
|
else {
|
|
2335
2335
|
this.checkRequiredCredentials();
|
|
2336
2336
|
if (method === 'POST' && (path === 'algo/order' || path === 'order')) {
|
|
2337
|
-
const isSandboxMode = this.
|
|
2337
|
+
const isSandboxMode = this.safeBool(this.options, 'sandboxMode', false);
|
|
2338
2338
|
if (!isSandboxMode) {
|
|
2339
2339
|
const applicationId = 'bc830de7-50f3-460b-9ee0-f430f83f9dad';
|
|
2340
2340
|
const brokerId = this.safeString(this.options, 'brokerId', applicationId);
|
package/js/ccxt.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import * as functions from './src/base/functions.js';
|
|
|
4
4
|
import * as errors from './src/base/errors.js';
|
|
5
5
|
import type { Market, Trade, Fee, Ticker, OrderBook, Order, Transaction, Tickers, Currency, Balance, DepositAddress, WithdrawalResponse, DepositAddressResponse, OHLCV, Balances, PartialBalances, Dictionary, MinMax, Position, FundingRateHistory, Liquidation, FundingHistory, MarginMode, Greeks, Leverage, Leverages } from './src/base/types.js';
|
|
6
6
|
import { BaseError, ExchangeError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, MarginModeAlreadySet, BadResponse, NullResponse, InsufficientFunds, InvalidAddress, InvalidOrder, OrderNotFound, OrderNotCached, CancelPending, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, NotSupported, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, RequestTimeout, AuthenticationError, AddressPending, NoChange } from './src/base/errors.js';
|
|
7
|
-
declare const version = "4.2.
|
|
7
|
+
declare const version = "4.2.58";
|
|
8
8
|
import ace from './src/ace.js';
|
|
9
9
|
import alpaca from './src/alpaca.js';
|
|
10
10
|
import ascendex from './src/ascendex.js';
|
package/js/ccxt.js
CHANGED
|
@@ -38,7 +38,7 @@ import * as errors from './src/base/errors.js';
|
|
|
38
38
|
import { BaseError, ExchangeError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, MarginModeAlreadySet, BadResponse, NullResponse, InsufficientFunds, InvalidAddress, InvalidOrder, OrderNotFound, OrderNotCached, CancelPending, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, NotSupported, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, RequestTimeout, AuthenticationError, AddressPending, NoChange } from './src/base/errors.js';
|
|
39
39
|
//-----------------------------------------------------------------------------
|
|
40
40
|
// this is updated by vss.js when building
|
|
41
|
-
const version = '4.2.
|
|
41
|
+
const version = '4.2.59';
|
|
42
42
|
Exchange.ccxtVersion = version;
|
|
43
43
|
//-----------------------------------------------------------------------------
|
|
44
44
|
import ace from './src/ace.js';
|
package/js/src/base/Exchange.js
CHANGED
|
@@ -3891,6 +3891,8 @@ export default class Exchange {
|
|
|
3891
3891
|
params = this.omit(params, [optionName, defaultOptionName]);
|
|
3892
3892
|
}
|
|
3893
3893
|
else {
|
|
3894
|
+
// handle routed methods like "watchTrades > watchTradesForSymbols" (or "watchTicker > watchTickers")
|
|
3895
|
+
[methodName, params] = this.handleParamString(params, 'callerMethodName', methodName);
|
|
3894
3896
|
// check if exchange has properties for this method
|
|
3895
3897
|
const exchangeWideMethodOptions = this.safeValue(this.options, methodName);
|
|
3896
3898
|
if (exchangeWideMethodOptions !== undefined) {
|
package/js/src/binance.js
CHANGED
|
@@ -4813,7 +4813,7 @@ export default class binance extends Exchange {
|
|
|
4813
4813
|
let stopPriceIsRequired = false;
|
|
4814
4814
|
let quantityIsRequired = false;
|
|
4815
4815
|
if (uppercaseType === 'MARKET') {
|
|
4816
|
-
const quoteOrderQty = this.
|
|
4816
|
+
const quoteOrderQty = this.safeBool(this.options, 'quoteOrderQty', true);
|
|
4817
4817
|
if (quoteOrderQty) {
|
|
4818
4818
|
const quoteOrderQtyNew = this.safeValue2(params, 'quoteOrderQty', 'cost');
|
|
4819
4819
|
const precision = market['precision']['price'];
|
|
@@ -10321,7 +10321,7 @@ export default class binance extends Exchange {
|
|
|
10321
10321
|
// POST https://fapi.binance.com/fapi/v1/marginType 400 Bad Request
|
|
10322
10322
|
// binanceusdm
|
|
10323
10323
|
if (e instanceof MarginModeAlreadySet) {
|
|
10324
|
-
const throwMarginModeAlreadySet = this.
|
|
10324
|
+
const throwMarginModeAlreadySet = this.safeBool(this.options, 'throwMarginModeAlreadySet', false);
|
|
10325
10325
|
if (throwMarginModeAlreadySet) {
|
|
10326
10326
|
throw e;
|
|
10327
10327
|
}
|
package/js/src/bingx.js
CHANGED
|
@@ -452,7 +452,7 @@ export default class bingx extends Exchange {
|
|
|
452
452
|
if (!this.checkRequiredCredentials(false)) {
|
|
453
453
|
return undefined;
|
|
454
454
|
}
|
|
455
|
-
const isSandbox = this.
|
|
455
|
+
const isSandbox = this.safeBool(this.options, 'sandboxMode', false);
|
|
456
456
|
if (isSandbox) {
|
|
457
457
|
return undefined;
|
|
458
458
|
}
|
|
@@ -696,7 +696,7 @@ export default class bingx extends Exchange {
|
|
|
696
696
|
* @returns {object[]} an array of objects representing market data
|
|
697
697
|
*/
|
|
698
698
|
const requests = [this.fetchSwapMarkets(params)];
|
|
699
|
-
const isSandbox = this.
|
|
699
|
+
const isSandbox = this.safeBool(this.options, 'sandboxMode', false);
|
|
700
700
|
if (!isSandbox) {
|
|
701
701
|
requests.push(this.fetchSpotMarkets(params)); // sandbox is swap only
|
|
702
702
|
}
|
|
@@ -4173,7 +4173,7 @@ export default class bingx extends Exchange {
|
|
|
4173
4173
|
const type = section[0];
|
|
4174
4174
|
const version = section[1];
|
|
4175
4175
|
const access = section[2];
|
|
4176
|
-
const isSandbox = this.
|
|
4176
|
+
const isSandbox = this.safeBool(this.options, 'sandboxMode', false);
|
|
4177
4177
|
if (isSandbox && (type !== 'swap')) {
|
|
4178
4178
|
throw new NotSupported(this.id + ' does not have a testnet/sandbox URL for ' + type + ' endpoints');
|
|
4179
4179
|
}
|
package/js/src/bitget.js
CHANGED
|
@@ -4516,7 +4516,7 @@ export default class bitget extends Exchange {
|
|
|
4516
4516
|
params = this.omit(params, ['stopPrice', 'triggerType', 'stopLossPrice', 'takeProfitPrice', 'stopLoss', 'takeProfit', 'clientOrderId', 'trailingTriggerPrice', 'trailingPercent']);
|
|
4517
4517
|
let response = undefined;
|
|
4518
4518
|
if (market['spot']) {
|
|
4519
|
-
const editMarketBuyOrderRequiresPrice = this.
|
|
4519
|
+
const editMarketBuyOrderRequiresPrice = this.safeBool(this.options, 'editMarketBuyOrderRequiresPrice', true);
|
|
4520
4520
|
if (editMarketBuyOrderRequiresPrice && isMarketOrder && (side === 'buy')) {
|
|
4521
4521
|
if (price === undefined) {
|
|
4522
4522
|
throw new InvalidOrder(this.id + ' editOrder() requires price argument for market buy orders on spot markets to calculate the total amount to spend (amount * price), alternatively set the editMarketBuyOrderRequiresPrice option to false and pass in the cost to spend into the amount parameter');
|
package/js/src/bitmex.js
CHANGED
|
@@ -1510,7 +1510,7 @@ export default class bitmex extends Exchange {
|
|
|
1510
1510
|
request['endTime'] = this.iso8601(until);
|
|
1511
1511
|
}
|
|
1512
1512
|
const duration = this.parseTimeframe(timeframe) * 1000;
|
|
1513
|
-
const fetchOHLCVOpenTimestamp = this.
|
|
1513
|
+
const fetchOHLCVOpenTimestamp = this.safeBool(this.options, 'fetchOHLCVOpenTimestamp', true);
|
|
1514
1514
|
// if since is not set, they will return candles starting from 2017-01-01
|
|
1515
1515
|
if (since !== undefined) {
|
|
1516
1516
|
let timestamp = since;
|
package/js/src/blofin.js
CHANGED
|
@@ -491,7 +491,7 @@ export default class blofin extends Exchange {
|
|
|
491
491
|
const symbol = market['symbol'];
|
|
492
492
|
const last = this.safeString(ticker, 'last');
|
|
493
493
|
const open = this.safeString(ticker, 'open24h');
|
|
494
|
-
const spot = this.
|
|
494
|
+
const spot = this.safeBool(market, 'spot', false);
|
|
495
495
|
const quoteVolume = spot ? this.safeString(ticker, 'volCurrency24h') : undefined;
|
|
496
496
|
const baseVolume = this.safeString(ticker, 'vol24h');
|
|
497
497
|
const high = this.safeString(ticker, 'high24h');
|