ccxt 4.2.43 → 4.2.45

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 (46) hide show
  1. package/README.md +3 -3
  2. package/dist/ccxt.browser.js +1489 -463
  3. package/dist/ccxt.browser.min.js +6 -6
  4. package/dist/cjs/ccxt.js +1 -1
  5. package/dist/cjs/src/base/Exchange.js +54 -0
  6. package/dist/cjs/src/binance.js +627 -51
  7. package/dist/cjs/src/bingx.js +46 -6
  8. package/dist/cjs/src/bitstamp.js +1 -1
  9. package/dist/cjs/src/blofin.js +2 -1
  10. package/dist/cjs/src/bybit.js +96 -43
  11. package/dist/cjs/src/coinbase.js +221 -41
  12. package/dist/cjs/src/deribit.js +1 -1
  13. package/dist/cjs/src/krakenfutures.js +3 -2
  14. package/dist/cjs/src/kucoin.js +9 -5
  15. package/dist/cjs/src/mexc.js +348 -266
  16. package/dist/cjs/src/pro/gate.js +76 -42
  17. package/dist/cjs/src/pro/hitbtc.js +1 -0
  18. package/dist/cjs/src/probit.js +3 -3
  19. package/js/ccxt.d.ts +1 -1
  20. package/js/ccxt.js +1 -1
  21. package/js/src/abstract/coinbase.d.ts +1 -0
  22. package/js/src/base/Exchange.d.ts +4 -0
  23. package/js/src/base/Exchange.js +54 -0
  24. package/js/src/binance.d.ts +1 -0
  25. package/js/src/binance.js +627 -51
  26. package/js/src/bingx.d.ts +2 -1
  27. package/js/src/bingx.js +46 -6
  28. package/js/src/bitstamp.js +1 -1
  29. package/js/src/blofin.js +2 -1
  30. package/js/src/bybit.d.ts +4 -1
  31. package/js/src/bybit.js +96 -43
  32. package/js/src/coinbase.d.ts +10 -4
  33. package/js/src/coinbase.js +221 -41
  34. package/js/src/coinbasepro.d.ts +1 -1
  35. package/js/src/deribit.js +1 -1
  36. package/js/src/krakenfutures.js +3 -2
  37. package/js/src/kucoin.js +9 -5
  38. package/js/src/mexc.d.ts +4 -5
  39. package/js/src/mexc.js +348 -266
  40. package/js/src/pro/gate.d.ts +4 -0
  41. package/js/src/pro/gate.js +76 -42
  42. package/js/src/pro/hitbtc.js +1 -0
  43. package/js/src/probit.js +3 -3
  44. package/js/src/static_dependencies/jsencrypt/lib/jsbn/jsbn.d.ts +1 -1
  45. package/package.json +1 -1
  46. package/skip-tests.json +2 -0
@@ -12,6 +12,10 @@ export default class gate extends gateRest {
12
12
  watchTicker(symbol: string, params?: {}): Promise<Ticker>;
13
13
  watchTickers(symbols?: Strings, params?: {}): Promise<Tickers>;
14
14
  handleTicker(client: Client, message: any): void;
15
+ watchBidsAsks(symbols?: Strings, params?: {}): Promise<Tickers>;
16
+ handleBidAsk(client: Client, message: any): void;
17
+ subscribeWatchTickersAndBidsAsks(symbols?: Strings, callerMethodName?: Str, params?: {}): Promise<Tickers>;
18
+ handleTickerAndBidAsk(objectName: string, client: Client, message: any): void;
15
19
  watchTrades(symbol: string, since?: Int, limit?: Int, params?: {}): Promise<Trade[]>;
16
20
  watchTradesForSymbols(symbols: string[], since?: Int, limit?: Int, params?: {}): Promise<Trade[]>;
17
21
  handleTrades(client: Client, message: any): void;
@@ -275,6 +275,7 @@ export default class gate extends gateRest {
275
275
  /**
276
276
  * @method
277
277
  * @name gate#watchTicker
278
+ * @see https://www.gate.io/docs/developers/apiv4/ws/en/#tickers-channel
278
279
  * @description watches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
279
280
  * @param {string} symbol unified symbol of the market to fetch the ticker for
280
281
  * @param {object} [params] extra parameters specific to the exchange API endpoint
@@ -283,45 +284,21 @@ export default class gate extends gateRest {
283
284
  await this.loadMarkets();
284
285
  const market = this.market(symbol);
285
286
  symbol = market['symbol'];
286
- const marketId = market['id'];
287
- const url = this.getUrlByMarket(market);
288
- const messageType = this.getTypeByMarket(market);
289
- const [topic, query] = this.handleOptionAndParams(params, 'watchTicker', 'name', 'tickers');
290
- const channel = messageType + '.' + topic;
291
- const messageHash = 'ticker:' + symbol;
292
- const payload = [marketId];
293
- return await this.subscribePublic(url, messageHash, payload, channel, query);
287
+ params['callerMethodName'] = 'watchTicker';
288
+ const result = await this.watchTickers([symbol], params);
289
+ return this.safeValue(result, symbol);
294
290
  }
295
291
  async watchTickers(symbols = undefined, params = {}) {
296
292
  /**
297
293
  * @method
298
294
  * @name gate#watchTickers
295
+ * @see https://www.gate.io/docs/developers/apiv4/ws/en/#tickers-channel
299
296
  * @description watches a price ticker, a statistical calculation with the information calculated over the past 24 hours for all markets of a specific list
300
297
  * @param {string[]} symbols unified symbol of the market to fetch the ticker for
301
298
  * @param {object} [params] extra parameters specific to the exchange API endpoint
302
299
  * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
303
300
  */
304
- await this.loadMarkets();
305
- symbols = this.marketSymbols(symbols);
306
- if (symbols === undefined) {
307
- throw new ArgumentsRequired(this.id + ' watchTickers requires symbols');
308
- }
309
- const market = this.market(symbols[0]);
310
- const messageType = this.getTypeByMarket(market);
311
- const marketIds = this.marketIds(symbols);
312
- const [topic, query] = this.handleOptionAndParams(params, 'watchTicker', 'method', 'tickers');
313
- const channel = messageType + '.' + topic;
314
- const messageHash = 'tickers';
315
- const url = this.getUrlByMarket(market);
316
- const ticker = await this.subscribePublic(url, messageHash, marketIds, channel, query);
317
- let result = {};
318
- if (this.newUpdates) {
319
- result[ticker['symbol']] = ticker;
320
- }
321
- else {
322
- result = this.tickers;
323
- }
324
- return this.filterByArray(result, 'symbol', symbols, true);
301
+ return await this.subscribeWatchTickersAndBidsAsks(symbols, 'watchTickers', this.extend({ 'method': 'tickers' }, params));
325
302
  }
326
303
  handleTicker(client, message) {
327
304
  //
@@ -341,6 +318,24 @@ export default class gate extends gateRest {
341
318
  // "low_24h": "42721.03"
342
319
  // }
343
320
  // }
321
+ //
322
+ this.handleTickerAndBidAsk('ticker', client, message);
323
+ }
324
+ async watchBidsAsks(symbols = undefined, params = {}) {
325
+ /**
326
+ * @method
327
+ * @name gate#watchBidsAsks
328
+ * @see https://www.gate.io/docs/developers/apiv4/ws/en/#best-bid-or-ask-price
329
+ * @see https://www.gate.io/docs/developers/apiv4/ws/en/#order-book-channel
330
+ * @description watches best bid & ask for symbols
331
+ * @param {string[]} symbols unified symbol of the market to fetch the ticker for
332
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
333
+ * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
334
+ */
335
+ return await this.subscribeWatchTickersAndBidsAsks(symbols, 'watchBidsAsks', this.extend({ 'method': 'book_ticker' }, params));
336
+ }
337
+ handleBidAsk(client, message) {
338
+ //
344
339
  // {
345
340
  // "time": 1671363004,
346
341
  // "time_ms": 1671363004235,
@@ -357,24 +352,63 @@ export default class gate extends gateRest {
357
352
  // }
358
353
  // }
359
354
  //
355
+ this.handleTickerAndBidAsk('bidask', client, message);
356
+ }
357
+ async subscribeWatchTickersAndBidsAsks(symbols = undefined, callerMethodName = undefined, params = {}) {
358
+ await this.loadMarkets();
359
+ [callerMethodName, params] = this.handleParamString(params, 'callerMethodName', callerMethodName);
360
+ symbols = this.marketSymbols(symbols, undefined, false);
361
+ const market = this.market(symbols[0]);
362
+ const messageType = this.getTypeByMarket(market);
363
+ const marketIds = this.marketIds(symbols);
364
+ let channelName = undefined;
365
+ [channelName, params] = this.handleOptionAndParams(params, callerMethodName, 'method');
366
+ const url = this.getUrlByMarket(market);
367
+ const channel = messageType + '.' + channelName;
368
+ const isWatchTickers = callerMethodName.indexOf('watchTicker') >= 0;
369
+ const prefix = isWatchTickers ? 'ticker' : 'bidask';
370
+ const messageHashes = [];
371
+ for (let i = 0; i < symbols.length; i++) {
372
+ const symbol = symbols[i];
373
+ messageHashes.push(prefix + ':' + symbol);
374
+ }
375
+ const tickerOrBidAsk = await this.subscribePublicMultiple(url, messageHashes, marketIds, channel, params);
376
+ if (this.newUpdates) {
377
+ const items = {};
378
+ items[tickerOrBidAsk['symbol']] = tickerOrBidAsk;
379
+ return items;
380
+ }
381
+ const result = isWatchTickers ? this.tickers : this.bidsasks;
382
+ return this.filterByArray(result, 'symbol', symbols, true);
383
+ }
384
+ handleTickerAndBidAsk(objectName, client, message) {
360
385
  const channel = this.safeString(message, 'channel');
361
386
  const parts = channel.split('.');
362
387
  const rawMarketType = this.safeString(parts, 0);
363
388
  const marketType = (rawMarketType === 'futures') ? 'contract' : 'spot';
364
- let result = this.safeValue(message, 'result');
365
- if (!Array.isArray(result)) {
366
- result = [result];
389
+ let results = [];
390
+ if (marketType === 'contract') {
391
+ results = this.safeList(message, 'result', []);
367
392
  }
368
- for (let i = 0; i < result.length; i++) {
369
- const ticker = result[i];
370
- const marketId = this.safeString(ticker, 's');
393
+ else {
394
+ const rawTicker = this.safeDict(message, 'result', {});
395
+ results = [rawTicker];
396
+ }
397
+ const isTicker = (objectName === 'ticker'); // whether ticker or bid-ask
398
+ for (let i = 0; i < results.length; i++) {
399
+ const rawTicker = results[i];
400
+ const marketId = this.safeString(rawTicker, 's');
371
401
  const market = this.safeMarket(marketId, undefined, '_', marketType);
372
- const parsed = this.parseTicker(ticker, market);
373
- const symbol = parsed['symbol'];
374
- this.tickers[symbol] = parsed;
375
- const messageHash = 'ticker:' + symbol;
376
- client.resolve(parsed, messageHash);
377
- client.resolve(parsed, 'tickers');
402
+ const parsedItem = this.parseTicker(rawTicker, market);
403
+ const symbol = parsedItem['symbol'];
404
+ if (isTicker) {
405
+ this.tickers[symbol] = parsedItem;
406
+ }
407
+ else {
408
+ this.bidsasks[symbol] = parsedItem;
409
+ }
410
+ const messageHash = objectName + ':' + symbol;
411
+ client.resolve(parsedItem, messageHash);
378
412
  }
379
413
  }
380
414
  async watchTrades(symbol, since = undefined, limit = undefined, params = {}) {
@@ -1175,7 +1209,7 @@ export default class gate extends gateRest {
1175
1209
  'orders': this.handleOrder,
1176
1210
  'positions': this.handlePositions,
1177
1211
  'tickers': this.handleTicker,
1178
- 'book_ticker': this.handleTicker,
1212
+ 'book_ticker': this.handleBidAsk,
1179
1213
  'trades': this.handleTrades,
1180
1214
  'order_book_update': this.handleOrderBook,
1181
1215
  'balances': this.handleBalance,
@@ -411,6 +411,7 @@ export default class hitbtc extends hitbtcRest {
411
411
  const messageHash = channel + '::' + symbol;
412
412
  client.resolve(newTickers, messageHash);
413
413
  }
414
+ client.resolve(newTickers, 'tickers');
414
415
  const messageHashes = this.findMessageHashes(client, 'tickers::');
415
416
  for (let i = 0; i < messageHashes.length; i++) {
416
417
  const messageHash = messageHashes[i];
package/js/src/probit.js CHANGED
@@ -1592,12 +1592,12 @@ export default class probit extends Exchange {
1592
1592
  const currencyId = this.safeString(transaction, 'currency_id');
1593
1593
  const code = this.safeCurrencyCode(currencyId);
1594
1594
  const status = this.parseTransactionStatus(this.safeString(transaction, 'status'));
1595
- const feeCost = this.safeNumber(transaction, 'fee');
1595
+ const feeCostString = this.safeString(transaction, 'fee');
1596
1596
  let fee = undefined;
1597
- if (feeCost !== undefined && feeCost !== 0) {
1597
+ if (feeCostString !== undefined && feeCostString !== '0') {
1598
1598
  fee = {
1599
1599
  'currency': code,
1600
- 'cost': feeCost,
1600
+ 'cost': this.parseNumber(feeCostString),
1601
1601
  };
1602
1602
  }
1603
1603
  return {
@@ -15,7 +15,7 @@ export declare class BigInteger {
15
15
  protected intValue(): number;
16
16
  protected byteValue(): number;
17
17
  protected shortValue(): number;
18
- protected signum(): 0 | 1 | -1;
18
+ protected signum(): 1 | 0 | -1;
19
19
  toByteArray(): number[];
20
20
  protected equals(a: BigInteger): boolean;
21
21
  protected min(a: BigInteger): BigInteger;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ccxt",
3
- "version": "4.2.43",
3
+ "version": "4.2.45",
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",
package/skip-tests.json CHANGED
@@ -213,6 +213,8 @@
213
213
  }
214
214
  },
215
215
  "bitflyer": {
216
+ "skip": true,
217
+ "until": "2024-02-14",
216
218
  "skipMethods": {
217
219
  "loadMarkets": "contract is true, but contractSize is undefined",
218
220
  "fetchTrades": {