ccxt 4.3.61 → 4.3.63

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.
Files changed (104) hide show
  1. package/README.md +3 -3
  2. package/dist/ccxt.browser.min.js +3 -3
  3. package/dist/cjs/ccxt.js +2 -1
  4. package/dist/cjs/src/ace.js +34 -15
  5. package/dist/cjs/src/base/Exchange.js +8 -1
  6. package/dist/cjs/src/base/errors.js +8 -1
  7. package/dist/cjs/src/binance.js +50 -43
  8. package/dist/cjs/src/bingx.js +507 -184
  9. package/dist/cjs/src/bybit.js +1 -1
  10. package/dist/cjs/src/cryptocom.js +18 -2
  11. package/dist/cjs/src/mercado.js +5 -1
  12. package/dist/cjs/src/pro/alpaca.js +3 -3
  13. package/dist/cjs/src/pro/binance.js +60 -38
  14. package/dist/cjs/src/pro/bingx.js +2 -2
  15. package/dist/cjs/src/pro/bitfinex2.js +8 -5
  16. package/dist/cjs/src/pro/bitget.js +5 -2
  17. package/dist/cjs/src/pro/bitmex.js +1 -1
  18. package/dist/cjs/src/pro/bitopro.js +1 -1
  19. package/dist/cjs/src/pro/bitvavo.js +1 -1
  20. package/dist/cjs/src/pro/bybit.js +49 -23
  21. package/dist/cjs/src/pro/coinbaseexchange.js +2 -2
  22. package/dist/cjs/src/pro/coincheck.js +1 -1
  23. package/dist/cjs/src/pro/coinone.js +1 -1
  24. package/dist/cjs/src/pro/cryptocom.js +8 -2
  25. package/dist/cjs/src/pro/deribit.js +1 -1
  26. package/dist/cjs/src/pro/gate.js +8 -4
  27. package/dist/cjs/src/pro/hollaex.js +1 -1
  28. package/dist/cjs/src/pro/htx.js +6 -2
  29. package/dist/cjs/src/pro/hyperliquid.js +3 -3
  30. package/dist/cjs/src/pro/independentreserve.js +5 -3
  31. package/dist/cjs/src/pro/kraken.js +83 -5
  32. package/dist/cjs/src/pro/kucoin.js +1 -1
  33. package/dist/cjs/src/pro/mexc.js +1 -1
  34. package/dist/cjs/src/pro/okx.js +4 -4
  35. package/dist/cjs/src/pro/oxfun.js +1 -1
  36. package/dist/cjs/src/pro/phemex.js +1 -1
  37. package/dist/cjs/src/pro/poloniexfutures.js +5 -1
  38. package/dist/cjs/src/pro/upbit.js +1 -1
  39. package/dist/cjs/src/pro/vertex.js +2 -2
  40. package/dist/cjs/src/pro/whitebit.js +1 -1
  41. package/dist/cjs/src/pro/woo.js +1 -1
  42. package/dist/cjs/src/pro/woofipro.js +1 -1
  43. package/dist/cjs/src/tradeogre.js +1 -1
  44. package/dist/cjs/src/woo.js +313 -81
  45. package/dist/cjs/src/xt.js +1 -1
  46. package/js/ccxt.d.ts +3 -3
  47. package/js/ccxt.js +3 -3
  48. package/js/src/abstract/cryptocom.d.ts +11 -0
  49. package/js/src/abstract/woo.d.ts +3 -0
  50. package/js/src/ace.js +34 -15
  51. package/js/src/base/Exchange.d.ts +1 -0
  52. package/js/src/base/Exchange.js +8 -1
  53. package/js/src/base/errorHierarchy.d.ts +3 -1
  54. package/js/src/base/errorHierarchy.js +3 -1
  55. package/js/src/base/errors.d.ts +5 -1
  56. package/js/src/base/errors.js +8 -2
  57. package/js/src/base/ws/Client.d.ts +1 -1
  58. package/js/src/binance.js +50 -43
  59. package/js/src/bingx.d.ts +1 -0
  60. package/js/src/bingx.js +507 -184
  61. package/js/src/bybit.js +1 -1
  62. package/js/src/coinbaseinternational.d.ts +1 -1
  63. package/js/src/cryptocom.js +18 -2
  64. package/js/src/mercado.js +5 -1
  65. package/js/src/pro/alpaca.js +3 -3
  66. package/js/src/pro/binance.d.ts +1 -0
  67. package/js/src/pro/binance.js +61 -39
  68. package/js/src/pro/bingx.js +2 -2
  69. package/js/src/pro/bitfinex2.js +9 -6
  70. package/js/src/pro/bitget.js +6 -3
  71. package/js/src/pro/bitmex.js +1 -1
  72. package/js/src/pro/bitopro.js +1 -1
  73. package/js/src/pro/bitvavo.js +1 -1
  74. package/js/src/pro/bybit.d.ts +1 -0
  75. package/js/src/pro/bybit.js +49 -23
  76. package/js/src/pro/coinbaseexchange.js +2 -2
  77. package/js/src/pro/coincheck.js +1 -1
  78. package/js/src/pro/coinone.js +1 -1
  79. package/js/src/pro/cryptocom.js +9 -3
  80. package/js/src/pro/deribit.js +1 -1
  81. package/js/src/pro/gate.js +9 -5
  82. package/js/src/pro/hollaex.js +1 -1
  83. package/js/src/pro/htx.js +7 -3
  84. package/js/src/pro/hyperliquid.js +3 -3
  85. package/js/src/pro/independentreserve.js +6 -4
  86. package/js/src/pro/kraken.d.ts +3 -1
  87. package/js/src/pro/kraken.js +84 -6
  88. package/js/src/pro/kucoin.js +1 -1
  89. package/js/src/pro/mexc.js +1 -1
  90. package/js/src/pro/okx.js +5 -5
  91. package/js/src/pro/oxfun.js +1 -1
  92. package/js/src/pro/phemex.js +1 -1
  93. package/js/src/pro/poloniexfutures.js +6 -2
  94. package/js/src/pro/upbit.js +1 -1
  95. package/js/src/pro/vertex.js +2 -2
  96. package/js/src/pro/whitebit.js +1 -1
  97. package/js/src/pro/woo.js +1 -1
  98. package/js/src/pro/woofipro.js +1 -1
  99. package/js/src/tradeogre.js +1 -1
  100. package/js/src/woo.d.ts +5 -1
  101. package/js/src/woo.js +313 -81
  102. package/js/src/xt.d.ts +3 -3
  103. package/js/src/xt.js +1 -1
  104. package/package.json +1 -1
@@ -6314,6 +6314,7 @@ class bybit extends bybit$1 {
6314
6314
  * @param {string} [params.settleCoin] Settle coin. Supports linear, inverse & option
6315
6315
  * @returns {object[]} a list of [position structure]{@link https://docs.ccxt.com/#/?id=position-structure}
6316
6316
  */
6317
+ await this.loadMarkets();
6317
6318
  let symbol = undefined;
6318
6319
  if ((symbols !== undefined) && Array.isArray(symbols)) {
6319
6320
  const symbolsLength = symbols.length;
@@ -6329,7 +6330,6 @@ class bybit extends bybit$1 {
6329
6330
  symbol = symbols;
6330
6331
  symbols = [this.symbol(symbol)];
6331
6332
  }
6332
- await this.loadMarkets();
6333
6333
  const [enableUnifiedMargin, enableUnifiedAccount] = await this.isUnifiedEnabled();
6334
6334
  const isUnifiedAccount = (enableUnifiedMargin || enableUnifiedAccount);
6335
6335
  const request = {};
@@ -161,6 +161,9 @@ class cryptocom extends cryptocom$1 {
161
161
  'public/get-expired-settlement-price': 10 / 3,
162
162
  'public/get-insurance': 1,
163
163
  },
164
+ 'post': {
165
+ 'public/staking/get-conversion-rate': 2,
166
+ },
164
167
  },
165
168
  'private': {
166
169
  'post': {
@@ -190,6 +193,16 @@ class cryptocom extends cryptocom$1 {
190
193
  'private/get-accounts': 10 / 3,
191
194
  'private/get-withdrawal-history': 10 / 3,
192
195
  'private/get-deposit-history': 10 / 3,
196
+ 'private/staking/stake': 2,
197
+ 'private/staking/unstake': 2,
198
+ 'private/staking/get-staking-position': 2,
199
+ 'private/staking/get-staking-instruments': 2,
200
+ 'private/staking/get-open-stake': 2,
201
+ 'private/staking/get-stake-history': 2,
202
+ 'private/staking/get-reward-history': 2,
203
+ 'private/staking/convert': 2,
204
+ 'private/staking/get-open-convert': 2,
205
+ 'private/staking/get-convert-history': 2,
193
206
  },
194
207
  },
195
208
  },
@@ -815,6 +828,9 @@ class cryptocom extends cryptocom$1 {
815
828
  'timeframe': this.safeString(this.timeframes, timeframe, timeframe),
816
829
  };
817
830
  if (limit !== undefined) {
831
+ if (limit > 300) {
832
+ limit = 300;
833
+ }
818
834
  request['count'] = limit;
819
835
  }
820
836
  const now = this.microseconds();
@@ -822,9 +838,9 @@ class cryptocom extends cryptocom$1 {
822
838
  const until = this.safeInteger(params, 'until', now);
823
839
  params = this.omit(params, ['until']);
824
840
  if (since !== undefined) {
825
- request['start_ts'] = since;
841
+ request['start_ts'] = since - duration * 1000;
826
842
  if (limit !== undefined) {
827
- request['end_ts'] = this.sum(since, duration * (limit + 1) * 1000) - 1;
843
+ request['end_ts'] = this.sum(since, duration * limit * 1000);
828
844
  }
829
845
  else {
830
846
  request['end_ts'] = until;
@@ -4,6 +4,7 @@ var mercado$1 = require('./abstract/mercado.js');
4
4
  var errors = require('./base/errors.js');
5
5
  var number = require('./base/functions/number.js');
6
6
  var sha512 = require('./static_dependencies/noble-hashes/sha512.js');
7
+ var Precise = require('./base/Precise.js');
7
8
 
8
9
  // ---------------------------------------------------------------------------
9
10
  // ---------------------------------------------------------------------------
@@ -460,7 +461,10 @@ class mercado extends mercado$1 {
460
461
  if (price === undefined) {
461
462
  throw new errors.InvalidOrder(this.id + ' createOrder() requires the price argument with market buy orders to calculate total order cost (amount to spend), where cost = amount * price. Supply a price argument to createOrder() call if you want the cost to be calculated for you from price and amount');
462
463
  }
463
- request['cost'] = this.priceToPrecision(market['symbol'], amount * price);
464
+ const amountString = this.numberToString(amount);
465
+ const priceString = this.numberToString(price);
466
+ const cost = this.parseToNumeric(Precise["default"].stringMul(amountString, priceString));
467
+ request['cost'] = this.priceToPrecision(market['symbol'], cost);
464
468
  }
465
469
  else {
466
470
  request['quantity'] = this.amountToPrecision(market['symbol'], amount);
@@ -263,7 +263,7 @@ class alpaca extends alpaca$1 {
263
263
  * @param {int} [since] the earliest time in ms to fetch orders for
264
264
  * @param {int} [limit] the maximum number of trade structures to retrieve
265
265
  * @param {object} [params] extra parameters specific to the exchange API endpoint
266
- * @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure
266
+ * @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure}
267
267
  */
268
268
  const url = this.urls['api']['ws']['crypto'];
269
269
  await this.authenticate(url);
@@ -316,7 +316,7 @@ class alpaca extends alpaca$1 {
316
316
  * @param {int} [limit] the maximum number of trade structures to retrieve
317
317
  * @param {object} [params] extra parameters specific to the exchange API endpoint
318
318
  * @param {boolean} [params.unifiedMargin] use unified margin account
319
- * @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure
319
+ * @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure}
320
320
  */
321
321
  const url = this.urls['api']['ws']['trading'];
322
322
  await this.authenticate(url);
@@ -347,7 +347,7 @@ class alpaca extends alpaca$1 {
347
347
  * @param {int} [since] the earliest time in ms to fetch orders for
348
348
  * @param {int} [limit] the maximum number of order structures to retrieve
349
349
  * @param {object} [params] extra parameters specific to the exchange API endpoint
350
- * @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure
350
+ * @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
351
351
  */
352
352
  const url = this.urls['api']['ws']['trading'];
353
353
  await this.authenticate(url);
@@ -24,7 +24,7 @@ class binance extends binance$1 {
24
24
  'watchBidsAsks': true,
25
25
  'watchMyTrades': true,
26
26
  'watchOHLCV': true,
27
- 'watchOHLCVForSymbols': false,
27
+ 'watchOHLCVForSymbols': true,
28
28
  'watchOrderBook': true,
29
29
  'watchOrderBookForSymbols': true,
30
30
  'watchOrders': true,
@@ -127,6 +127,7 @@ class binance extends binance$1 {
127
127
  },
128
128
  'watchOrderBook': {
129
129
  'maxRetries': 3,
130
+ 'checksum': true,
130
131
  },
131
132
  'watchBalance': {
132
133
  'fetchBalanceSnapshot': false,
@@ -711,10 +712,8 @@ class binance extends binance$1 {
711
712
  client.resolve(orderbook, messageHash);
712
713
  }
713
714
  async fetchOrderBookSnapshot(client, message, subscription) {
714
- const name = this.safeString(subscription, 'name');
715
715
  const symbol = this.safeString(subscription, 'symbol');
716
- const market = this.market(symbol);
717
- const messageHash = market['lowercaseId'] + '@' + name;
716
+ const messageHash = 'orderbook::' + symbol;
718
717
  try {
719
718
  const defaultLimit = this.safeInteger(this.options, 'watchOrderBookLimit', 1000);
720
719
  const type = this.safeValue(subscription, 'type');
@@ -856,10 +855,10 @@ class binance extends binance$1 {
856
855
  }
857
856
  }
858
857
  else {
859
- const checksum = this.safeBool(this.options, 'checksum', true);
858
+ const checksum = this.handleOption('watchOrderBook', 'checksum', true);
860
859
  if (checksum) {
861
860
  // todo: client.reject from handleOrderBookMessage properly
862
- throw new errors.InvalidNonce(this.id + ' handleOrderBook received an out-of-order nonce');
861
+ throw new errors.ChecksumError(this.id + ' ' + this.orderbookChecksumMessage(symbol));
863
862
  }
864
863
  }
865
864
  }
@@ -877,10 +876,10 @@ class binance extends binance$1 {
877
876
  }
878
877
  }
879
878
  else {
880
- const checksum = this.safeBool(this.options, 'checksum', true);
879
+ const checksum = this.handleOption('watchOrderBook', 'checksum', true);
881
880
  if (checksum) {
882
881
  // todo: client.reject from handleOrderBookMessage properly
883
- throw new errors.InvalidNonce(this.id + ' handleOrderBook received an out-of-order nonce');
882
+ throw new errors.ChecksumError(this.id + ' ' + this.orderbookChecksumMessage(symbol));
884
883
  }
885
884
  }
886
885
  }
@@ -1190,40 +1189,63 @@ class binance extends binance$1 {
1190
1189
  * @param {object} [params] extra parameters specific to the exchange API endpoint
1191
1190
  * @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
1192
1191
  */
1192
+ params['callerMethodName'] = 'watchOHLCV';
1193
+ const result = await this.watchOHLCVForSymbols([[symbol, timeframe]], since, limit, params);
1194
+ return result[symbol][timeframe];
1195
+ }
1196
+ async watchOHLCVForSymbols(symbolsAndTimeframes, since = undefined, limit = undefined, params = {}) {
1197
+ /**
1198
+ * @method
1199
+ * @name binance#watchOHLCVForSymbols
1200
+ * @description watches historical candlestick data containing the open, high, low, and close price, and the volume of a market
1201
+ * @param {string[][]} symbolsAndTimeframes array of arrays containing unified symbols and timeframes to fetch OHLCV data for, example [['BTC/USDT', '1m'], ['LTC/USDT', '5m']]
1202
+ * @param {int} [since] timestamp in ms of the earliest candle to fetch
1203
+ * @param {int} [limit] the maximum amount of candles to fetch
1204
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1205
+ * @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
1206
+ */
1193
1207
  await this.loadMarkets();
1194
- const market = this.market(symbol);
1195
- let marketId = market['lowercaseId'];
1196
- const interval = this.safeString(this.timeframes, timeframe, timeframe);
1197
- const options = this.safeValue(this.options, 'watchOHLCV', {});
1198
- const nameOption = this.safeString(options, 'name', 'kline');
1199
- const name = this.safeString(params, 'name', nameOption);
1200
- if (name === 'indexPriceKline') {
1201
- marketId = marketId.replace('_perp', '');
1202
- // weird behavior for index price kline we can't use the perp suffix
1203
- }
1204
- params = this.omit(params, 'name');
1205
- const messageHash = marketId + '@' + name + '_' + interval;
1206
- let type = market['type'];
1207
- if (market['contract']) {
1208
- type = market['linear'] ? 'future' : 'delivery';
1209
- }
1210
- const url = this.urls['api']['ws'][type] + '/' + this.stream(type, messageHash);
1208
+ let klineType = undefined;
1209
+ [klineType, params] = this.handleParamString2(params, 'channel', 'name', 'kline');
1210
+ const symbols = this.getListFromObjectValues(symbolsAndTimeframes, 0);
1211
+ const marketSymbols = this.marketSymbols(symbols, undefined, false, false, true);
1212
+ const firstMarket = this.market(marketSymbols[0]);
1213
+ let type = firstMarket['type'];
1214
+ if (firstMarket['contract']) {
1215
+ type = firstMarket['linear'] ? 'future' : 'delivery';
1216
+ }
1217
+ const rawHashes = [];
1218
+ const messageHashes = [];
1219
+ for (let i = 0; i < symbolsAndTimeframes.length; i++) {
1220
+ const symAndTf = symbolsAndTimeframes[i];
1221
+ const symbolString = symAndTf[0];
1222
+ const timeframeString = symAndTf[1];
1223
+ const interval = this.safeString(this.timeframes, timeframeString, timeframeString);
1224
+ const market = this.market(symbolString);
1225
+ let marketId = market['lowercaseId'];
1226
+ if (klineType === 'indexPriceKline') {
1227
+ // weird behavior for index price kline we can't use the perp suffix
1228
+ marketId = marketId.replace('_perp', '');
1229
+ }
1230
+ rawHashes.push(marketId + '@' + klineType + '_' + interval);
1231
+ messageHashes.push('ohlcv::' + symbolString + '::' + timeframeString);
1232
+ }
1233
+ const url = this.urls['api']['ws'][type] + '/' + this.stream(type, 'multipleOHLCV');
1211
1234
  const requestId = this.requestId(url);
1212
1235
  const request = {
1213
1236
  'method': 'SUBSCRIBE',
1214
- 'params': [
1215
- messageHash,
1216
- ],
1237
+ 'params': rawHashes,
1217
1238
  'id': requestId,
1218
1239
  };
1219
1240
  const subscribe = {
1220
1241
  'id': requestId,
1221
1242
  };
1222
- const ohlcv = await this.watch(url, messageHash, this.extend(request, params), messageHash, subscribe);
1243
+ const [symbol, timeframe, candles] = await this.watchMultiple(url, messageHashes, this.extend(request, params), messageHashes, subscribe);
1223
1244
  if (this.newUpdates) {
1224
- limit = ohlcv.getLimit(symbol, limit);
1245
+ limit = candles.getLimit(symbol, limit);
1225
1246
  }
1226
- return this.filterBySinceLimit(ohlcv, since, limit, 0, true);
1247
+ const filtered = this.filterBySinceLimit(candles, since, limit, 0, true);
1248
+ return this.createOHLCVObject(symbol, timeframe, filtered);
1227
1249
  }
1228
1250
  handleOHLCV(client, message) {
1229
1251
  //
@@ -1264,11 +1286,9 @@ class binance extends binance$1 {
1264
1286
  // indexPriceKline doesn't have the _PERP suffix
1265
1287
  marketId = this.safeString(message, 'ps');
1266
1288
  }
1267
- const lowercaseMarketId = marketId.toLowerCase();
1268
1289
  const interval = this.safeString(kline, 'i');
1269
1290
  // use a reverse lookup in a static map instead
1270
- const timeframe = this.findTimeframe(interval);
1271
- const messageHash = lowercaseMarketId + '@' + event + '_' + interval;
1291
+ const unifiedTimeframe = this.findTimeframe(interval);
1272
1292
  const parsed = [
1273
1293
  this.safeInteger(kline, 't'),
1274
1294
  this.safeFloat(kline, 'o'),
@@ -1280,15 +1300,17 @@ class binance extends binance$1 {
1280
1300
  const isSpot = ((client.url.indexOf('/stream') > -1) || (client.url.indexOf('/testnet.binance') > -1));
1281
1301
  const marketType = (isSpot) ? 'spot' : 'contract';
1282
1302
  const symbol = this.safeSymbol(marketId, undefined, undefined, marketType);
1303
+ const messageHash = 'ohlcv::' + symbol + '::' + unifiedTimeframe;
1283
1304
  this.ohlcvs[symbol] = this.safeValue(this.ohlcvs, symbol, {});
1284
- let stored = this.safeValue(this.ohlcvs[symbol], timeframe);
1305
+ let stored = this.safeValue(this.ohlcvs[symbol], unifiedTimeframe);
1285
1306
  if (stored === undefined) {
1286
1307
  const limit = this.safeInteger(this.options, 'OHLCVLimit', 1000);
1287
1308
  stored = new Cache.ArrayCacheByTimestamp(limit);
1288
- this.ohlcvs[symbol][timeframe] = stored;
1309
+ this.ohlcvs[symbol][unifiedTimeframe] = stored;
1289
1310
  }
1290
1311
  stored.append(parsed);
1291
- client.resolve(stored, messageHash);
1312
+ const resolveData = [symbol, unifiedTimeframe, stored];
1313
+ client.resolve(resolveData, messageHash);
1292
1314
  }
1293
1315
  async fetchTickerWs(symbol, params = {}) {
1294
1316
  /**
@@ -3553,7 +3575,7 @@ class binance extends binance$1 {
3553
3575
  * @param {int} [limit] the maximum number of order structures to retrieve
3554
3576
  * @param {object} [params] extra parameters specific to the exchange API endpoint
3555
3577
  * @param {boolean} [params.portfolioMargin] set to true if you would like to watch trades in a portfolio margin account
3556
- * @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure
3578
+ * @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure}
3557
3579
  */
3558
3580
  await this.loadMarkets();
3559
3581
  let type = undefined;
@@ -441,7 +441,7 @@ class bingx extends bingx$1 {
441
441
  * @param {int} [since] the earliest time in ms to fetch orders for
442
442
  * @param {int} [limit] the maximum number of order structures to retrieve
443
443
  * @param {object} [params] extra parameters specific to the exchange API endpoint
444
- * @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure
444
+ * @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
445
445
  */
446
446
  await this.loadMarkets();
447
447
  const market = this.market(symbol);
@@ -888,7 +888,7 @@ class bingx extends bingx$1 {
888
888
  * @param {int} [since] the earliest time in ms to trades orders for
889
889
  * @param {int} [limit] the maximum number of trades structures to retrieve
890
890
  * @param {object} [params] extra parameters specific to the exchange API endpoint
891
- * @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure
891
+ * @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure}
892
892
  */
893
893
  await this.loadMarkets();
894
894
  await this.authenticate();
@@ -34,9 +34,9 @@ class bitfinex2 extends bitfinex2$1 {
34
34
  'watchOrderBook': {
35
35
  'prec': 'P0',
36
36
  'freq': 'F0',
37
+ 'checksum': true,
37
38
  },
38
39
  'ordersLimit': 1000,
39
- 'checksum': true,
40
40
  },
41
41
  });
42
42
  }
@@ -210,7 +210,7 @@ class bitfinex2 extends bitfinex2$1 {
210
210
  * @param {int} [since] the earliest time in ms to fetch trades for
211
211
  * @param {int} [limit] the maximum number of trade structures to retrieve
212
212
  * @param {object} [params] extra parameters specific to the exchange API endpoint
213
- * @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure
213
+ * @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure}
214
214
  */
215
215
  await this.loadMarkets();
216
216
  let messageHash = 'myTrade';
@@ -681,10 +681,13 @@ class bitfinex2 extends bitfinex2$1 {
681
681
  const localChecksum = this.crc32(payload, true);
682
682
  const responseChecksum = this.safeInteger(message, 2);
683
683
  if (responseChecksum !== localChecksum) {
684
- const error = new errors.InvalidNonce(this.id + ' invalid checksum');
685
684
  delete client.subscriptions[messageHash];
686
685
  delete this.orderbooks[symbol];
687
- client.reject(error, messageHash);
686
+ const checksum = this.handleOption('watchOrderBook', 'checksum', true);
687
+ if (checksum) {
688
+ const error = new errors.ChecksumError(this.id + ' ' + this.orderbookChecksumMessage(symbol));
689
+ client.reject(error, messageHash);
690
+ }
688
691
  }
689
692
  }
690
693
  async watchBalance(params = {}) {
@@ -891,7 +894,7 @@ class bitfinex2 extends bitfinex2$1 {
891
894
  * @param {int} [since] the earliest time in ms to fetch orders for
892
895
  * @param {int} [limit] the maximum number of order structures to retrieve
893
896
  * @param {object} [params] extra parameters specific to the exchange API endpoint
894
- * @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure
897
+ * @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
895
898
  */
896
899
  await this.loadMarkets();
897
900
  let messageHash = 'orders';
@@ -62,6 +62,9 @@ class bitget extends bitget$1 {
62
62
  '1d': '1D',
63
63
  '1w': '1W',
64
64
  },
65
+ 'watchOrderBook': {
66
+ 'checksum': true,
67
+ },
65
68
  },
66
69
  'streaming': {
67
70
  'ping': this.ping,
@@ -559,9 +562,9 @@ class bitget extends bitget$1 {
559
562
  const calculatedChecksum = this.crc32(payload, true);
560
563
  const responseChecksum = this.safeInteger(rawOrderBook, 'checksum');
561
564
  if (calculatedChecksum !== responseChecksum) {
562
- const error = new errors.InvalidNonce(this.id + ' invalid checksum');
563
565
  delete client.subscriptions[messageHash];
564
566
  delete this.orderbooks[symbol];
567
+ const error = new errors.ChecksumError(this.id + ' ' + this.orderbookChecksumMessage(symbol));
565
568
  client.reject(error, messageHash);
566
569
  return;
567
570
  }
@@ -969,7 +972,7 @@ class bitget extends bitget$1 {
969
972
  * @param {string} [params.marginMode] 'isolated' or 'cross' for watching spot margin orders]
970
973
  * @param {string} [params.type] 'spot', 'swap'
971
974
  * @param {string} [params.subType] 'linear', 'inverse'
972
- * @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure
975
+ * @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
973
976
  */
974
977
  await this.loadMarkets();
975
978
  let market = undefined;
@@ -1144,7 +1144,7 @@ class bitmex extends bitmex$1 {
1144
1144
  * @param {int} [since] the earliest time in ms to fetch trades for
1145
1145
  * @param {int} [limit] the maximum number of trade structures to retrieve
1146
1146
  * @param {object} [params] extra parameters specific to the exchange API endpoint
1147
- * @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure
1147
+ * @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure}
1148
1148
  */
1149
1149
  await this.loadMarkets();
1150
1150
  await this.authenticate();
@@ -184,7 +184,7 @@ class bitopro extends bitopro$1 {
184
184
  * @param {int} [since] the earliest time in ms to fetch trades for
185
185
  * @param {int} [limit] the maximum number of trade structures to retrieve
186
186
  * @param {object} [params] extra parameters specific to the exchange API endpoint
187
- * @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure
187
+ * @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure}
188
188
  */
189
189
  this.checkRequiredCredentials();
190
190
  await this.loadMarkets();
@@ -500,7 +500,7 @@ class bitvavo extends bitvavo$1 {
500
500
  * @param {int} [since] the earliest time in ms to fetch trades for
501
501
  * @param {int} [limit] the maximum number of trade structures to retrieve
502
502
  * @param {object} [params] extra parameters specific to the exchange API endpoint
503
- * @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=ortradeder-structure
503
+ * @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure}
504
504
  */
505
505
  if (symbol === undefined) {
506
506
  throw new errors.ArgumentsRequired(this.id + ' watchMyTrades() requires a symbol argument');
@@ -28,7 +28,7 @@ class bybit extends bybit$1 {
28
28
  'watchMyLiquidationsForSymbols': false,
29
29
  'watchMyTrades': true,
30
30
  'watchOHLCV': true,
31
- 'watchOHLCVForSymbols': false,
31
+ 'watchOHLCVForSymbols': true,
32
32
  'watchOrderBook': true,
33
33
  'watchOrderBookForSymbols': true,
34
34
  'watchOrders': true,
@@ -530,20 +530,46 @@ class bybit extends bybit$1 {
530
530
  * @param {object} [params] extra parameters specific to the exchange API endpoint
531
531
  * @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
532
532
  */
533
+ params['callerMethodName'] = 'watchOHLCV';
534
+ const result = await this.watchOHLCVForSymbols([[symbol, timeframe]], since, limit, params);
535
+ return result[symbol][timeframe];
536
+ }
537
+ async watchOHLCVForSymbols(symbolsAndTimeframes, since = undefined, limit = undefined, params = {}) {
538
+ /**
539
+ * @method
540
+ * @name bybit#watchOHLCVForSymbols
541
+ * @description watches historical candlestick data containing the open, high, low, and close price, and the volume of a market
542
+ * @see https://bybit-exchange.github.io/docs/v5/websocket/public/kline
543
+ * @see https://bybit-exchange.github.io/docs/v5/websocket/public/etp-kline
544
+ * @param {string[][]} symbolsAndTimeframes array of arrays containing unified symbols and timeframes to fetch OHLCV data for, example [['BTC/USDT', '1m'], ['LTC/USDT', '5m']]
545
+ * @param {int} [since] timestamp in ms of the earliest candle to fetch
546
+ * @param {int} [limit] the maximum amount of candles to fetch
547
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
548
+ * @returns {object} A list of candles ordered as timestamp, open, high, low, close, volume
549
+ */
533
550
  await this.loadMarkets();
534
- const market = this.market(symbol);
535
- symbol = market['symbol'];
536
- const url = await this.getUrlByMarketType(symbol, false, 'watchOHLCV', params);
537
- params = this.cleanParams(params);
538
- let ohlcv = undefined;
539
- const timeframeId = this.safeString(this.timeframes, timeframe, timeframe);
540
- const topics = ['kline.' + timeframeId + '.' + market['id']];
541
- const messageHash = 'kline' + ':' + timeframeId + ':' + symbol;
542
- ohlcv = await this.watchTopics(url, [messageHash], topics, params);
551
+ const symbols = this.getListFromObjectValues(symbolsAndTimeframes, 0);
552
+ const marketSymbols = this.marketSymbols(symbols, undefined, false, true, true);
553
+ const firstSymbol = marketSymbols[0];
554
+ const url = await this.getUrlByMarketType(firstSymbol, false, 'watchOHLCVForSymbols', params);
555
+ const rawHashes = [];
556
+ const messageHashes = [];
557
+ for (let i = 0; i < symbolsAndTimeframes.length; i++) {
558
+ const data = symbolsAndTimeframes[i];
559
+ let symbolString = this.safeString(data, 0);
560
+ const market = this.market(symbolString);
561
+ symbolString = market['symbol'];
562
+ const unfiedTimeframe = this.safeString(data, 1);
563
+ const timeframeId = this.safeString(this.timeframes, unfiedTimeframe, unfiedTimeframe);
564
+ rawHashes.push('kline.' + timeframeId + '.' + market['id']);
565
+ messageHashes.push('ohlcv::' + symbolString + '::' + unfiedTimeframe);
566
+ }
567
+ const [symbol, timeframe, stored] = await this.watchTopics(url, messageHashes, rawHashes, params);
543
568
  if (this.newUpdates) {
544
- limit = ohlcv.getLimit(symbol, limit);
569
+ limit = stored.getLimit(symbol, limit);
545
570
  }
546
- return this.filterBySinceLimit(ohlcv, since, limit, 0, true);
571
+ const filtered = this.filterBySinceLimit(stored, since, limit, 0, true);
572
+ return this.createOHLCVObject(symbol, timeframe, filtered);
547
573
  }
548
574
  handleOHLCV(client, message) {
549
575
  //
@@ -583,18 +609,18 @@ class bybit extends bybit$1 {
583
609
  if (ohlcvsByTimeframe === undefined) {
584
610
  this.ohlcvs[symbol] = {};
585
611
  }
586
- let stored = this.safeValue(ohlcvsByTimeframe, timeframe);
587
- if (stored === undefined) {
612
+ if (this.safeValue(ohlcvsByTimeframe, timeframe) === undefined) {
588
613
  const limit = this.safeInteger(this.options, 'OHLCVLimit', 1000);
589
- stored = new Cache.ArrayCacheByTimestamp(limit);
590
- this.ohlcvs[symbol][timeframe] = stored;
614
+ this.ohlcvs[symbol][timeframe] = new Cache.ArrayCacheByTimestamp(limit);
591
615
  }
616
+ const stored = this.ohlcvs[symbol][timeframe];
592
617
  for (let i = 0; i < data.length; i++) {
593
618
  const parsed = this.parseWsOHLCV(data[i]);
594
619
  stored.append(parsed);
595
620
  }
596
- const messageHash = 'kline' + ':' + timeframeId + ':' + symbol;
597
- client.resolve(stored, messageHash);
621
+ const messageHash = 'ohlcv::' + symbol + '::' + timeframe;
622
+ const resolveData = [symbol, timeframe, stored];
623
+ client.resolve(resolveData, messageHash);
598
624
  }
599
625
  parseWsOHLCV(ohlcv, market = undefined) {
600
626
  //
@@ -760,7 +786,7 @@ class bybit extends bybit$1 {
760
786
  * @param {int} [since] the earliest time in ms to fetch trades for
761
787
  * @param {int} [limit] the maximum number of trade structures to retrieve
762
788
  * @param {object} [params] extra parameters specific to the exchange API endpoint
763
- * @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure
789
+ * @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure}
764
790
  */
765
791
  return await this.watchTradesForSymbols([symbol], since, limit, params);
766
792
  }
@@ -937,7 +963,7 @@ class bybit extends bybit$1 {
937
963
  * @param {int} [limit] the maximum number of order structures to retrieve
938
964
  * @param {object} [params] extra parameters specific to the exchange API endpoint
939
965
  * @param {boolean} [params.unifiedMargin] use unified margin account
940
- * @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure
966
+ * @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
941
967
  */
942
968
  const method = 'watchMyTrades';
943
969
  let messageHash = 'myTrades';
@@ -1254,7 +1280,7 @@ class bybit extends bybit$1 {
1254
1280
  const rawLiquidation = this.safeDict(message, 'data', {});
1255
1281
  const marketId = this.safeString(rawLiquidation, 'symbol');
1256
1282
  const market = this.safeMarket(marketId, undefined, '', 'contract');
1257
- const symbol = this.safeSymbol(marketId);
1283
+ const symbol = market['symbol'];
1258
1284
  const liquidation = this.parseWsLiquidation(rawLiquidation, market);
1259
1285
  let liquidations = this.safeValue(this.liquidations, symbol);
1260
1286
  if (liquidations === undefined) {
@@ -1281,7 +1307,7 @@ class bybit extends bybit$1 {
1281
1307
  const timestamp = this.safeInteger(liquidation, 'updatedTime');
1282
1308
  return this.safeLiquidation({
1283
1309
  'info': liquidation,
1284
- 'symbol': this.safeSymbol(marketId, market),
1310
+ 'symbol': market['symbol'],
1285
1311
  'contracts': this.safeNumber(liquidation, 'size'),
1286
1312
  'contractSize': this.safeNumber(market, 'contractSize'),
1287
1313
  'price': this.safeNumber(liquidation, 'price'),
@@ -1301,7 +1327,7 @@ class bybit extends bybit$1 {
1301
1327
  * @param {int} [since] the earliest time in ms to fetch orders for
1302
1328
  * @param {int} [limit] the maximum number of order structures to retrieve
1303
1329
  * @param {object} [params] extra parameters specific to the exchange API endpoint
1304
- * @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure
1330
+ * @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
1305
1331
  */
1306
1332
  await this.loadMarkets();
1307
1333
  const method = 'watchOrders';
@@ -198,7 +198,7 @@ class coinbaseexchange extends coinbaseexchange$1 {
198
198
  * @param {int} [since] the earliest time in ms to fetch trades for
199
199
  * @param {int} [limit] the maximum number of trade structures to retrieve
200
200
  * @param {object} [params] extra parameters specific to the exchange API endpoint
201
- * @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure
201
+ * @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure}
202
202
  */
203
203
  if (symbol === undefined) {
204
204
  throw new errors.ArgumentsRequired(this.id + ' watchMyTrades() requires a symbol argument');
@@ -223,7 +223,7 @@ class coinbaseexchange extends coinbaseexchange$1 {
223
223
  * @param {int} [since] the earliest time in ms to fetch trades for
224
224
  * @param {int} [limit] the maximum number of trade structures to retrieve
225
225
  * @param {object} [params] extra parameters specific to the exchange API endpoint
226
- * @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure
226
+ * @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure}
227
227
  */
228
228
  symbols = this.marketSymbols(symbols, undefined, false);
229
229
  await this.loadMarkets();
@@ -111,7 +111,7 @@ class coincheck extends coincheck$1 {
111
111
  * @param {int} [since] the earliest time in ms to fetch trades for
112
112
  * @param {int} [limit] the maximum number of trade structures to retrieve
113
113
  * @param {object} [params] extra parameters specific to the exchange API endpoint
114
- * @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure
114
+ * @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure}
115
115
  */
116
116
  await this.loadMarkets();
117
117
  const market = this.market(symbol);
@@ -254,7 +254,7 @@ class coinone extends coinone$1 {
254
254
  * @param {int} [since] the earliest time in ms to fetch trades for
255
255
  * @param {int} [limit] the maximum number of trade structures to retrieve
256
256
  * @param {object} [params] extra parameters specific to the exchange API endpoint
257
- * @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure
257
+ * @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure}
258
258
  */
259
259
  await this.loadMarkets();
260
260
  const market = this.market(symbol);
@@ -44,6 +44,9 @@ class cryptocom extends cryptocom$1 {
44
44
  'fetchPositionsSnapshot': true,
45
45
  'awaitPositionsSnapshot': true, // whether to wait for the positions snapshot before providing updates
46
46
  },
47
+ 'watchOrderBook': {
48
+ 'checksum': true,
49
+ },
47
50
  },
48
51
  'streaming': {},
49
52
  });
@@ -217,7 +220,10 @@ class cryptocom extends cryptocom$1 {
217
220
  const previousNonce = this.safeInteger(data, 'pu');
218
221
  const currentNonce = orderbook['nonce'];
219
222
  if (currentNonce !== previousNonce) {
220
- throw new errors.InvalidNonce(this.id + ' watchOrderBook() ' + symbol + ' ' + previousNonce + ' != ' + nonce);
223
+ const checksum = this.handleOption('watchOrderBook', 'checksum', true);
224
+ if (checksum) {
225
+ throw new errors.ChecksumError(this.id + ' ' + this.orderbookChecksumMessage(symbol));
226
+ }
221
227
  }
222
228
  }
223
229
  this.handleDeltas(orderbook['asks'], this.safeValue(books, 'asks', []));
@@ -327,7 +333,7 @@ class cryptocom extends cryptocom$1 {
327
333
  * @param {int} [since] the earliest time in ms to fetch trades for
328
334
  * @param {int} [limit] the maximum number of trade structures to retrieve
329
335
  * @param {object} [params] extra parameters specific to the exchange API endpoint
330
- * @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure
336
+ * @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure}
331
337
  */
332
338
  await this.loadMarkets();
333
339
  let market = undefined;