ccxt 4.4.82 → 4.4.85

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 (103) hide show
  1. package/README.md +5 -7
  2. package/dist/ccxt.browser.min.js +7 -7
  3. package/dist/cjs/ccxt.js +1 -9
  4. package/dist/cjs/src/apex.js +2 -1
  5. package/dist/cjs/src/base/Exchange.js +15 -2
  6. package/dist/cjs/src/bitget.js +1 -3
  7. package/dist/cjs/src/bitrue.js +14 -35
  8. package/dist/cjs/src/bitso.js +33 -0
  9. package/dist/cjs/src/bitstamp.js +33 -0
  10. package/dist/cjs/src/blofin.js +154 -13
  11. package/dist/cjs/src/btcbox.js +25 -5
  12. package/dist/cjs/src/bybit.js +16 -40
  13. package/dist/cjs/src/cex.js +2 -4
  14. package/dist/cjs/src/coinbase.js +56 -40
  15. package/dist/cjs/src/coinbaseexchange.js +142 -32
  16. package/dist/cjs/src/coincatch.js +14 -67
  17. package/dist/cjs/src/coinex.js +29 -32
  18. package/dist/cjs/src/coinlist.js +16 -15
  19. package/dist/cjs/src/coinmetro.js +22 -11
  20. package/dist/cjs/src/coinone.js +8 -10
  21. package/dist/cjs/src/coinsph.js +126 -1
  22. package/dist/cjs/src/cryptocom.js +111 -1
  23. package/dist/cjs/src/cryptomus.js +43 -89
  24. package/dist/cjs/src/delta.js +76 -36
  25. package/dist/cjs/src/derive.js +46 -10
  26. package/dist/cjs/src/ellipx.js +175 -79
  27. package/dist/cjs/src/gate.js +1 -1
  28. package/dist/cjs/src/gemini.js +3 -5
  29. package/dist/cjs/src/hitbtc.js +56 -69
  30. package/dist/cjs/src/hyperliquid.js +2 -2
  31. package/dist/cjs/src/kraken.js +29 -24
  32. package/dist/cjs/src/kucoinfutures.js +6 -0
  33. package/dist/cjs/src/lbank.js +1 -1
  34. package/dist/cjs/src/paradex.js +119 -3
  35. package/dist/cjs/src/pro/binance.js +31 -33
  36. package/dist/cjs/src/pro/bithumb.js +5 -3
  37. package/dist/cjs/src/pro/kraken.js +289 -79
  38. package/dist/cjs/src/pro/mexc.js +302 -8
  39. package/dist/cjs/src/pro/poloniex.js +6 -2
  40. package/examples/js/cli.js +127 -13
  41. package/js/ccxt.d.ts +2 -11
  42. package/js/ccxt.js +2 -8
  43. package/js/src/abstract/blofin.d.ts +8 -0
  44. package/js/src/abstract/btcbox.d.ts +1 -0
  45. package/js/src/apex.js +2 -1
  46. package/js/src/base/Exchange.d.ts +15 -1
  47. package/js/src/base/Exchange.js +15 -2
  48. package/js/src/base/types.d.ts +3 -0
  49. package/js/src/bitget.js +1 -3
  50. package/js/src/bitrue.js +14 -35
  51. package/js/src/bitso.js +33 -0
  52. package/js/src/bitstamp.js +33 -0
  53. package/js/src/blofin.d.ts +42 -2
  54. package/js/src/blofin.js +154 -13
  55. package/js/src/btcbox.js +25 -5
  56. package/js/src/bybit.js +16 -40
  57. package/js/src/cex.js +2 -4
  58. package/js/src/coinbase.js +56 -40
  59. package/js/src/coinbaseexchange.js +142 -32
  60. package/js/src/coincatch.js +14 -67
  61. package/js/src/coinex.js +28 -29
  62. package/js/src/coinlist.js +16 -15
  63. package/js/src/coinmetro.js +22 -11
  64. package/js/src/coinone.js +8 -10
  65. package/js/src/coinsph.d.ts +10 -1
  66. package/js/src/coinsph.js +126 -1
  67. package/js/src/cryptocom.d.ts +10 -1
  68. package/js/src/cryptocom.js +111 -1
  69. package/js/src/cryptomus.js +43 -89
  70. package/js/src/delta.js +76 -36
  71. package/js/src/derive.js +46 -10
  72. package/js/src/ellipx.d.ts +2 -3
  73. package/js/src/ellipx.js +175 -80
  74. package/js/src/gate.js +1 -1
  75. package/js/src/gemini.js +3 -5
  76. package/js/src/hitbtc.js +56 -69
  77. package/js/src/hyperliquid.js +2 -2
  78. package/js/src/kraken.js +29 -24
  79. package/js/src/kucoinfutures.d.ts +1 -0
  80. package/js/src/kucoinfutures.js +6 -0
  81. package/js/src/lbank.js +1 -1
  82. package/js/src/paradex.d.ts +12 -1
  83. package/js/src/paradex.js +119 -3
  84. package/js/src/pro/binance.d.ts +26 -26
  85. package/js/src/pro/binance.js +31 -33
  86. package/js/src/pro/bithumb.js +5 -3
  87. package/js/src/pro/kraken.d.ts +7 -6
  88. package/js/src/pro/kraken.js +290 -80
  89. package/js/src/pro/mexc.d.ts +58 -0
  90. package/js/src/pro/mexc.js +302 -8
  91. package/js/src/pro/poloniex.d.ts +1 -1
  92. package/js/src/pro/poloniex.js +6 -2
  93. package/package.json +1 -1
  94. package/js/src/abstract/bl3p.d.ts +0 -22
  95. package/js/src/abstract/bl3p.js +0 -11
  96. package/js/src/abstract/idex.d.ts +0 -29
  97. package/js/src/abstract/idex.js +0 -11
  98. package/js/src/bl3p.d.ts +0 -116
  99. package/js/src/bl3p.js +0 -552
  100. package/js/src/idex.d.ts +0 -312
  101. package/js/src/idex.js +0 -1961
  102. package/js/src/pro/idex.d.ts +0 -81
  103. package/js/src/pro/idex.js +0 -720
@@ -31,6 +31,12 @@ class mexc extends mexc$1 {
31
31
  'watchBidsAsks': true,
32
32
  'watchTrades': true,
33
33
  'watchTradesForSymbols': false,
34
+ 'unWatchTicker': true,
35
+ 'unWatchTickers': true,
36
+ 'unWatchBidsAsks': true,
37
+ 'unWatchOHLCV': true,
38
+ 'unWatchOrderBook': true,
39
+ 'unWatchTrades': true,
34
40
  },
35
41
  'urls': {
36
42
  'api': {
@@ -488,12 +494,15 @@ class mexc extends mexc$1 {
488
494
  }, market);
489
495
  }
490
496
  async watchSpotPublic(channel, messageHash, params = {}) {
497
+ const unsubscribed = this.safeBool(params, 'unsubscribed', false);
498
+ params = this.omit(params, ['unsubscribed']);
491
499
  const url = this.urls['api']['ws']['spot'];
500
+ const method = (unsubscribed) ? 'UNSUBSCRIPTION' : 'SUBSCRIPTION';
492
501
  const request = {
493
- 'method': 'SUBSCRIPTION',
502
+ 'method': method,
494
503
  'params': [channel],
495
504
  };
496
- return await this.watch(url, messageHash, this.extend(request, params), channel);
505
+ return await this.watch(url, messageHash, this.extend(request, params), messageHash);
497
506
  }
498
507
  async watchSpotPrivate(channel, messageHash, params = {}) {
499
508
  this.checkRequiredCredentials();
@@ -785,12 +794,6 @@ class mexc extends mexc$1 {
785
794
  const messageHash = 'orderbook:' + symbol;
786
795
  const subscription = this.safeValue(client.subscriptions, messageHash);
787
796
  const limit = this.safeInteger(subscription, 'limit');
788
- if (subscription === true) {
789
- // we set client.subscriptions[messageHash] to 1
790
- // once we have received the first delta and initialized the orderbook
791
- client.subscriptions[messageHash] = 1;
792
- this.orderbooks[symbol] = this.countedOrderBook({});
793
- }
794
797
  const storedOrderBook = this.orderbooks[symbol];
795
798
  const nonce = this.safeInteger(storedOrderBook, 'nonce');
796
799
  if (nonce === undefined) {
@@ -1412,6 +1415,297 @@ class mexc extends mexc$1 {
1412
1415
  this.balance[type] = this.safeBalance(this.balance[type]);
1413
1416
  client.resolve(this.balance[type], messageHash);
1414
1417
  }
1418
+ /**
1419
+ * @method
1420
+ * @name mexc#unWatchTicker
1421
+ * @description unWatches a price ticker, a statistical calculation with the information calculated over the past 24 hours for all markets of a specific list
1422
+ * @param {string} symbol unified symbol of the market to fetch the ticker for
1423
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1424
+ * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
1425
+ */
1426
+ async unWatchTicker(symbol, params = {}) {
1427
+ await this.loadMarkets();
1428
+ const market = this.market(symbol);
1429
+ const messageHash = 'unsubscribe:ticker:' + market['symbol'];
1430
+ let url = undefined;
1431
+ let channel = undefined;
1432
+ if (market['spot']) {
1433
+ let miniTicker = false;
1434
+ [miniTicker, params] = this.handleOptionAndParams(params, 'watchTicker', 'miniTicker');
1435
+ if (miniTicker) {
1436
+ channel = 'spot@public.miniTicker.v3.api@' + market['id'] + '@UTC+8';
1437
+ }
1438
+ else {
1439
+ channel = 'spot@public.bookTicker.v3.api@' + market['id'];
1440
+ }
1441
+ url = this.urls['api']['ws']['spot'];
1442
+ params['unsubscribed'] = true;
1443
+ this.watchSpotPublic(channel, messageHash, params);
1444
+ }
1445
+ else {
1446
+ channel = 'unsub.ticker';
1447
+ const requestParams = {
1448
+ 'symbol': market['id'],
1449
+ };
1450
+ url = this.urls['api']['ws']['swap'];
1451
+ this.watchSwapPublic(channel, messageHash, requestParams, params);
1452
+ }
1453
+ const client = this.client(url);
1454
+ this.handleUnsubscriptions(client, [messageHash]);
1455
+ return undefined;
1456
+ }
1457
+ /**
1458
+ * @method
1459
+ * @name mexc#unWatchTickers
1460
+ * @description unWatches a price ticker, a statistical calculation with the information calculated over the past 24 hours for all markets of a specific list
1461
+ * @param {string[]} symbols unified symbol of the market to fetch the ticker for
1462
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1463
+ * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
1464
+ */
1465
+ async unWatchTickers(symbols = undefined, params = {}) {
1466
+ await this.loadMarkets();
1467
+ symbols = this.marketSymbols(symbols, undefined);
1468
+ const messageHashes = [];
1469
+ const firstSymbol = this.safeString(symbols, 0);
1470
+ let market = undefined;
1471
+ if (firstSymbol !== undefined) {
1472
+ market = this.market(firstSymbol);
1473
+ }
1474
+ let type = undefined;
1475
+ [type, params] = this.handleMarketTypeAndParams('watchTickers', market, params);
1476
+ const isSpot = (type === 'spot');
1477
+ const url = (isSpot) ? this.urls['api']['ws']['spot'] : this.urls['api']['ws']['swap'];
1478
+ const request = {};
1479
+ if (isSpot) {
1480
+ let miniTicker = false;
1481
+ [miniTicker, params] = this.handleOptionAndParams(params, 'watchTickers', 'miniTicker');
1482
+ const topics = [];
1483
+ if (!miniTicker) {
1484
+ if (symbols === undefined) {
1485
+ throw new errors.ArgumentsRequired(this.id + ' watchTickers required symbols argument for the bookTicker channel');
1486
+ }
1487
+ const marketIds = this.marketIds(symbols);
1488
+ for (let i = 0; i < marketIds.length; i++) {
1489
+ const marketId = marketIds[i];
1490
+ messageHashes.push('unsubscribe:ticker:' + symbols[i]);
1491
+ const channel = 'spot@public.bookTicker.v3.api@' + marketId;
1492
+ topics.push(channel);
1493
+ }
1494
+ }
1495
+ else {
1496
+ topics.push('spot@public.miniTickers.v3.api@UTC+8');
1497
+ if (symbols === undefined) {
1498
+ messageHashes.push('unsubscribe:spot:ticker');
1499
+ }
1500
+ else {
1501
+ for (let i = 0; i < symbols.length; i++) {
1502
+ messageHashes.push('unsubscribe:ticker:' + symbols[i]);
1503
+ }
1504
+ }
1505
+ }
1506
+ request['method'] = 'UNSUBSCRIPTION';
1507
+ request['params'] = topics;
1508
+ }
1509
+ else {
1510
+ request['method'] = 'unsub.tickers';
1511
+ request['params'] = {};
1512
+ messageHashes.push('unsubscribe:ticker');
1513
+ }
1514
+ const client = this.client(url);
1515
+ this.watchMultiple(url, messageHashes, this.extend(request, params), messageHashes);
1516
+ this.handleUnsubscriptions(client, messageHashes);
1517
+ return undefined;
1518
+ }
1519
+ /**
1520
+ * @method
1521
+ * @name mexc#unWatchBidsAsks
1522
+ * @description unWatches best bid & ask for symbols
1523
+ * @param {string[]} symbols unified symbol of the market to fetch the ticker for
1524
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1525
+ * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
1526
+ */
1527
+ async unWatchBidsAsks(symbols = undefined, params = {}) {
1528
+ await this.loadMarkets();
1529
+ symbols = this.marketSymbols(symbols, undefined, true, false, true);
1530
+ let marketType = undefined;
1531
+ if (symbols === undefined) {
1532
+ throw new errors.ArgumentsRequired(this.id + ' watchBidsAsks required symbols argument');
1533
+ }
1534
+ const markets = this.marketsForSymbols(symbols);
1535
+ [marketType, params] = this.handleMarketTypeAndParams('watchBidsAsks', markets[0], params);
1536
+ const isSpot = marketType === 'spot';
1537
+ if (!isSpot) {
1538
+ throw new errors.NotSupported(this.id + ' watchBidsAsks only support spot market');
1539
+ }
1540
+ const messageHashes = [];
1541
+ const topics = [];
1542
+ for (let i = 0; i < symbols.length; i++) {
1543
+ if (isSpot) {
1544
+ const market = this.market(symbols[i]);
1545
+ topics.push('spot@public.bookTicker.v3.api@' + market['id']);
1546
+ }
1547
+ messageHashes.push('unsubscribe:bidask:' + symbols[i]);
1548
+ }
1549
+ const url = this.urls['api']['ws']['spot'];
1550
+ const request = {
1551
+ 'method': 'UNSUBSCRIPTION',
1552
+ 'params': topics,
1553
+ };
1554
+ const client = this.client(url);
1555
+ this.watchMultiple(url, messageHashes, this.extend(request, params), messageHashes);
1556
+ this.handleUnsubscriptions(client, messageHashes);
1557
+ return undefined;
1558
+ }
1559
+ /**
1560
+ * @method
1561
+ * @name mexc#unWatchOHLCV
1562
+ * @description unWatches historical candlestick data containing the open, high, low, and close price, and the volume of a market
1563
+ * @param {string} symbol unified symbol of the market to fetch OHLCV data for
1564
+ * @param {string} timeframe the length of time each candle represents
1565
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1566
+ * @param {object} [params.timezone] if provided, kline intervals are interpreted in that timezone instead of UTC, example '+08:00'
1567
+ * @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
1568
+ */
1569
+ async unWatchOHLCV(symbol, timeframe = '1m', params = {}) {
1570
+ await this.loadMarkets();
1571
+ const market = this.market(symbol);
1572
+ symbol = market['symbol'];
1573
+ const timeframes = this.safeValue(this.options, 'timeframes', {});
1574
+ const timeframeId = this.safeString(timeframes, timeframe);
1575
+ const messageHash = 'unsubscribe:candles:' + symbol + ':' + timeframe;
1576
+ let url = undefined;
1577
+ if (market['spot']) {
1578
+ url = this.urls['api']['ws']['spot'];
1579
+ const channel = 'spot@public.kline.v3.api@' + market['id'] + '@' + timeframeId;
1580
+ params['unsubscribed'] = true;
1581
+ this.watchSpotPublic(channel, messageHash, params);
1582
+ }
1583
+ else {
1584
+ url = this.urls['api']['ws']['swap'];
1585
+ const channel = 'unsub.kline';
1586
+ const requestParams = {
1587
+ 'symbol': market['id'],
1588
+ 'interval': timeframeId,
1589
+ };
1590
+ this.watchSwapPublic(channel, messageHash, requestParams, params);
1591
+ }
1592
+ const client = this.client(url);
1593
+ this.handleUnsubscriptions(client, [messageHash]);
1594
+ return undefined;
1595
+ }
1596
+ /**
1597
+ * @method
1598
+ * @name mexc#unWatchOrderBook
1599
+ * @description unWatches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
1600
+ * @param {string} symbol unified array of symbols
1601
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1602
+ * @returns {object} A dictionary of [order book structures]{@link https://docs.ccxt.com/#/?id=order-book-structure} indexed by market symbols
1603
+ */
1604
+ async unWatchOrderBook(symbol, params = {}) {
1605
+ await this.loadMarkets();
1606
+ const market = this.market(symbol);
1607
+ symbol = market['symbol'];
1608
+ const messageHash = 'unsubscribe:orderbook:' + symbol;
1609
+ let url = undefined;
1610
+ if (market['spot']) {
1611
+ url = this.urls['api']['ws']['spot'];
1612
+ const channel = 'spot@public.increase.depth.v3.api@' + market['id'];
1613
+ params['unsubscribed'] = true;
1614
+ this.watchSpotPublic(channel, messageHash, params);
1615
+ }
1616
+ else {
1617
+ url = this.urls['api']['ws']['swap'];
1618
+ const channel = 'unsub.depth';
1619
+ const requestParams = {
1620
+ 'symbol': market['id'],
1621
+ };
1622
+ this.watchSwapPublic(channel, messageHash, requestParams, params);
1623
+ }
1624
+ const client = this.client(url);
1625
+ this.handleUnsubscriptions(client, [messageHash]);
1626
+ return undefined;
1627
+ }
1628
+ /**
1629
+ * @method
1630
+ * @name mexc#unWatchTrades
1631
+ * @description unsubscribes from the trades channel
1632
+ * @param {string} symbol unified symbol of the market to fetch trades for
1633
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1634
+ * @param {string} [params.name] the name of the method to call, 'trade' or 'aggTrade', default is 'trade'
1635
+ * @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=public-trades}
1636
+ */
1637
+ async unWatchTrades(symbol, params = {}) {
1638
+ await this.loadMarkets();
1639
+ const market = this.market(symbol);
1640
+ symbol = market['symbol'];
1641
+ const messageHash = 'unsubscribe:trades:' + symbol;
1642
+ let url = undefined;
1643
+ if (market['spot']) {
1644
+ url = this.urls['api']['ws']['spot'];
1645
+ const channel = 'spot@public.deals.v3.api@' + market['id'];
1646
+ params['unsubscribed'] = true;
1647
+ this.watchSpotPublic(channel, messageHash, params);
1648
+ }
1649
+ else {
1650
+ url = this.urls['api']['ws']['swap'];
1651
+ const channel = 'unsub.deal';
1652
+ const requestParams = {
1653
+ 'symbol': market['id'],
1654
+ };
1655
+ this.watchSwapPublic(channel, messageHash, requestParams, params);
1656
+ }
1657
+ const client = this.client(url);
1658
+ this.handleUnsubscriptions(client, [messageHash]);
1659
+ return undefined;
1660
+ }
1661
+ handleUnsubscriptions(client, messageHashes) {
1662
+ for (let i = 0; i < messageHashes.length; i++) {
1663
+ const messageHash = messageHashes[i];
1664
+ const subMessageHash = messageHash.replace('unsubscribe:', '');
1665
+ this.cleanUnsubscription(client, subMessageHash, messageHash);
1666
+ if (messageHash.indexOf('ticker') >= 0) {
1667
+ const symbol = messageHash.replace('unsubscribe:ticker:', '');
1668
+ if (symbol.indexOf('unsubscribe') >= 0) {
1669
+ // unWatchTickers
1670
+ const symbols = Object.keys(this.tickers);
1671
+ for (let j = 0; j < symbols.length; j++) {
1672
+ delete this.tickers[symbols[j]];
1673
+ }
1674
+ }
1675
+ else if (symbol in this.tickers) {
1676
+ delete this.tickers[symbol];
1677
+ }
1678
+ }
1679
+ else if (messageHash.indexOf('bidask') >= 0) {
1680
+ const symbol = messageHash.replace('unsubscribe:bidask:', '');
1681
+ if (symbol in this.bidsasks) {
1682
+ delete this.bidsasks[symbol];
1683
+ }
1684
+ }
1685
+ else if (messageHash.indexOf('candles') >= 0) {
1686
+ const splitHashes = messageHash.split(':');
1687
+ let symbol = this.safeString(splitHashes, 2);
1688
+ if (splitHashes.length > 4) {
1689
+ symbol += ':' + this.safeString(splitHashes, 3);
1690
+ }
1691
+ if (symbol in this.ohlcvs) {
1692
+ delete this.ohlcvs[symbol];
1693
+ }
1694
+ }
1695
+ else if (messageHash.indexOf('orderbook') >= 0) {
1696
+ const symbol = messageHash.replace('unsubscribe:orderbook:', '');
1697
+ if (symbol in this.orderbooks) {
1698
+ delete this.orderbooks[symbol];
1699
+ }
1700
+ }
1701
+ else if (messageHash.indexOf('trades') >= 0) {
1702
+ const symbol = messageHash.replace('unsubscribe:trades:', '');
1703
+ if (symbol in this.trades) {
1704
+ delete this.trades[symbol];
1705
+ }
1706
+ }
1707
+ }
1708
+ }
1415
1709
  async authenticate(subscriptionHash, params = {}) {
1416
1710
  // we only need one listenKey since ccxt shares connections
1417
1711
  let listenKey = this.safeString(this.options, 'listenKey');
@@ -249,7 +249,9 @@ class poloniex extends poloniex$1 {
249
249
  request['price'] = this.priceToPrecision(symbol, price);
250
250
  }
251
251
  }
252
- return await this.tradeRequest('createOrder', this.extend(request, params));
252
+ const orders = await this.tradeRequest('createOrder', this.extend(request, params));
253
+ const order = this.safeDict(orders, 0);
254
+ return order;
253
255
  }
254
256
  /**
255
257
  * @method
@@ -268,7 +270,9 @@ class poloniex extends poloniex$1 {
268
270
  const clientOrderIds = this.safeValue(params, 'clientOrderId', []);
269
271
  params['clientOrderIds'] = this.arrayConcat(clientOrderIds, [clientOrderId]);
270
272
  }
271
- return await this.cancelOrdersWs([id], symbol, params);
273
+ const orders = await this.cancelOrdersWs([id], symbol, params);
274
+ const order = this.safeDict(orders, 0);
275
+ return order;
272
276
  }
273
277
  /**
274
278
  * @method
@@ -15,6 +15,21 @@ const { ExchangeError , NetworkError} = ccxt
15
15
  function jsonStringify (obj, indent = undefined) {
16
16
  return JSON.stringify (obj, function(k, v) { return v === undefined ? null : v; }, indent);
17
17
  }
18
+
19
+
20
+ function countAllParams(fn) {
21
+ const fnStr = fn.toString()
22
+ .replace(/\/\/.*$/mg, '')
23
+ .replace(/\/\*[\s\S]*?\*\//mg, '')
24
+ .replace(/\s+/g, '');
25
+
26
+ const match = fnStr.match(/^[^(]*\(([^)]*)\)/);
27
+ if (!match) return 0;
28
+
29
+ const params = match[1].split(',').filter(p => p);
30
+ return params.length;
31
+ }
32
+
18
33
  //-----------------------------------------------------------------------------
19
34
 
20
35
  let [processPath, , exchangeId, methodName, ... params] = process.argv.filter (x => !x.startsWith ('--'))
@@ -45,19 +60,63 @@ let [processPath, , exchangeId, methodName, ... params] = process.argv.filter (x
45
60
  , noKeys = process.argv.includes ('--no-keys')
46
61
 
47
62
  let foundDescription = undefined;
63
+ const nameIndex = process.argv.indexOf ('--name')
64
+ if (nameIndex >= 0) {
65
+ foundDescription = process.argv[nameIndex + 1];
66
+ // search that string in `params` and remove it
67
+ const index = params.indexOf (foundDescription)
68
+ if (index >= 0) {
69
+ params.splice (index, 1);
70
+ }
71
+ }
72
+
73
+ let lastParamObject
74
+ let symbol
48
75
  for (let i = 0; i < process.argv.length; i++) {
49
- if (process.argv[i] === '--name') {
50
- foundDescription = process.argv[i + 1];
51
- // search that string in `params` and remove it
52
- for (let j = 0; j < params.length; j++) {
53
- if (params[j] === foundDescription) {
54
- params.splice(j, 1);
55
- break;
76
+ if (process.argv[i] === '--param') {
77
+ const nextParam = process.argv[i + 1]
78
+ if (nextParam) {
79
+ const paramIndex = params.indexOf (nextParam)
80
+ if (paramIndex >= 0) {
81
+ if (nextParam.indexOf('=') >= 0) {
82
+ const parsed = nextParam.split('=')
83
+ if (parsed.length === 2) {
84
+ if (!lastParamObject) {
85
+ lastParamObject = {}
86
+ }
87
+ const key = parsed[0];
88
+ const value = parsed[1];
89
+ if (key === 'symbol') {
90
+ symbol = value
91
+ }
92
+ lastParamObject[key] = value
93
+ params.splice(paramIndex, 1)
94
+ } else {
95
+ throw new Error ('Invalid usage of --param. Please provide a key=value pair after --param.')
96
+ }
97
+ } else {
98
+ if (!lastParamObject) {
99
+ lastParamObject = {}
100
+ }
101
+ lastParamObject[nextParam] = true
102
+ }
103
+ } else {
104
+ throw new Error (`Unexpected error by parsing parameters: ${nextParam} is not found in params array.`)
56
105
  }
106
+ } else {
107
+ throw new Error ('Invalid usage of --param. Please provide a value after --param.')
57
108
  }
58
- break;
59
109
  }
60
110
  }
111
+
112
+ let lastParam = params[params.length - 1]
113
+ // exclude parasitic single quotes. Can happen on some shell processors
114
+ if (lastParam?.includes('{') && lastParam?.includes('}')) {
115
+ if (lastParam.startsWith('\'{') && lastParam.endsWith('}\'')) {
116
+ lastParam = params[params.length - 1] = lastParam.substring(1, lastParam.length - 1)
117
+ }
118
+ }
119
+
61
120
  //-----------------------------------------------------------------------------
62
121
  if (!raw) {
63
122
  log ((new Date ()).toISOString())
@@ -213,6 +272,7 @@ function printUsage () {
213
272
  log ('node', process.argv[1], 'okcoin fetchOHLCV BTC/USD 15m')
214
273
  log ('node', process.argv[1], 'bitfinex fetchBalance')
215
274
  log ('node', process.argv[1], 'kraken fetchOrderBook ETH/BTC')
275
+ log ('node', process.argv[1], 'binanceusdm fetchTrades BTC/USDC undefined undefined --param until=1746988377067')
216
276
  printSupportedExchanges ()
217
277
  log ('Supported options:')
218
278
  log ('--verbose Print verbose output')
@@ -224,6 +284,8 @@ function printUsage () {
224
284
  log ('--no-table Do not print the fetch response as a table')
225
285
  log ('--table Print the fetch response as a table')
226
286
  log ('--iso8601 Print timestamps as ISO8601 datetimes')
287
+ log ('--param key=value Set a custom key=value pair for the last method\'s argument. Can be repeated multiple times')
288
+ log (' NOTE: don\'t forget to fill up missed arguments with "undefined" before last options parameter')
227
289
  log ('--cors use CORS proxy for debugging')
228
290
  log ('--sign-in Call signIn() if any')
229
291
  log ('--sandbox Use the exchange sandbox if available, same as --testnet')
@@ -306,10 +368,16 @@ async function run () {
306
368
 
307
369
  let args = params
308
370
  .map (s => s.match (/^[0-9]{4}[-][0-9]{2}[-][0-9]{2}[T\s]?[0-9]{2}[:][0-9]{2}[:][0-9]{2}/g) ? exchange.parse8601 (s) : s)
309
- .map (s => (() => {
310
- if (s.match ( /^\d+$/g)) return s < Number.MAX_SAFE_INTEGER ? Number (s) : s
311
- try {return eval ('(() => (' + s + ')) ()') } catch (e) { return s }
312
- }) ())
371
+ .map (s => {
372
+ return (() => {
373
+ if (s.match(/^\d+$/g)) return s < Number.MAX_SAFE_INTEGER ? Number(s) : s
374
+ try {
375
+ return eval('(() => (' + s + ')) ()')
376
+ } catch (e) {
377
+ return s
378
+ }
379
+ })();
380
+ })
313
381
 
314
382
  const www = Array.isArray (exchange.urls.www) ? exchange.urls.www[0] : exchange.urls.www
315
383
 
@@ -337,6 +405,34 @@ async function run () {
337
405
  }
338
406
  }
339
407
  }
408
+ if (symbol && lastParamObject) {
409
+ let marketId
410
+ try {
411
+ marketId = exchange.marketId(symbol)
412
+ } catch (e) {
413
+ // noop possible loaded from cache
414
+ }
415
+ if (!marketId) {
416
+ try {
417
+ await exchange.loadMarkets();
418
+ marketId = exchange.marketId(symbol)
419
+ } catch (e) {
420
+ // noop
421
+ }
422
+ }
423
+ if (marketId) {
424
+ lastParamObject.symbol = marketId
425
+ }
426
+ }
427
+
428
+ if (typeof lastParamObject === 'object') {
429
+ const lastArgument = args[args.length - 1];
430
+ if (lastParam && typeof lastArgument === 'object') {
431
+ args[args.length - 1] = Object.assign (lastArgument, lastParamObject)
432
+ } else {
433
+ args.push (lastParamObject)
434
+ }
435
+ }
340
436
 
341
437
  if (signIn && exchange.has.signIn) {
342
438
  await exchange.signIn ()
@@ -363,7 +459,10 @@ async function run () {
363
459
 
364
460
  if (typeof exchange[methodName] === 'function') {
365
461
 
366
- if (!raw) log (exchange.id + '.' + methodName, '(' + args.join (', ') + ')')
462
+ if (!raw || details) {
463
+ const methodArgsPrint = JSON.stringify(args);
464
+ log(exchange.id + '.' + methodName, '(' + methodArgsPrint.substring(1, methodArgsPrint.length - 1) + ')')
465
+ }
367
466
 
368
467
  let start = exchange.milliseconds ()
369
468
  let end = exchange.milliseconds ()
@@ -377,6 +476,21 @@ async function run () {
377
476
 
378
477
  while (true) {
379
478
  try {
479
+ const fn = exchange[methodName]
480
+ const fnParams = countAllParams(fn)
481
+ const argsContainsParams = args.find( arg=> arg && typeof arg === 'object' && !Array.isArray(arg) && Object.keys(arg).length > 0)
482
+ if (argsContainsParams && fnParams !== args.length) {
483
+ // populate the missing params with undefined
484
+ const missingParams = fnParams - args.length
485
+ const paramsObj = args[args.length - 1]
486
+ args.pop()
487
+ const newArgsArray = args;
488
+ for (let i = 0; i < missingParams; i++) {
489
+ newArgsArray.push(undefined)
490
+ }
491
+ newArgsArray.push(paramsObj)
492
+ args = newArgsArray
493
+ }
380
494
  const result = await exchange[methodName] (... args)
381
495
  end = exchange.milliseconds ()
382
496
  if (!isWsMethod && !raw) {
package/js/ccxt.d.ts CHANGED
@@ -4,7 +4,7 @@ import * as functions from './src/base/functions.js';
4
4
  import * as errors from './src/base/errors.js';
5
5
  import type { Int, int, Str, Strings, Num, Bool, IndexType, OrderSide, OrderType, MarketType, SubType, Dict, NullableDict, List, NullableList, Fee, OHLCV, OHLCVC, implicitReturnType, Market, Currency, Dictionary, MinMax, FeeInterface, TradingFeeInterface, MarketInterface, Trade, Order, OrderBook, Ticker, Transaction, Tickers, CurrencyInterface, Balance, BalanceAccount, Account, PartialBalances, Balances, DepositAddress, WithdrawalResponse, FundingRate, FundingRates, Position, BorrowInterest, LeverageTier, LedgerEntry, DepositWithdrawFeeNetwork, DepositWithdrawFee, TransferEntry, CrossBorrowRate, IsolatedBorrowRate, FundingRateHistory, OpenInterest, Liquidation, OrderRequest, CancellationRequest, FundingHistory, MarketMarginModes, MarginMode, Greeks, Conversion, Option, LastPrice, Leverage, MarginModification, Leverages, LastPrices, Currencies, TradingFees, MarginModes, OptionChain, IsolatedBorrowRates, CrossBorrowRates, LeverageTiers, LongShortRatio, OrderBooks, OpenInterests, ConstructorArgs } from './src/base/types.js';
6
6
  import { BaseError, ExchangeError, AuthenticationError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, OperationRejected, NoChange, MarginModeAlreadySet, MarketClosed, ManualInteractionNeeded, InsufficientFunds, InvalidAddress, AddressPending, InvalidOrder, OrderNotFound, OrderNotCached, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, ContractUnavailable, NotSupported, InvalidProxySettings, ExchangeClosedByUser, OperationFailed, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, ChecksumError, RequestTimeout, BadResponse, NullResponse, CancelPending, UnsubscribeError } from './src/base/errors.js';
7
- declare const version = "4.4.81";
7
+ declare const version = "4.4.84";
8
8
  import alpaca from './src/alpaca.js';
9
9
  import apex from './src/apex.js';
10
10
  import ascendex from './src/ascendex.js';
@@ -30,7 +30,6 @@ import bitso from './src/bitso.js';
30
30
  import bitstamp from './src/bitstamp.js';
31
31
  import bitteam from './src/bitteam.js';
32
32
  import bitvavo from './src/bitvavo.js';
33
- import bl3p from './src/bl3p.js';
34
33
  import blockchaincom from './src/blockchaincom.js';
35
34
  import blofin from './src/blofin.js';
36
35
  import btcalpha from './src/btcalpha.js';
@@ -72,7 +71,6 @@ import htx from './src/htx.js';
72
71
  import huobi from './src/huobi.js';
73
72
  import huobijp from './src/huobijp.js';
74
73
  import hyperliquid from './src/hyperliquid.js';
75
- import idex from './src/idex.js';
76
74
  import independentreserve from './src/independentreserve.js';
77
75
  import indodax from './src/indodax.js';
78
76
  import kraken from './src/kraken.js';
@@ -157,7 +155,6 @@ import htxPro from './src/pro/htx.js';
157
155
  import huobiPro from './src/pro/huobi.js';
158
156
  import huobijpPro from './src/pro/huobijp.js';
159
157
  import hyperliquidPro from './src/pro/hyperliquid.js';
160
- import idexPro from './src/pro/idex.js';
161
158
  import independentreservePro from './src/pro/independentreserve.js';
162
159
  import krakenPro from './src/pro/kraken.js';
163
160
  import krakenfuturesPro from './src/pro/krakenfutures.js';
@@ -210,7 +207,6 @@ declare const exchanges: {
210
207
  bitstamp: typeof bitstamp;
211
208
  bitteam: typeof bitteam;
212
209
  bitvavo: typeof bitvavo;
213
- bl3p: typeof bl3p;
214
210
  blockchaincom: typeof blockchaincom;
215
211
  blofin: typeof blofin;
216
212
  btcalpha: typeof btcalpha;
@@ -252,7 +248,6 @@ declare const exchanges: {
252
248
  huobi: typeof huobi;
253
249
  huobijp: typeof huobijp;
254
250
  hyperliquid: typeof hyperliquid;
255
- idex: typeof idex;
256
251
  independentreserve: typeof independentreserve;
257
252
  indodax: typeof indodax;
258
253
  kraken: typeof kraken;
@@ -339,7 +334,6 @@ declare const pro: {
339
334
  huobi: typeof huobiPro;
340
335
  huobijp: typeof huobijpPro;
341
336
  hyperliquid: typeof hyperliquidPro;
342
- idex: typeof idexPro;
343
337
  independentreserve: typeof independentreservePro;
344
338
  kraken: typeof krakenPro;
345
339
  krakenfutures: typeof krakenfuturesPro;
@@ -418,7 +412,6 @@ declare const ccxt: {
418
412
  huobi: typeof huobiPro;
419
413
  huobijp: typeof huobijpPro;
420
414
  hyperliquid: typeof hyperliquidPro;
421
- idex: typeof idexPro;
422
415
  independentreserve: typeof independentreservePro;
423
416
  kraken: typeof krakenPro;
424
417
  krakenfutures: typeof krakenfuturesPro;
@@ -472,7 +465,6 @@ declare const ccxt: {
472
465
  bitstamp: typeof bitstamp;
473
466
  bitteam: typeof bitteam;
474
467
  bitvavo: typeof bitvavo;
475
- bl3p: typeof bl3p;
476
468
  blockchaincom: typeof blockchaincom;
477
469
  blofin: typeof blofin;
478
470
  btcalpha: typeof btcalpha;
@@ -514,7 +506,6 @@ declare const ccxt: {
514
506
  huobi: typeof huobi;
515
507
  huobijp: typeof huobijp;
516
508
  hyperliquid: typeof hyperliquid;
517
- idex: typeof idex;
518
509
  independentreserve: typeof independentreserve;
519
510
  indodax: typeof indodax;
520
511
  kraken: typeof kraken;
@@ -555,5 +546,5 @@ declare const ccxt: {
555
546
  zaif: typeof zaif;
556
547
  zonda: typeof zonda;
557
548
  } & typeof functions & typeof errors;
558
- export { version, Exchange, exchanges, pro, Precise, functions, errors, BaseError, ExchangeError, AuthenticationError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, OperationRejected, NoChange, MarginModeAlreadySet, MarketClosed, ManualInteractionNeeded, InsufficientFunds, InvalidAddress, AddressPending, InvalidOrder, OrderNotFound, OrderNotCached, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, ContractUnavailable, NotSupported, InvalidProxySettings, ExchangeClosedByUser, OperationFailed, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, ChecksumError, RequestTimeout, BadResponse, NullResponse, CancelPending, UnsubscribeError, Int, int, Str, Strings, Num, Bool, IndexType, OrderSide, OrderType, MarketType, SubType, Dict, NullableDict, List, NullableList, Fee, OHLCV, OHLCVC, implicitReturnType, Market, Currency, ConstructorArgs, Dictionary, MinMax, FeeInterface, TradingFeeInterface, MarketMarginModes, MarketInterface, Trade, Order, OrderBook, OrderBooks, Ticker, Transaction, Tickers, CurrencyInterface, Balance, BalanceAccount, Account, PartialBalances, Balances, DepositAddress, WithdrawalResponse, FundingRate, FundingRates, Position, BorrowInterest, LeverageTier, LedgerEntry, DepositWithdrawFeeNetwork, DepositWithdrawFee, TransferEntry, CrossBorrowRate, IsolatedBorrowRate, FundingRateHistory, OpenInterest, OpenInterests, Liquidation, OrderRequest, CancellationRequest, FundingHistory, MarginMode, Greeks, Conversion, Option, LastPrice, Leverage, LongShortRatio, MarginModification, Leverages, LastPrices, Currencies, TradingFees, MarginModes, OptionChain, IsolatedBorrowRates, CrossBorrowRates, LeverageTiers, alpaca, apex, ascendex, bequant, bigone, binance, binancecoinm, binanceus, binanceusdm, bingx, bit2c, bitbank, bitbns, bitfinex, bitflyer, bitget, bithumb, bitmart, bitmex, bitopro, bitrue, bitso, bitstamp, bitteam, bitvavo, bl3p, blockchaincom, blofin, btcalpha, btcbox, btcmarkets, btcturk, bybit, cex, coinbase, coinbaseadvanced, coinbaseexchange, coinbaseinternational, coincatch, coincheck, coinex, coinlist, coinmate, coinmetro, coinone, coinsph, coinspot, cryptocom, cryptomus, defx, delta, deribit, derive, digifinex, ellipx, exmo, fmfwio, gate, gateio, gemini, hashkey, hitbtc, hollaex, htx, huobi, huobijp, hyperliquid, idex, independentreserve, indodax, kraken, krakenfutures, kucoin, kucoinfutures, kuna, latoken, lbank, luno, mercado, mexc, myokx, ndax, novadax, oceanex, okcoin, okx, onetrading, oxfun, p2b, paradex, paymium, phemex, poloniex, probit, timex, tokocrypto, tradeogre, upbit, vertex, wavesexchange, whitebit, woo, woofipro, xt, yobit, zaif, zonda, };
549
+ export { version, Exchange, exchanges, pro, Precise, functions, errors, BaseError, ExchangeError, AuthenticationError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, OperationRejected, NoChange, MarginModeAlreadySet, MarketClosed, ManualInteractionNeeded, InsufficientFunds, InvalidAddress, AddressPending, InvalidOrder, OrderNotFound, OrderNotCached, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, ContractUnavailable, NotSupported, InvalidProxySettings, ExchangeClosedByUser, OperationFailed, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, ChecksumError, RequestTimeout, BadResponse, NullResponse, CancelPending, UnsubscribeError, Int, int, Str, Strings, Num, Bool, IndexType, OrderSide, OrderType, MarketType, SubType, Dict, NullableDict, List, NullableList, Fee, OHLCV, OHLCVC, implicitReturnType, Market, Currency, ConstructorArgs, Dictionary, MinMax, FeeInterface, TradingFeeInterface, MarketMarginModes, MarketInterface, Trade, Order, OrderBook, OrderBooks, Ticker, Transaction, Tickers, CurrencyInterface, Balance, BalanceAccount, Account, PartialBalances, Balances, DepositAddress, WithdrawalResponse, FundingRate, FundingRates, Position, BorrowInterest, LeverageTier, LedgerEntry, DepositWithdrawFeeNetwork, DepositWithdrawFee, TransferEntry, CrossBorrowRate, IsolatedBorrowRate, FundingRateHistory, OpenInterest, OpenInterests, Liquidation, OrderRequest, CancellationRequest, FundingHistory, MarginMode, Greeks, Conversion, Option, LastPrice, Leverage, LongShortRatio, MarginModification, Leverages, LastPrices, Currencies, TradingFees, MarginModes, OptionChain, IsolatedBorrowRates, CrossBorrowRates, LeverageTiers, alpaca, apex, ascendex, bequant, bigone, binance, binancecoinm, binanceus, binanceusdm, bingx, bit2c, bitbank, bitbns, bitfinex, bitflyer, bitget, bithumb, bitmart, bitmex, bitopro, bitrue, bitso, bitstamp, bitteam, bitvavo, blockchaincom, blofin, btcalpha, btcbox, btcmarkets, btcturk, bybit, cex, coinbase, coinbaseadvanced, coinbaseexchange, coinbaseinternational, coincatch, coincheck, coinex, coinlist, coinmate, coinmetro, coinone, coinsph, coinspot, cryptocom, cryptomus, defx, delta, deribit, derive, digifinex, ellipx, exmo, fmfwio, gate, gateio, gemini, hashkey, hitbtc, hollaex, htx, huobi, huobijp, hyperliquid, independentreserve, indodax, kraken, krakenfutures, kucoin, kucoinfutures, kuna, latoken, lbank, luno, mercado, mexc, myokx, ndax, novadax, oceanex, okcoin, okx, onetrading, oxfun, p2b, paradex, paymium, phemex, poloniex, probit, timex, tokocrypto, tradeogre, upbit, vertex, wavesexchange, whitebit, woo, woofipro, xt, yobit, zaif, zonda, };
559
550
  export default ccxt;