ccxt 4.2.39 → 4.2.41

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. package/README.md +3 -3
  2. package/dist/ccxt.browser.js +1140 -341
  3. package/dist/ccxt.browser.min.js +2 -2
  4. package/dist/cjs/ccxt.js +1 -1
  5. package/dist/cjs/src/ascendex.js +28 -24
  6. package/dist/cjs/src/base/Exchange.js +14 -14
  7. package/dist/cjs/src/binance.js +561 -168
  8. package/dist/cjs/src/bingx.js +271 -25
  9. package/dist/cjs/src/bitforex.js +2 -2
  10. package/dist/cjs/src/bitget.js +13 -2
  11. package/dist/cjs/src/bybit.js +3 -1
  12. package/dist/cjs/src/coinbase.js +8 -6
  13. package/dist/cjs/src/coinbasepro.js +1 -0
  14. package/dist/cjs/src/coinlist.js +9 -7
  15. package/dist/cjs/src/coinmetro.js +2 -1
  16. package/dist/cjs/src/currencycom.js +1 -1
  17. package/dist/cjs/src/htx.js +1 -1
  18. package/dist/cjs/src/krakenfutures.js +126 -2
  19. package/dist/cjs/src/mexc.js +44 -44
  20. package/dist/cjs/src/okx.js +9 -15
  21. package/dist/cjs/src/phemex.js +1 -0
  22. package/dist/cjs/src/pro/bitmart.js +38 -20
  23. package/dist/cjs/src/pro/bybit.js +5 -5
  24. package/dist/cjs/src/pro/cex.js +1 -1
  25. package/dist/cjs/src/pro/gemini.js +1 -1
  26. package/js/ccxt.d.ts +1 -1
  27. package/js/ccxt.js +1 -1
  28. package/js/src/abstract/bingx.d.ts +4 -0
  29. package/js/src/abstract/coinbasepro.d.ts +1 -0
  30. package/js/src/ascendex.js +28 -24
  31. package/js/src/base/Exchange.d.ts +8 -8
  32. package/js/src/base/Exchange.js +14 -14
  33. package/js/src/binance.d.ts +1 -1
  34. package/js/src/binance.js +561 -168
  35. package/js/src/bingx.d.ts +2 -0
  36. package/js/src/bingx.js +271 -25
  37. package/js/src/bitforex.js +2 -2
  38. package/js/src/bitget.js +13 -2
  39. package/js/src/bybit.js +3 -1
  40. package/js/src/coinbase.js +8 -6
  41. package/js/src/coinbasepro.js +1 -0
  42. package/js/src/coinlist.js +9 -7
  43. package/js/src/coinmetro.js +2 -1
  44. package/js/src/currencycom.js +1 -1
  45. package/js/src/htx.js +1 -1
  46. package/js/src/krakenfutures.d.ts +2 -0
  47. package/js/src/krakenfutures.js +126 -2
  48. package/js/src/mexc.js +44 -44
  49. package/js/src/okx.js +9 -15
  50. package/js/src/phemex.js +1 -0
  51. package/js/src/pro/bitmart.d.ts +2 -0
  52. package/js/src/pro/bitmart.js +38 -20
  53. package/js/src/pro/bybit.d.ts +1 -1
  54. package/js/src/pro/bybit.js +5 -5
  55. package/js/src/pro/cex.js +1 -1
  56. package/js/src/pro/gemini.js +1 -1
  57. package/package.json +1 -1
@@ -30,6 +30,7 @@ export default class bitmart extends bitmartRest {
30
30
  'watchOrderBookForSymbols': true,
31
31
  'watchOrders': true,
32
32
  'watchTrades': true,
33
+ 'watchTradesForSymbols': true,
33
34
  'watchOHLCV': true,
34
35
  'watchPosition': 'emulated',
35
36
  'watchPositions': true,
@@ -274,17 +275,43 @@ export default class bitmart extends bitmartRest {
274
275
  * @param {object} [params] extra parameters specific to the exchange API endpoint
275
276
  * @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=public-trades}
276
277
  */
278
+ return await this.watchTradesForSymbols([symbol], since, limit, params);
279
+ }
280
+ async watchTradesForSymbols(symbols, since = undefined, limit = undefined, params = {}) {
281
+ /**
282
+ * @method
283
+ * @name bitmart#watchTradesForSymbols
284
+ * @see https://developer-pro.bitmart.com/en/spot/#public-trade-channel
285
+ * @description get the list of most recent trades for a list of symbols
286
+ * @param {string[]} symbols unified symbol of the market to fetch trades for
287
+ * @param {int} [since] timestamp in ms of the earliest trade to fetch
288
+ * @param {int} [limit] the maximum amount of trades to fetch
289
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
290
+ * @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=public-trades}
291
+ */
277
292
  await this.loadMarkets();
278
- symbol = this.symbol(symbol);
279
- const market = this.market(symbol);
280
- let type = 'spot';
281
- [type, params] = this.handleMarketTypeAndParams('watchTrades', market, params);
282
- const trades = await this.subscribe('trade', symbol, type, params);
293
+ let marketType = undefined;
294
+ [symbols, marketType, params] = this.getParamsForMultipleSub('watchTradesForSymbols', symbols, limit, params);
295
+ const channelName = 'trade';
296
+ const trades = await this.subscribeMultiple(channelName, marketType, symbols, params);
283
297
  if (this.newUpdates) {
284
- limit = trades.getLimit(symbol, limit);
298
+ const first = this.safeDict(trades, 0);
299
+ const tradeSymbol = this.safeString(first, 'symbol');
300
+ limit = trades.getLimit(tradeSymbol, limit);
285
301
  }
286
302
  return this.filterBySinceLimit(trades, since, limit, 'timestamp', true);
287
303
  }
304
+ getParamsForMultipleSub(methodName, symbols, limit = undefined, params = {}) {
305
+ symbols = this.marketSymbols(symbols, undefined, false, true);
306
+ const length = symbols.length;
307
+ if (length > 20) {
308
+ throw new NotSupported(this.id + ' ' + methodName + '() accepts a maximum of 20 symbols in one request');
309
+ }
310
+ const market = this.market(symbols[0]);
311
+ let marketType = undefined;
312
+ [marketType, params] = this.handleMarketTypeAndParams(methodName, market, params);
313
+ return [symbols, marketType, params];
314
+ }
288
315
  async watchTicker(symbol, params = {}) {
289
316
  /**
290
317
  * @method
@@ -822,16 +849,15 @@ export default class bitmart extends bitmartRest {
822
849
  // ]
823
850
  // }
824
851
  //
825
- const channel = this.safeString2(message, 'table', 'group');
826
- const isSpot = (channel.indexOf('spot') >= 0);
827
852
  const data = this.safeValue(message, 'data');
828
853
  if (data === undefined) {
829
854
  return;
830
855
  }
831
856
  let stored = undefined;
857
+ let symbol = undefined;
832
858
  for (let i = 0; i < data.length; i++) {
833
859
  const trade = this.parseWsTrade(data[i]);
834
- const symbol = trade['symbol'];
860
+ symbol = trade['symbol'];
835
861
  const tradesLimit = this.safeInteger(this.options, 'tradesLimit', 1000);
836
862
  stored = this.safeValue(this.trades, symbol);
837
863
  if (stored === undefined) {
@@ -840,10 +866,7 @@ export default class bitmart extends bitmartRest {
840
866
  }
841
867
  stored.append(trade);
842
868
  }
843
- let messageHash = channel;
844
- if (isSpot) {
845
- messageHash += ':' + this.safeString(data[0], 'symbol');
846
- }
869
+ const messageHash = 'trade:' + symbol;
847
870
  client.resolve(stored, messageHash);
848
871
  }
849
872
  parseWsTrade(trade, market = undefined) {
@@ -1376,15 +1399,10 @@ export default class bitmart extends bitmartRest {
1376
1399
  * @returns {object} A dictionary of [order book structures]{@link https://docs.ccxt.com/#/?id=order-book-structure} indexed by market symbols
1377
1400
  */
1378
1401
  await this.loadMarkets();
1379
- symbols = this.marketSymbols(symbols, undefined, false, true);
1380
- if (symbols.length > 20) {
1381
- throw new NotSupported(this.id + ' watchOrderBookForSymbols() accepts a maximum of 20 symbols in one request');
1382
- }
1383
- const market = this.market(symbols[0]);
1402
+ let type = undefined;
1403
+ [symbols, type, params] = this.getParamsForMultipleSub('watchOrderBookForSymbols', symbols, limit, params);
1384
1404
  let channel = undefined;
1385
1405
  [channel, params] = this.handleOptionAndParams(params, 'watchOrderBookForSymbols', 'depth', 'depth/increase100');
1386
- let type = 'spot';
1387
- [type, params] = this.handleMarketTypeAndParams('watchOrderBookForSymbols', market, params);
1388
1406
  if (type === 'swap' && channel === 'depth/increase100') {
1389
1407
  channel = 'depth50';
1390
1408
  }
@@ -4,7 +4,7 @@ import Client from '../base/ws/Client.js';
4
4
  export default class bybit extends bybitRest {
5
5
  describe(): any;
6
6
  requestId(): any;
7
- getUrlByMarketType(symbol?: Str, isPrivate?: boolean, method?: any, params?: {}): any;
7
+ getUrlByMarketType(symbol?: Str, isPrivate?: boolean, method?: string, params?: {}): any;
8
8
  cleanParams(params: any): any;
9
9
  watchTicker(symbol: string, params?: {}): Promise<Ticker>;
10
10
  watchTickers(symbols?: Strings, params?: {}): Promise<Tickers>;
@@ -187,7 +187,7 @@ export default class bybit extends bybitRest {
187
187
  const market = this.market(symbol);
188
188
  symbol = market['symbol'];
189
189
  const messageHash = 'ticker:' + symbol;
190
- const url = this.getUrlByMarketType(symbol, false, params);
190
+ const url = this.getUrlByMarketType(symbol, false, 'watchTicker', params);
191
191
  params = this.cleanParams(params);
192
192
  const options = this.safeValue(this.options, 'watchTicker', {});
193
193
  let topic = this.safeString(options, 'name', 'tickers');
@@ -212,7 +212,7 @@ export default class bybit extends bybitRest {
212
212
  await this.loadMarkets();
213
213
  symbols = this.marketSymbols(symbols, undefined, false);
214
214
  const messageHashes = [];
215
- const url = this.getUrlByMarketType(symbols[0], false, params);
215
+ const url = this.getUrlByMarketType(symbols[0], false, 'watchTickers', params);
216
216
  params = this.cleanParams(params);
217
217
  const options = this.safeValue(this.options, 'watchTickers', {});
218
218
  const topic = this.safeString(options, 'name', 'tickers');
@@ -379,7 +379,7 @@ export default class bybit extends bybitRest {
379
379
  await this.loadMarkets();
380
380
  const market = this.market(symbol);
381
381
  symbol = market['symbol'];
382
- const url = this.getUrlByMarketType(symbol, false, params);
382
+ const url = this.getUrlByMarketType(symbol, false, 'watchOHLCV', params);
383
383
  params = this.cleanParams(params);
384
384
  let ohlcv = undefined;
385
385
  const timeframeId = this.safeString(this.timeframes, timeframe, timeframe);
@@ -497,7 +497,7 @@ export default class bybit extends bybitRest {
497
497
  throw new ArgumentsRequired(this.id + ' watchOrderBookForSymbols() requires a non-empty array of symbols');
498
498
  }
499
499
  symbols = this.marketSymbols(symbols);
500
- const url = this.getUrlByMarketType(symbols[0], false, params);
500
+ const url = this.getUrlByMarketType(symbols[0], false, 'watchOrderBook', params);
501
501
  params = this.cleanParams(params);
502
502
  const market = this.market(symbols[0]);
503
503
  if (limit === undefined) {
@@ -629,7 +629,7 @@ export default class bybit extends bybitRest {
629
629
  throw new ArgumentsRequired(this.id + ' watchTradesForSymbols() requires a non-empty array of symbols');
630
630
  }
631
631
  params = this.cleanParams(params);
632
- const url = this.getUrlByMarketType(symbols[0], false, params);
632
+ const url = this.getUrlByMarketType(symbols[0], false, 'watchTrades', params);
633
633
  const topics = [];
634
634
  const messageHashes = [];
635
635
  for (let i = 0; i < symbols.length; i++) {
package/js/src/pro/cex.js CHANGED
@@ -188,7 +188,7 @@ export default class cex extends cexRest {
188
188
  trade = trade.split(':');
189
189
  }
190
190
  const side = this.safeString(trade, 0);
191
- const timestamp = this.safeNumber(trade, 1);
191
+ const timestamp = this.safeInteger(trade, 1);
192
192
  const amount = this.safeString(trade, 2);
193
193
  const price = this.safeString(trade, 3);
194
194
  const id = this.safeString(trade, 4);
@@ -644,7 +644,7 @@ export default class gemini extends geminiRest {
644
644
  // "socket_sequence": 139
645
645
  // }
646
646
  //
647
- const timestamp = this.safeNumber(order, 'timestampms');
647
+ const timestamp = this.safeInteger(order, 'timestampms');
648
648
  const status = this.safeString(order, 'type');
649
649
  const marketId = this.safeString(order, 'symbol');
650
650
  const typeId = this.safeString(order, 'order_type');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ccxt",
3
- "version": "4.2.39",
3
+ "version": "4.2.41",
4
4
  "description": "A JavaScript / TypeScript / Python / C# / PHP cryptocurrency trading library with support for 100+ exchanges",
5
5
  "unpkg": "dist/ccxt.browser.js",
6
6
  "type": "module",