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
package/js/src/bybit.js CHANGED
@@ -6317,6 +6317,7 @@ export default class bybit extends Exchange {
6317
6317
  * @param {string} [params.settleCoin] Settle coin. Supports linear, inverse & option
6318
6318
  * @returns {object[]} a list of [position structure]{@link https://docs.ccxt.com/#/?id=position-structure}
6319
6319
  */
6320
+ await this.loadMarkets();
6320
6321
  let symbol = undefined;
6321
6322
  if ((symbols !== undefined) && Array.isArray(symbols)) {
6322
6323
  const symbolsLength = symbols.length;
@@ -6332,7 +6333,6 @@ export default class bybit extends Exchange {
6332
6333
  symbol = symbols;
6333
6334
  symbols = [this.symbol(symbol)];
6334
6335
  }
6335
- await this.loadMarkets();
6336
6336
  const [enableUnifiedMargin, enableUnifiedAccount] = await this.isUnifiedEnabled();
6337
6337
  const isUnifiedAccount = (enableUnifiedMargin || enableUnifiedAccount);
6338
6338
  const request = {};
@@ -67,7 +67,7 @@ export default class coinbaseinternational extends Exchange {
67
67
  };
68
68
  };
69
69
  setMargin(symbol: string, amount: number, params?: {}): Promise<any>;
70
- fetchDepositsWithdrawals(code?: string, since?: Int, limit?: Int, params?: {}): Promise<Transaction[]>;
70
+ fetchDepositsWithdrawals(code?: Str, since?: Int, limit?: Int, params?: {}): Promise<Transaction[]>;
71
71
  fetchPosition(symbol: string, params?: {}): Promise<Position>;
72
72
  parsePosition(position: Dict, market?: Market): Position;
73
73
  fetchPositions(symbols?: Strings, params?: {}): Promise<Position[]>;
@@ -164,6 +164,9 @@ export default class cryptocom extends Exchange {
164
164
  'public/get-expired-settlement-price': 10 / 3,
165
165
  'public/get-insurance': 1,
166
166
  },
167
+ 'post': {
168
+ 'public/staking/get-conversion-rate': 2,
169
+ },
167
170
  },
168
171
  'private': {
169
172
  'post': {
@@ -193,6 +196,16 @@ export default class cryptocom extends Exchange {
193
196
  'private/get-accounts': 10 / 3,
194
197
  'private/get-withdrawal-history': 10 / 3,
195
198
  'private/get-deposit-history': 10 / 3,
199
+ 'private/staking/stake': 2,
200
+ 'private/staking/unstake': 2,
201
+ 'private/staking/get-staking-position': 2,
202
+ 'private/staking/get-staking-instruments': 2,
203
+ 'private/staking/get-open-stake': 2,
204
+ 'private/staking/get-stake-history': 2,
205
+ 'private/staking/get-reward-history': 2,
206
+ 'private/staking/convert': 2,
207
+ 'private/staking/get-open-convert': 2,
208
+ 'private/staking/get-convert-history': 2,
196
209
  },
197
210
  },
198
211
  },
@@ -818,6 +831,9 @@ export default class cryptocom extends Exchange {
818
831
  'timeframe': this.safeString(this.timeframes, timeframe, timeframe),
819
832
  };
820
833
  if (limit !== undefined) {
834
+ if (limit > 300) {
835
+ limit = 300;
836
+ }
821
837
  request['count'] = limit;
822
838
  }
823
839
  const now = this.microseconds();
@@ -825,9 +841,9 @@ export default class cryptocom extends Exchange {
825
841
  const until = this.safeInteger(params, 'until', now);
826
842
  params = this.omit(params, ['until']);
827
843
  if (since !== undefined) {
828
- request['start_ts'] = since;
844
+ request['start_ts'] = since - duration * 1000;
829
845
  if (limit !== undefined) {
830
- request['end_ts'] = this.sum(since, duration * (limit + 1) * 1000) - 1;
846
+ request['end_ts'] = this.sum(since, duration * limit * 1000);
831
847
  }
832
848
  else {
833
849
  request['end_ts'] = until;
package/js/src/mercado.js CHANGED
@@ -9,6 +9,7 @@ import Exchange from './abstract/mercado.js';
9
9
  import { ExchangeError, ArgumentsRequired, InvalidOrder } from './base/errors.js';
10
10
  import { TICK_SIZE } from './base/functions/number.js';
11
11
  import { sha512 } from './static_dependencies/noble-hashes/sha512.js';
12
+ import { Precise } from './base/Precise.js';
12
13
  // ---------------------------------------------------------------------------
13
14
  /**
14
15
  * @class mercado
@@ -463,7 +464,10 @@ export default class mercado extends Exchange {
463
464
  if (price === undefined) {
464
465
  throw new 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');
465
466
  }
466
- request['cost'] = this.priceToPrecision(market['symbol'], amount * price);
467
+ const amountString = this.numberToString(amount);
468
+ const priceString = this.numberToString(price);
469
+ const cost = this.parseToNumeric(Precise.stringMul(amountString, priceString));
470
+ request['cost'] = this.priceToPrecision(market['symbol'], cost);
467
471
  }
468
472
  else {
469
473
  request['quantity'] = this.amountToPrecision(market['symbol'], amount);
@@ -266,7 +266,7 @@ export default class alpaca extends alpacaRest {
266
266
  * @param {int} [since] the earliest time in ms to fetch orders for
267
267
  * @param {int} [limit] the maximum number of trade structures to retrieve
268
268
  * @param {object} [params] extra parameters specific to the exchange API endpoint
269
- * @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure
269
+ * @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure}
270
270
  */
271
271
  const url = this.urls['api']['ws']['crypto'];
272
272
  await this.authenticate(url);
@@ -319,7 +319,7 @@ export default class alpaca extends alpacaRest {
319
319
  * @param {int} [limit] the maximum number of trade structures to retrieve
320
320
  * @param {object} [params] extra parameters specific to the exchange API endpoint
321
321
  * @param {boolean} [params.unifiedMargin] use unified margin account
322
- * @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure
322
+ * @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure}
323
323
  */
324
324
  const url = this.urls['api']['ws']['trading'];
325
325
  await this.authenticate(url);
@@ -350,7 +350,7 @@ export default class alpaca extends alpacaRest {
350
350
  * @param {int} [since] the earliest time in ms to fetch orders for
351
351
  * @param {int} [limit] the maximum number of order structures to retrieve
352
352
  * @param {object} [params] extra parameters specific to the exchange API endpoint
353
- * @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure
353
+ * @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
354
354
  */
355
355
  const url = this.urls['api']['ws']['trading'];
356
356
  await this.authenticate(url);
@@ -28,6 +28,7 @@ export default class binance extends binanceRest {
28
28
  parseWsTrade(trade: any, market?: any): Trade;
29
29
  handleTrade(client: Client, message: any): void;
30
30
  watchOHLCV(symbol: string, timeframe?: string, since?: Int, limit?: Int, params?: {}): Promise<OHLCV[]>;
31
+ watchOHLCVForSymbols(symbolsAndTimeframes: string[][], since?: Int, limit?: Int, params?: {}): Promise<import("../base/types.js").Dictionary<import("../base/types.js").Dictionary<OHLCV[]>>>;
31
32
  handleOHLCV(client: Client, message: any): void;
32
33
  fetchTickerWs(symbol: string, params?: {}): Promise<Ticker>;
33
34
  fetchOHLCVWs(symbol: string, timeframe?: string, since?: Int, limit?: Int, params?: {}): Promise<OHLCV[]>;
@@ -7,7 +7,7 @@
7
7
  // ----------------------------------------------------------------------------
8
8
  import binanceRest from '../binance.js';
9
9
  import { Precise } from '../base/Precise.js';
10
- import { InvalidNonce, ArgumentsRequired, BadRequest, NotSupported } from '../base/errors.js';
10
+ import { ChecksumError, ArgumentsRequired, BadRequest, NotSupported } from '../base/errors.js';
11
11
  import { ArrayCache, ArrayCacheByTimestamp, ArrayCacheBySymbolById, ArrayCacheBySymbolBySide } from '../base/ws/Cache.js';
12
12
  import { sha256 } from '../static_dependencies/noble-hashes/sha256.js';
13
13
  import { rsa } from '../base/functions/rsa.js';
@@ -27,7 +27,7 @@ export default class binance extends binanceRest {
27
27
  'watchBidsAsks': true,
28
28
  'watchMyTrades': true,
29
29
  'watchOHLCV': true,
30
- 'watchOHLCVForSymbols': false,
30
+ 'watchOHLCVForSymbols': true,
31
31
  'watchOrderBook': true,
32
32
  'watchOrderBookForSymbols': true,
33
33
  'watchOrders': true,
@@ -130,6 +130,7 @@ export default class binance extends binanceRest {
130
130
  },
131
131
  'watchOrderBook': {
132
132
  'maxRetries': 3,
133
+ 'checksum': true,
133
134
  },
134
135
  'watchBalance': {
135
136
  'fetchBalanceSnapshot': false,
@@ -714,10 +715,8 @@ export default class binance extends binanceRest {
714
715
  client.resolve(orderbook, messageHash);
715
716
  }
716
717
  async fetchOrderBookSnapshot(client, message, subscription) {
717
- const name = this.safeString(subscription, 'name');
718
718
  const symbol = this.safeString(subscription, 'symbol');
719
- const market = this.market(symbol);
720
- const messageHash = market['lowercaseId'] + '@' + name;
719
+ const messageHash = 'orderbook::' + symbol;
721
720
  try {
722
721
  const defaultLimit = this.safeInteger(this.options, 'watchOrderBookLimit', 1000);
723
722
  const type = this.safeValue(subscription, 'type');
@@ -859,10 +858,10 @@ export default class binance extends binanceRest {
859
858
  }
860
859
  }
861
860
  else {
862
- const checksum = this.safeBool(this.options, 'checksum', true);
861
+ const checksum = this.handleOption('watchOrderBook', 'checksum', true);
863
862
  if (checksum) {
864
863
  // todo: client.reject from handleOrderBookMessage properly
865
- throw new InvalidNonce(this.id + ' handleOrderBook received an out-of-order nonce');
864
+ throw new ChecksumError(this.id + ' ' + this.orderbookChecksumMessage(symbol));
866
865
  }
867
866
  }
868
867
  }
@@ -880,10 +879,10 @@ export default class binance extends binanceRest {
880
879
  }
881
880
  }
882
881
  else {
883
- const checksum = this.safeBool(this.options, 'checksum', true);
882
+ const checksum = this.handleOption('watchOrderBook', 'checksum', true);
884
883
  if (checksum) {
885
884
  // todo: client.reject from handleOrderBookMessage properly
886
- throw new InvalidNonce(this.id + ' handleOrderBook received an out-of-order nonce');
885
+ throw new ChecksumError(this.id + ' ' + this.orderbookChecksumMessage(symbol));
887
886
  }
888
887
  }
889
888
  }
@@ -1193,40 +1192,63 @@ export default class binance extends binanceRest {
1193
1192
  * @param {object} [params] extra parameters specific to the exchange API endpoint
1194
1193
  * @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
1195
1194
  */
1195
+ params['callerMethodName'] = 'watchOHLCV';
1196
+ const result = await this.watchOHLCVForSymbols([[symbol, timeframe]], since, limit, params);
1197
+ return result[symbol][timeframe];
1198
+ }
1199
+ async watchOHLCVForSymbols(symbolsAndTimeframes, since = undefined, limit = undefined, params = {}) {
1200
+ /**
1201
+ * @method
1202
+ * @name binance#watchOHLCVForSymbols
1203
+ * @description watches historical candlestick data containing the open, high, low, and close price, and the volume of a market
1204
+ * @param {string[][]} symbolsAndTimeframes array of arrays containing unified symbols and timeframes to fetch OHLCV data for, example [['BTC/USDT', '1m'], ['LTC/USDT', '5m']]
1205
+ * @param {int} [since] timestamp in ms of the earliest candle to fetch
1206
+ * @param {int} [limit] the maximum amount of candles to fetch
1207
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1208
+ * @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
1209
+ */
1196
1210
  await this.loadMarkets();
1197
- const market = this.market(symbol);
1198
- let marketId = market['lowercaseId'];
1199
- const interval = this.safeString(this.timeframes, timeframe, timeframe);
1200
- const options = this.safeValue(this.options, 'watchOHLCV', {});
1201
- const nameOption = this.safeString(options, 'name', 'kline');
1202
- const name = this.safeString(params, 'name', nameOption);
1203
- if (name === 'indexPriceKline') {
1204
- marketId = marketId.replace('_perp', '');
1205
- // weird behavior for index price kline we can't use the perp suffix
1206
- }
1207
- params = this.omit(params, 'name');
1208
- const messageHash = marketId + '@' + name + '_' + interval;
1209
- let type = market['type'];
1210
- if (market['contract']) {
1211
- type = market['linear'] ? 'future' : 'delivery';
1212
- }
1213
- const url = this.urls['api']['ws'][type] + '/' + this.stream(type, messageHash);
1211
+ let klineType = undefined;
1212
+ [klineType, params] = this.handleParamString2(params, 'channel', 'name', 'kline');
1213
+ const symbols = this.getListFromObjectValues(symbolsAndTimeframes, 0);
1214
+ const marketSymbols = this.marketSymbols(symbols, undefined, false, false, true);
1215
+ const firstMarket = this.market(marketSymbols[0]);
1216
+ let type = firstMarket['type'];
1217
+ if (firstMarket['contract']) {
1218
+ type = firstMarket['linear'] ? 'future' : 'delivery';
1219
+ }
1220
+ const rawHashes = [];
1221
+ const messageHashes = [];
1222
+ for (let i = 0; i < symbolsAndTimeframes.length; i++) {
1223
+ const symAndTf = symbolsAndTimeframes[i];
1224
+ const symbolString = symAndTf[0];
1225
+ const timeframeString = symAndTf[1];
1226
+ const interval = this.safeString(this.timeframes, timeframeString, timeframeString);
1227
+ const market = this.market(symbolString);
1228
+ let marketId = market['lowercaseId'];
1229
+ if (klineType === 'indexPriceKline') {
1230
+ // weird behavior for index price kline we can't use the perp suffix
1231
+ marketId = marketId.replace('_perp', '');
1232
+ }
1233
+ rawHashes.push(marketId + '@' + klineType + '_' + interval);
1234
+ messageHashes.push('ohlcv::' + symbolString + '::' + timeframeString);
1235
+ }
1236
+ const url = this.urls['api']['ws'][type] + '/' + this.stream(type, 'multipleOHLCV');
1214
1237
  const requestId = this.requestId(url);
1215
1238
  const request = {
1216
1239
  'method': 'SUBSCRIBE',
1217
- 'params': [
1218
- messageHash,
1219
- ],
1240
+ 'params': rawHashes,
1220
1241
  'id': requestId,
1221
1242
  };
1222
1243
  const subscribe = {
1223
1244
  'id': requestId,
1224
1245
  };
1225
- const ohlcv = await this.watch(url, messageHash, this.extend(request, params), messageHash, subscribe);
1246
+ const [symbol, timeframe, candles] = await this.watchMultiple(url, messageHashes, this.extend(request, params), messageHashes, subscribe);
1226
1247
  if (this.newUpdates) {
1227
- limit = ohlcv.getLimit(symbol, limit);
1248
+ limit = candles.getLimit(symbol, limit);
1228
1249
  }
1229
- return this.filterBySinceLimit(ohlcv, since, limit, 0, true);
1250
+ const filtered = this.filterBySinceLimit(candles, since, limit, 0, true);
1251
+ return this.createOHLCVObject(symbol, timeframe, filtered);
1230
1252
  }
1231
1253
  handleOHLCV(client, message) {
1232
1254
  //
@@ -1267,11 +1289,9 @@ export default class binance extends binanceRest {
1267
1289
  // indexPriceKline doesn't have the _PERP suffix
1268
1290
  marketId = this.safeString(message, 'ps');
1269
1291
  }
1270
- const lowercaseMarketId = marketId.toLowerCase();
1271
1292
  const interval = this.safeString(kline, 'i');
1272
1293
  // use a reverse lookup in a static map instead
1273
- const timeframe = this.findTimeframe(interval);
1274
- const messageHash = lowercaseMarketId + '@' + event + '_' + interval;
1294
+ const unifiedTimeframe = this.findTimeframe(interval);
1275
1295
  const parsed = [
1276
1296
  this.safeInteger(kline, 't'),
1277
1297
  this.safeFloat(kline, 'o'),
@@ -1283,15 +1303,17 @@ export default class binance extends binanceRest {
1283
1303
  const isSpot = ((client.url.indexOf('/stream') > -1) || (client.url.indexOf('/testnet.binance') > -1));
1284
1304
  const marketType = (isSpot) ? 'spot' : 'contract';
1285
1305
  const symbol = this.safeSymbol(marketId, undefined, undefined, marketType);
1306
+ const messageHash = 'ohlcv::' + symbol + '::' + unifiedTimeframe;
1286
1307
  this.ohlcvs[symbol] = this.safeValue(this.ohlcvs, symbol, {});
1287
- let stored = this.safeValue(this.ohlcvs[symbol], timeframe);
1308
+ let stored = this.safeValue(this.ohlcvs[symbol], unifiedTimeframe);
1288
1309
  if (stored === undefined) {
1289
1310
  const limit = this.safeInteger(this.options, 'OHLCVLimit', 1000);
1290
1311
  stored = new ArrayCacheByTimestamp(limit);
1291
- this.ohlcvs[symbol][timeframe] = stored;
1312
+ this.ohlcvs[symbol][unifiedTimeframe] = stored;
1292
1313
  }
1293
1314
  stored.append(parsed);
1294
- client.resolve(stored, messageHash);
1315
+ const resolveData = [symbol, unifiedTimeframe, stored];
1316
+ client.resolve(resolveData, messageHash);
1295
1317
  }
1296
1318
  async fetchTickerWs(symbol, params = {}) {
1297
1319
  /**
@@ -3556,7 +3578,7 @@ export default class binance extends binanceRest {
3556
3578
  * @param {int} [limit] the maximum number of order structures to retrieve
3557
3579
  * @param {object} [params] extra parameters specific to the exchange API endpoint
3558
3580
  * @param {boolean} [params.portfolioMargin] set to true if you would like to watch trades in a portfolio margin account
3559
- * @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure
3581
+ * @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure}
3560
3582
  */
3561
3583
  await this.loadMarkets();
3562
3584
  let type = undefined;
@@ -444,7 +444,7 @@ export default class bingx extends bingxRest {
444
444
  * @param {int} [since] the earliest time in ms to fetch orders for
445
445
  * @param {int} [limit] the maximum number of order structures to retrieve
446
446
  * @param {object} [params] extra parameters specific to the exchange API endpoint
447
- * @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure
447
+ * @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
448
448
  */
449
449
  await this.loadMarkets();
450
450
  const market = this.market(symbol);
@@ -891,7 +891,7 @@ export default class bingx extends bingxRest {
891
891
  * @param {int} [since] the earliest time in ms to trades orders for
892
892
  * @param {int} [limit] the maximum number of trades structures to retrieve
893
893
  * @param {object} [params] extra parameters specific to the exchange API endpoint
894
- * @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure
894
+ * @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure}
895
895
  */
896
896
  await this.loadMarkets();
897
897
  await this.authenticate();
@@ -7,7 +7,7 @@
7
7
  // ---------------------------------------------------------------------------
8
8
  import bitfinex2Rest from '../bitfinex2.js';
9
9
  import { Precise } from '../base/Precise.js';
10
- import { ExchangeError, AuthenticationError, InvalidNonce } from '../base/errors.js';
10
+ import { ExchangeError, AuthenticationError, ChecksumError } from '../base/errors.js';
11
11
  import { ArrayCache, ArrayCacheBySymbolById, ArrayCacheByTimestamp } from '../base/ws/Cache.js';
12
12
  import { sha384 } from '../static_dependencies/noble-hashes/sha512.js';
13
13
  // ---------------------------------------------------------------------------
@@ -37,9 +37,9 @@ export default class bitfinex2 extends bitfinex2Rest {
37
37
  'watchOrderBook': {
38
38
  'prec': 'P0',
39
39
  'freq': 'F0',
40
+ 'checksum': true,
40
41
  },
41
42
  'ordersLimit': 1000,
42
- 'checksum': true,
43
43
  },
44
44
  });
45
45
  }
@@ -213,7 +213,7 @@ export default class bitfinex2 extends bitfinex2Rest {
213
213
  * @param {int} [since] the earliest time in ms to fetch trades for
214
214
  * @param {int} [limit] the maximum number of trade structures to retrieve
215
215
  * @param {object} [params] extra parameters specific to the exchange API endpoint
216
- * @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure
216
+ * @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure}
217
217
  */
218
218
  await this.loadMarkets();
219
219
  let messageHash = 'myTrade';
@@ -684,10 +684,13 @@ export default class bitfinex2 extends bitfinex2Rest {
684
684
  const localChecksum = this.crc32(payload, true);
685
685
  const responseChecksum = this.safeInteger(message, 2);
686
686
  if (responseChecksum !== localChecksum) {
687
- const error = new InvalidNonce(this.id + ' invalid checksum');
688
687
  delete client.subscriptions[messageHash];
689
688
  delete this.orderbooks[symbol];
690
- client.reject(error, messageHash);
689
+ const checksum = this.handleOption('watchOrderBook', 'checksum', true);
690
+ if (checksum) {
691
+ const error = new ChecksumError(this.id + ' ' + this.orderbookChecksumMessage(symbol));
692
+ client.reject(error, messageHash);
693
+ }
691
694
  }
692
695
  }
693
696
  async watchBalance(params = {}) {
@@ -894,7 +897,7 @@ export default class bitfinex2 extends bitfinex2Rest {
894
897
  * @param {int} [since] the earliest time in ms to fetch orders for
895
898
  * @param {int} [limit] the maximum number of order structures to retrieve
896
899
  * @param {object} [params] extra parameters specific to the exchange API endpoint
897
- * @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure
900
+ * @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
898
901
  */
899
902
  await this.loadMarkets();
900
903
  let messageHash = 'orders';
@@ -6,7 +6,7 @@
6
6
 
7
7
  // ---------------------------------------------------------------------------
8
8
  import bitgetRest from '../bitget.js';
9
- import { AuthenticationError, BadRequest, ArgumentsRequired, InvalidNonce, ExchangeError, RateLimitExceeded } from '../base/errors.js';
9
+ import { AuthenticationError, BadRequest, ArgumentsRequired, ChecksumError, ExchangeError, RateLimitExceeded } from '../base/errors.js';
10
10
  import { Precise } from '../base/Precise.js';
11
11
  import { ArrayCache, ArrayCacheBySymbolById, ArrayCacheBySymbolBySide, ArrayCacheByTimestamp } from '../base/ws/Cache.js';
12
12
  import { sha256 } from '../static_dependencies/noble-hashes/sha256.js';
@@ -65,6 +65,9 @@ export default class bitget extends bitgetRest {
65
65
  '1d': '1D',
66
66
  '1w': '1W',
67
67
  },
68
+ 'watchOrderBook': {
69
+ 'checksum': true,
70
+ },
68
71
  },
69
72
  'streaming': {
70
73
  'ping': this.ping,
@@ -562,9 +565,9 @@ export default class bitget extends bitgetRest {
562
565
  const calculatedChecksum = this.crc32(payload, true);
563
566
  const responseChecksum = this.safeInteger(rawOrderBook, 'checksum');
564
567
  if (calculatedChecksum !== responseChecksum) {
565
- const error = new InvalidNonce(this.id + ' invalid checksum');
566
568
  delete client.subscriptions[messageHash];
567
569
  delete this.orderbooks[symbol];
570
+ const error = new ChecksumError(this.id + ' ' + this.orderbookChecksumMessage(symbol));
568
571
  client.reject(error, messageHash);
569
572
  return;
570
573
  }
@@ -972,7 +975,7 @@ export default class bitget extends bitgetRest {
972
975
  * @param {string} [params.marginMode] 'isolated' or 'cross' for watching spot margin orders]
973
976
  * @param {string} [params.type] 'spot', 'swap'
974
977
  * @param {string} [params.subType] 'linear', 'inverse'
975
- * @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure
978
+ * @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
976
979
  */
977
980
  await this.loadMarkets();
978
981
  let market = undefined;
@@ -1149,7 +1149,7 @@ export default class bitmex extends bitmexRest {
1149
1149
  * @param {int} [since] the earliest time in ms to fetch trades for
1150
1150
  * @param {int} [limit] the maximum number of trade structures to retrieve
1151
1151
  * @param {object} [params] extra parameters specific to the exchange API endpoint
1152
- * @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure
1152
+ * @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure}
1153
1153
  */
1154
1154
  await this.loadMarkets();
1155
1155
  await this.authenticate();
@@ -187,7 +187,7 @@ export default class bitopro extends bitoproRest {
187
187
  * @param {int} [since] the earliest time in ms to fetch trades for
188
188
  * @param {int} [limit] the maximum number of trade structures to retrieve
189
189
  * @param {object} [params] extra parameters specific to the exchange API endpoint
190
- * @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure
190
+ * @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure}
191
191
  */
192
192
  this.checkRequiredCredentials();
193
193
  await this.loadMarkets();
@@ -503,7 +503,7 @@ export default class bitvavo extends bitvavoRest {
503
503
  * @param {int} [since] the earliest time in ms to fetch trades for
504
504
  * @param {int} [limit] the maximum number of trade structures to retrieve
505
505
  * @param {object} [params] extra parameters specific to the exchange API endpoint
506
- * @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=ortradeder-structure
506
+ * @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure}
507
507
  */
508
508
  if (symbol === undefined) {
509
509
  throw new ArgumentsRequired(this.id + ' watchMyTrades() requires a symbol argument');
@@ -13,6 +13,7 @@ export default class bybit extends bybitRest {
13
13
  watchTickers(symbols?: Strings, params?: {}): Promise<Tickers>;
14
14
  handleTicker(client: Client, message: any): void;
15
15
  watchOHLCV(symbol: string, timeframe?: string, since?: Int, limit?: Int, params?: {}): Promise<OHLCV[]>;
16
+ watchOHLCVForSymbols(symbolsAndTimeframes: string[][], since?: Int, limit?: Int, params?: {}): Promise<import("../base/types.js").Dictionary<import("../base/types.js").Dictionary<OHLCV[]>>>;
16
17
  handleOHLCV(client: Client, message: any): void;
17
18
  parseWsOHLCV(ohlcv: any, market?: any): OHLCV;
18
19
  watchOrderBook(symbol: string, limit?: Int, params?: {}): Promise<OrderBook>;
@@ -31,7 +31,7 @@ export default class bybit extends bybitRest {
31
31
  'watchMyLiquidationsForSymbols': false,
32
32
  'watchMyTrades': true,
33
33
  'watchOHLCV': true,
34
- 'watchOHLCVForSymbols': false,
34
+ 'watchOHLCVForSymbols': true,
35
35
  'watchOrderBook': true,
36
36
  'watchOrderBookForSymbols': true,
37
37
  'watchOrders': true,
@@ -533,20 +533,46 @@ export default class bybit extends bybitRest {
533
533
  * @param {object} [params] extra parameters specific to the exchange API endpoint
534
534
  * @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
535
535
  */
536
+ params['callerMethodName'] = 'watchOHLCV';
537
+ const result = await this.watchOHLCVForSymbols([[symbol, timeframe]], since, limit, params);
538
+ return result[symbol][timeframe];
539
+ }
540
+ async watchOHLCVForSymbols(symbolsAndTimeframes, since = undefined, limit = undefined, params = {}) {
541
+ /**
542
+ * @method
543
+ * @name bybit#watchOHLCVForSymbols
544
+ * @description watches historical candlestick data containing the open, high, low, and close price, and the volume of a market
545
+ * @see https://bybit-exchange.github.io/docs/v5/websocket/public/kline
546
+ * @see https://bybit-exchange.github.io/docs/v5/websocket/public/etp-kline
547
+ * @param {string[][]} symbolsAndTimeframes array of arrays containing unified symbols and timeframes to fetch OHLCV data for, example [['BTC/USDT', '1m'], ['LTC/USDT', '5m']]
548
+ * @param {int} [since] timestamp in ms of the earliest candle to fetch
549
+ * @param {int} [limit] the maximum amount of candles to fetch
550
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
551
+ * @returns {object} A list of candles ordered as timestamp, open, high, low, close, volume
552
+ */
536
553
  await this.loadMarkets();
537
- const market = this.market(symbol);
538
- symbol = market['symbol'];
539
- const url = await this.getUrlByMarketType(symbol, false, 'watchOHLCV', params);
540
- params = this.cleanParams(params);
541
- let ohlcv = undefined;
542
- const timeframeId = this.safeString(this.timeframes, timeframe, timeframe);
543
- const topics = ['kline.' + timeframeId + '.' + market['id']];
544
- const messageHash = 'kline' + ':' + timeframeId + ':' + symbol;
545
- ohlcv = await this.watchTopics(url, [messageHash], topics, params);
554
+ const symbols = this.getListFromObjectValues(symbolsAndTimeframes, 0);
555
+ const marketSymbols = this.marketSymbols(symbols, undefined, false, true, true);
556
+ const firstSymbol = marketSymbols[0];
557
+ const url = await this.getUrlByMarketType(firstSymbol, false, 'watchOHLCVForSymbols', params);
558
+ const rawHashes = [];
559
+ const messageHashes = [];
560
+ for (let i = 0; i < symbolsAndTimeframes.length; i++) {
561
+ const data = symbolsAndTimeframes[i];
562
+ let symbolString = this.safeString(data, 0);
563
+ const market = this.market(symbolString);
564
+ symbolString = market['symbol'];
565
+ const unfiedTimeframe = this.safeString(data, 1);
566
+ const timeframeId = this.safeString(this.timeframes, unfiedTimeframe, unfiedTimeframe);
567
+ rawHashes.push('kline.' + timeframeId + '.' + market['id']);
568
+ messageHashes.push('ohlcv::' + symbolString + '::' + unfiedTimeframe);
569
+ }
570
+ const [symbol, timeframe, stored] = await this.watchTopics(url, messageHashes, rawHashes, params);
546
571
  if (this.newUpdates) {
547
- limit = ohlcv.getLimit(symbol, limit);
572
+ limit = stored.getLimit(symbol, limit);
548
573
  }
549
- return this.filterBySinceLimit(ohlcv, since, limit, 0, true);
574
+ const filtered = this.filterBySinceLimit(stored, since, limit, 0, true);
575
+ return this.createOHLCVObject(symbol, timeframe, filtered);
550
576
  }
551
577
  handleOHLCV(client, message) {
552
578
  //
@@ -586,18 +612,18 @@ export default class bybit extends bybitRest {
586
612
  if (ohlcvsByTimeframe === undefined) {
587
613
  this.ohlcvs[symbol] = {};
588
614
  }
589
- let stored = this.safeValue(ohlcvsByTimeframe, timeframe);
590
- if (stored === undefined) {
615
+ if (this.safeValue(ohlcvsByTimeframe, timeframe) === undefined) {
591
616
  const limit = this.safeInteger(this.options, 'OHLCVLimit', 1000);
592
- stored = new ArrayCacheByTimestamp(limit);
593
- this.ohlcvs[symbol][timeframe] = stored;
617
+ this.ohlcvs[symbol][timeframe] = new ArrayCacheByTimestamp(limit);
594
618
  }
619
+ const stored = this.ohlcvs[symbol][timeframe];
595
620
  for (let i = 0; i < data.length; i++) {
596
621
  const parsed = this.parseWsOHLCV(data[i]);
597
622
  stored.append(parsed);
598
623
  }
599
- const messageHash = 'kline' + ':' + timeframeId + ':' + symbol;
600
- client.resolve(stored, messageHash);
624
+ const messageHash = 'ohlcv::' + symbol + '::' + timeframe;
625
+ const resolveData = [symbol, timeframe, stored];
626
+ client.resolve(resolveData, messageHash);
601
627
  }
602
628
  parseWsOHLCV(ohlcv, market = undefined) {
603
629
  //
@@ -763,7 +789,7 @@ export default class bybit extends bybitRest {
763
789
  * @param {int} [since] the earliest time in ms to fetch trades for
764
790
  * @param {int} [limit] the maximum number of trade structures to retrieve
765
791
  * @param {object} [params] extra parameters specific to the exchange API endpoint
766
- * @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure
792
+ * @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure}
767
793
  */
768
794
  return await this.watchTradesForSymbols([symbol], since, limit, params);
769
795
  }
@@ -940,7 +966,7 @@ export default class bybit extends bybitRest {
940
966
  * @param {int} [limit] the maximum number of order structures to retrieve
941
967
  * @param {object} [params] extra parameters specific to the exchange API endpoint
942
968
  * @param {boolean} [params.unifiedMargin] use unified margin account
943
- * @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure
969
+ * @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
944
970
  */
945
971
  const method = 'watchMyTrades';
946
972
  let messageHash = 'myTrades';
@@ -1257,7 +1283,7 @@ export default class bybit extends bybitRest {
1257
1283
  const rawLiquidation = this.safeDict(message, 'data', {});
1258
1284
  const marketId = this.safeString(rawLiquidation, 'symbol');
1259
1285
  const market = this.safeMarket(marketId, undefined, '', 'contract');
1260
- const symbol = this.safeSymbol(marketId);
1286
+ const symbol = market['symbol'];
1261
1287
  const liquidation = this.parseWsLiquidation(rawLiquidation, market);
1262
1288
  let liquidations = this.safeValue(this.liquidations, symbol);
1263
1289
  if (liquidations === undefined) {
@@ -1284,7 +1310,7 @@ export default class bybit extends bybitRest {
1284
1310
  const timestamp = this.safeInteger(liquidation, 'updatedTime');
1285
1311
  return this.safeLiquidation({
1286
1312
  'info': liquidation,
1287
- 'symbol': this.safeSymbol(marketId, market),
1313
+ 'symbol': market['symbol'],
1288
1314
  'contracts': this.safeNumber(liquidation, 'size'),
1289
1315
  'contractSize': this.safeNumber(market, 'contractSize'),
1290
1316
  'price': this.safeNumber(liquidation, 'price'),
@@ -1304,7 +1330,7 @@ export default class bybit extends bybitRest {
1304
1330
  * @param {int} [since] the earliest time in ms to fetch orders for
1305
1331
  * @param {int} [limit] the maximum number of order structures to retrieve
1306
1332
  * @param {object} [params] extra parameters specific to the exchange API endpoint
1307
- * @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure
1333
+ * @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
1308
1334
  */
1309
1335
  await this.loadMarkets();
1310
1336
  const method = 'watchOrders';