ccxt 4.4.69 → 4.4.71

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 (80) hide show
  1. package/README.md +5 -8
  2. package/dist/ccxt.browser.min.js +7 -7
  3. package/dist/cjs/ccxt.js +1 -6
  4. package/dist/cjs/src/abstract/poloniexfutures.js +1 -1
  5. package/dist/cjs/src/base/Exchange.js +22 -1
  6. package/dist/cjs/src/binance.js +107 -102
  7. package/dist/cjs/src/bingx.js +64 -42
  8. package/dist/cjs/src/bitget.js +50 -340
  9. package/dist/cjs/src/bitmart.js +15 -1
  10. package/dist/cjs/src/bitopro.js +1 -0
  11. package/dist/cjs/src/bitrue.js +1 -0
  12. package/dist/cjs/src/bybit.js +7 -0
  13. package/dist/cjs/src/cex.js +1 -0
  14. package/dist/cjs/src/coinbase.js +24 -4
  15. package/dist/cjs/src/coinbaseexchange.js +1 -0
  16. package/dist/cjs/src/deribit.js +1 -0
  17. package/dist/cjs/src/hashkey.js +4 -2
  18. package/dist/cjs/src/hyperliquid.js +18 -7
  19. package/dist/cjs/src/kraken.js +83 -6
  20. package/dist/cjs/src/kucoin.js +4 -2
  21. package/dist/cjs/src/mexc.js +8 -4
  22. package/dist/cjs/src/okx.js +62 -46
  23. package/dist/cjs/src/poloniex.js +1311 -81
  24. package/dist/cjs/src/poloniexfutures.js +1 -1
  25. package/dist/cjs/src/pro/binance.js +94 -94
  26. package/dist/cjs/src/pro/bingx.js +63 -52
  27. package/dist/cjs/src/pro/bitget.js +40 -7
  28. package/dist/cjs/src/pro/bybit.js +86 -38
  29. package/dist/cjs/src/pro/poloniexfutures.js +1 -1
  30. package/dist/cjs/src/tradeogre.js +22 -4
  31. package/dist/cjs/src/whitebit.js +4 -2
  32. package/js/ccxt.d.ts +3 -9
  33. package/js/ccxt.js +2 -6
  34. package/js/src/abstract/bingx.d.ts +1 -0
  35. package/js/src/abstract/bitmart.d.ts +1 -0
  36. package/js/src/abstract/bybit.d.ts +4 -0
  37. package/js/src/abstract/myokx.d.ts +3 -0
  38. package/js/src/abstract/okx.d.ts +3 -0
  39. package/js/src/abstract/poloniex.d.ts +36 -0
  40. package/js/src/abstract/poloniexfutures.js +6 -0
  41. package/js/src/abstract/tradeogre.d.ts +1 -1
  42. package/js/src/base/Exchange.d.ts +11 -2
  43. package/js/src/base/Exchange.js +22 -1
  44. package/js/src/base/types.d.ts +33 -2
  45. package/js/src/binance.d.ts +98 -97
  46. package/js/src/binance.js +107 -102
  47. package/js/src/bingx.js +64 -42
  48. package/js/src/bitget.d.ts +0 -1
  49. package/js/src/bitget.js +50 -340
  50. package/js/src/bitmart.d.ts +1 -0
  51. package/js/src/bitmart.js +15 -1
  52. package/js/src/bitopro.js +1 -0
  53. package/js/src/bitrue.js +1 -0
  54. package/js/src/bybit.js +7 -0
  55. package/js/src/cex.js +1 -0
  56. package/js/src/coinbase.js +24 -4
  57. package/js/src/coinbaseexchange.js +1 -0
  58. package/js/src/deribit.js +1 -0
  59. package/js/src/hashkey.js +4 -2
  60. package/js/src/hyperliquid.js +18 -7
  61. package/js/src/kraken.d.ts +1 -0
  62. package/js/src/kraken.js +83 -6
  63. package/js/src/kucoin.js +4 -2
  64. package/js/src/mexc.js +8 -4
  65. package/js/src/okx.d.ts +1 -0
  66. package/js/src/okx.js +62 -46
  67. package/js/src/poloniex.d.ts +109 -1
  68. package/js/src/poloniex.js +1311 -81
  69. package/js/src/poloniexfutures.js +6 -0
  70. package/js/src/pro/binance.d.ts +94 -94
  71. package/js/src/pro/binance.js +94 -94
  72. package/js/src/pro/bingx.js +63 -52
  73. package/js/src/pro/bitget.js +40 -7
  74. package/js/src/pro/bybit.d.ts +1 -0
  75. package/js/src/pro/bybit.js +86 -38
  76. package/js/src/pro/poloniexfutures.js +6 -0
  77. package/js/src/tradeogre.d.ts +1 -0
  78. package/js/src/tradeogre.js +22 -4
  79. package/js/src/whitebit.js +4 -2
  80. package/package.json +1 -1
@@ -42,6 +42,10 @@ export default class bitget extends bitgetRest {
42
42
  'public': 'wss://ws.bitget.com/v2/ws/public',
43
43
  'private': 'wss://ws.bitget.com/v2/ws/private',
44
44
  },
45
+ 'demo': {
46
+ 'public': 'wss://wspap.bitget.com/v2/ws/public',
47
+ 'private': 'wss://wspap.bitget.com/v2/ws/private',
48
+ },
45
49
  },
46
50
  },
47
51
  'options': {
@@ -1162,7 +1166,7 @@ export default class bitget extends bitgetRest {
1162
1166
  else {
1163
1167
  [instType, params] = this.getInstType(market, params);
1164
1168
  }
1165
- if (type === 'spot') {
1169
+ if (type === 'spot' && (symbol !== undefined)) {
1166
1170
  subscriptionHash = subscriptionHash + ':' + symbol;
1167
1171
  }
1168
1172
  if (isTrigger) {
@@ -1776,7 +1780,14 @@ export default class bitget extends bitgetRest {
1776
1780
  client.resolve(this.balance, messageHash);
1777
1781
  }
1778
1782
  async watchPublic(messageHash, args, params = {}) {
1779
- const url = this.urls['api']['ws']['public'];
1783
+ let url = this.urls['api']['ws']['public'];
1784
+ const sandboxMode = this.safeBool2(this.options, 'sandboxMode', 'sandbox', false);
1785
+ if (sandboxMode) {
1786
+ const instType = this.safeString(args, 'instType');
1787
+ if ((instType !== 'SCOIN-FUTURES') && (instType !== 'SUSDT-FUTURES') && (instType !== 'SUSDC-FUTURES')) {
1788
+ url = this.urls['api']['demo']['public'];
1789
+ }
1790
+ }
1780
1791
  const request = {
1781
1792
  'op': 'subscribe',
1782
1793
  'args': [args],
@@ -1785,7 +1796,14 @@ export default class bitget extends bitgetRest {
1785
1796
  return await this.watch(url, messageHash, message, messageHash);
1786
1797
  }
1787
1798
  async unWatchPublic(messageHash, args, params = {}) {
1788
- const url = this.urls['api']['ws']['public'];
1799
+ let url = this.urls['api']['ws']['public'];
1800
+ const sandboxMode = this.safeBool2(this.options, 'sandboxMode', 'sandbox', false);
1801
+ if (sandboxMode) {
1802
+ const instType = this.safeString(args, 'instType');
1803
+ if ((instType !== 'SCOIN-FUTURES') && (instType !== 'SUSDT-FUTURES') && (instType !== 'SUSDC-FUTURES')) {
1804
+ url = this.urls['api']['demo']['public'];
1805
+ }
1806
+ }
1789
1807
  const request = {
1790
1808
  'op': 'unsubscribe',
1791
1809
  'args': [args],
@@ -1794,7 +1812,15 @@ export default class bitget extends bitgetRest {
1794
1812
  return await this.watch(url, messageHash, message, messageHash);
1795
1813
  }
1796
1814
  async watchPublicMultiple(messageHashes, argsArray, params = {}) {
1797
- const url = this.urls['api']['ws']['public'];
1815
+ let url = this.urls['api']['ws']['public'];
1816
+ const sandboxMode = this.safeBool2(this.options, 'sandboxMode', 'sandbox', false);
1817
+ if (sandboxMode) {
1818
+ const argsArrayFirst = this.safeDict(argsArray, 0, {});
1819
+ const instType = this.safeString(argsArrayFirst, 'instType');
1820
+ if ((instType !== 'SCOIN-FUTURES') && (instType !== 'SUSDT-FUTURES') && (instType !== 'SUSDC-FUTURES')) {
1821
+ url = this.urls['api']['demo']['public'];
1822
+ }
1823
+ }
1798
1824
  const request = {
1799
1825
  'op': 'subscribe',
1800
1826
  'args': argsArray,
@@ -1804,7 +1830,7 @@ export default class bitget extends bitgetRest {
1804
1830
  }
1805
1831
  async authenticate(params = {}) {
1806
1832
  this.checkRequiredCredentials();
1807
- const url = this.urls['api']['ws']['private'];
1833
+ const url = this.safeString(params, 'url');
1808
1834
  const client = this.client(url);
1809
1835
  const messageHash = 'authenticated';
1810
1836
  const future = client.future(messageHash);
@@ -1831,8 +1857,15 @@ export default class bitget extends bitgetRest {
1831
1857
  return await future;
1832
1858
  }
1833
1859
  async watchPrivate(messageHash, subscriptionHash, args, params = {}) {
1834
- await this.authenticate();
1835
- const url = this.urls['api']['ws']['private'];
1860
+ let url = this.urls['api']['ws']['private'];
1861
+ const sandboxMode = this.safeBool2(this.options, 'sandboxMode', 'sandbox', false);
1862
+ if (sandboxMode) {
1863
+ const instType = this.safeString(args, 'instType');
1864
+ if ((instType !== 'SCOIN-FUTURES') && (instType !== 'SUSDT-FUTURES') && (instType !== 'SUSDC-FUTURES')) {
1865
+ url = this.urls['api']['demo']['private'];
1866
+ }
1867
+ }
1868
+ await this.authenticate({ 'url': url });
1836
1869
  const request = {
1837
1870
  'op': 'subscribe',
1838
1871
  'args': [args],
@@ -329,6 +329,7 @@ export default class bybit extends bybitRest {
329
329
  * @param {int} [since] the earliest time in ms to fetch liquidations for
330
330
  * @param {int} [limit] the maximum number of liquidation structures to retrieve
331
331
  * @param {object} [params] exchange specific parameters for the bitmex api endpoint
332
+ * @param {string} [params.method] exchange specific method, supported: liquidation, allLiquidation
332
333
  * @returns {object} an array of [liquidation structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#liquidation-structure}
333
334
  */
334
335
  watchLiquidations(symbol: string, since?: Int, limit?: Int, params?: {}): Promise<Liquidation[]>;
@@ -1560,6 +1560,7 @@ export default class bybit extends bybitRest {
1560
1560
  * @param {int} [since] the earliest time in ms to fetch liquidations for
1561
1561
  * @param {int} [limit] the maximum number of liquidation structures to retrieve
1562
1562
  * @param {object} [params] exchange specific parameters for the bitmex api endpoint
1563
+ * @param {string} [params.method] exchange specific method, supported: liquidation, allLiquidation
1563
1564
  * @returns {object} an array of [liquidation structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#liquidation-structure}
1564
1565
  */
1565
1566
  async watchLiquidations(symbol, since = undefined, limit = undefined, params = {}) {
@@ -1568,8 +1569,10 @@ export default class bybit extends bybitRest {
1568
1569
  symbol = market['symbol'];
1569
1570
  const url = await this.getUrlByMarketType(symbol, false, 'watchLiquidations', params);
1570
1571
  params = this.cleanParams(params);
1572
+ let method = undefined;
1573
+ [method, params] = this.handleOptionAndParams(params, 'watchLiquidations', 'method', 'liquidation');
1571
1574
  const messageHash = 'liquidations::' + symbol;
1572
- const topic = 'liquidation.' + market['id'];
1575
+ const topic = method + '.' + market['id'];
1573
1576
  const newLiquidation = await this.watchTopics(url, [messageHash], [topic], params);
1574
1577
  if (this.newUpdates) {
1575
1578
  return newLiquidation;
@@ -1578,53 +1581,97 @@ export default class bybit extends bybitRest {
1578
1581
  }
1579
1582
  handleLiquidation(client, message) {
1580
1583
  //
1581
- // {
1582
- // "data": {
1583
- // "price": "0.03803",
1584
- // "side": "Buy",
1585
- // "size": "1637",
1586
- // "symbol": "GALAUSDT",
1587
- // "updatedTime": 1673251091822
1588
- // },
1589
- // "topic": "liquidation.GALAUSDT",
1590
- // "ts": 1673251091822,
1591
- // "type": "snapshot"
1592
- // }
1584
+ // {
1585
+ // "data": {
1586
+ // "price": "0.03803",
1587
+ // "side": "Buy",
1588
+ // "size": "1637",
1589
+ // "symbol": "GALAUSDT",
1590
+ // "updatedTime": 1673251091822
1591
+ // },
1592
+ // "topic": "liquidation.GALAUSDT",
1593
+ // "ts": 1673251091822,
1594
+ // "type": "snapshot"
1595
+ // }
1593
1596
  //
1594
- const rawLiquidation = this.safeDict(message, 'data', {});
1595
- const marketId = this.safeString(rawLiquidation, 'symbol');
1596
- const market = this.safeMarket(marketId, undefined, '', 'contract');
1597
- const symbol = market['symbol'];
1598
- const liquidation = this.parseWsLiquidation(rawLiquidation, market);
1599
- let liquidations = this.safeValue(this.liquidations, symbol);
1600
- if (liquidations === undefined) {
1601
- const limit = this.safeInteger(this.options, 'liquidationsLimit', 1000);
1602
- liquidations = new ArrayCache(limit);
1603
- }
1604
- liquidations.append(liquidation);
1605
- this.liquidations[symbol] = liquidations;
1606
- client.resolve([liquidation], 'liquidations');
1607
- client.resolve([liquidation], 'liquidations::' + symbol);
1597
+ // {
1598
+ // "topic": "allLiquidation.ROSEUSDT",
1599
+ // "type": "snapshot",
1600
+ // "ts": 1739502303204,
1601
+ // "data": [
1602
+ // {
1603
+ // "T": 1739502302929,
1604
+ // "s": "ROSEUSDT",
1605
+ // "S": "Sell",
1606
+ // "v": "20000",
1607
+ // "p": "0.04499"
1608
+ // }
1609
+ // ]
1610
+ // }
1611
+ //
1612
+ if (Array.isArray(message['data'])) {
1613
+ const rawLiquidations = this.safeList(message, 'data', []);
1614
+ for (let i = 0; i < rawLiquidations.length; i++) {
1615
+ const rawLiquidation = rawLiquidations[i];
1616
+ const marketId = this.safeString(rawLiquidation, 's');
1617
+ const market = this.safeMarket(marketId, undefined, '', 'contract');
1618
+ const symbol = market['symbol'];
1619
+ const liquidation = this.parseWsLiquidation(rawLiquidation, market);
1620
+ let liquidations = this.safeValue(this.liquidations, symbol);
1621
+ if (liquidations === undefined) {
1622
+ const limit = this.safeInteger(this.options, 'liquidationsLimit', 1000);
1623
+ liquidations = new ArrayCache(limit);
1624
+ }
1625
+ liquidations.append(liquidation);
1626
+ this.liquidations[symbol] = liquidations;
1627
+ client.resolve([liquidation], 'liquidations');
1628
+ client.resolve([liquidation], 'liquidations::' + symbol);
1629
+ }
1630
+ }
1631
+ else {
1632
+ const rawLiquidation = this.safeDict(message, 'data', {});
1633
+ const marketId = this.safeString(rawLiquidation, 'symbol');
1634
+ const market = this.safeMarket(marketId, undefined, '', 'contract');
1635
+ const symbol = market['symbol'];
1636
+ const liquidation = this.parseWsLiquidation(rawLiquidation, market);
1637
+ let liquidations = this.safeValue(this.liquidations, symbol);
1638
+ if (liquidations === undefined) {
1639
+ const limit = this.safeInteger(this.options, 'liquidationsLimit', 1000);
1640
+ liquidations = new ArrayCache(limit);
1641
+ }
1642
+ liquidations.append(liquidation);
1643
+ this.liquidations[symbol] = liquidations;
1644
+ client.resolve([liquidation], 'liquidations');
1645
+ client.resolve([liquidation], 'liquidations::' + symbol);
1646
+ }
1608
1647
  }
1609
1648
  parseWsLiquidation(liquidation, market = undefined) {
1610
1649
  //
1611
- // {
1612
- // "price": "0.03803",
1613
- // "side": "Buy",
1614
- // "size": "1637",
1615
- // "symbol": "GALAUSDT",
1616
- // "updatedTime": 1673251091822
1617
- // }
1650
+ // {
1651
+ // "price": "0.03803",
1652
+ // "side": "Buy",
1653
+ // "size": "1637",
1654
+ // "symbol": "GALAUSDT",
1655
+ // "updatedTime": 1673251091822
1656
+ // }
1657
+ //
1658
+ // {
1659
+ // "T": 1739502302929,
1660
+ // "s": "ROSEUSDT",
1661
+ // "S": "Sell",
1662
+ // "v": "20000",
1663
+ // "p": "0.04499"
1664
+ // }
1618
1665
  //
1619
- const marketId = this.safeString(liquidation, 'symbol');
1666
+ const marketId = this.safeString2(liquidation, 'symbol', 's');
1620
1667
  market = this.safeMarket(marketId, market, '', 'contract');
1621
- const timestamp = this.safeInteger(liquidation, 'updatedTime');
1668
+ const timestamp = this.safeInteger2(liquidation, 'updatedTime', 'T');
1622
1669
  return this.safeLiquidation({
1623
1670
  'info': liquidation,
1624
1671
  'symbol': market['symbol'],
1625
- 'contracts': this.safeNumber(liquidation, 'size'),
1672
+ 'contracts': this.safeNumber2(liquidation, 'size', 'v'),
1626
1673
  'contractSize': this.safeNumber(market, 'contractSize'),
1627
- 'price': this.safeNumber(liquidation, 'price'),
1674
+ 'price': this.safeNumber2(liquidation, 'price', 'p'),
1628
1675
  'baseValue': undefined,
1629
1676
  'quoteValue': undefined,
1630
1677
  'timestamp': timestamp,
@@ -2438,6 +2485,7 @@ export default class bybit extends bybitRest {
2438
2485
  'user.openapi.perp.trade': this.handleMyTrades,
2439
2486
  'position': this.handlePositions,
2440
2487
  'liquidation': this.handleLiquidation,
2488
+ 'allLiquidation': this.handleLiquidation,
2441
2489
  'pong': this.handlePong,
2442
2490
  'order.create': this.handleOrderWs,
2443
2491
  'order.amend': this.handleOrderWs,
@@ -1,3 +1,9 @@
1
+ // ----------------------------------------------------------------------------
2
+
3
+ // PLEASE DO NOT EDIT THIS FILE, IT IS GENERATED AND WILL BE OVERWRITTEN:
4
+ // https://github.com/ccxt/ccxt/blob/master/CONTRIBUTING.md#how-to-contribute-code
5
+ // EDIT THE CORRESPONDENT .ts FILE INSTEAD
6
+
1
7
  // ---------------------------------------------------------------------------
2
8
  import poloniexfuturesRest from '../poloniexfutures.js';
3
9
  import { AuthenticationError, BadRequest, ChecksumError } from '../base/errors.js';
@@ -78,6 +78,7 @@ export default class tradeogre extends Exchange {
78
78
  * @name tradeogre#fetchBalance
79
79
  * @description query for balance and get the amount of funds available for trading or funds locked in orders
80
80
  * @param {object} [params] extra parameters specific to the exchange API endpoint
81
+ * @param {string} [params.currency] currency to fetch the balance for
81
82
  * @returns {object} a [balance structure]{@link https://docs.ccxt.com/#/?id=balance-structure}
82
83
  */
83
84
  fetchBalance(params?: {}): Promise<import("./base/types.js").Balances>;
@@ -131,7 +131,6 @@ export default class tradeogre extends Exchange {
131
131
  },
132
132
  'private': {
133
133
  'get': {
134
- 'account/balance': 1,
135
134
  'account/balances': 1,
136
135
  'account/order/{uuid}': 1,
137
136
  },
@@ -141,6 +140,7 @@ export default class tradeogre extends Exchange {
141
140
  'order/cancel': 1,
142
141
  'orders': 1,
143
142
  'account/orders': 1,
143
+ 'account/balance': 1,
144
144
  },
145
145
  },
146
146
  },
@@ -593,11 +593,29 @@ export default class tradeogre extends Exchange {
593
593
  * @name tradeogre#fetchBalance
594
594
  * @description query for balance and get the amount of funds available for trading or funds locked in orders
595
595
  * @param {object} [params] extra parameters specific to the exchange API endpoint
596
+ * @param {string} [params.currency] currency to fetch the balance for
596
597
  * @returns {object} a [balance structure]{@link https://docs.ccxt.com/#/?id=balance-structure}
597
598
  */
598
599
  async fetchBalance(params = {}) {
599
600
  await this.loadMarkets();
600
- const response = await this.privateGetAccountBalances(params);
601
+ let response = undefined;
602
+ const currency = this.safeString(params, 'currency');
603
+ if (currency !== undefined) {
604
+ response = await this.privatePostAccountBalance(params);
605
+ const singleCurrencyresult = {
606
+ 'info': response,
607
+ };
608
+ const code = this.safeCurrencyCode(currency);
609
+ const account = {
610
+ 'total': this.safeNumber(response, 'balance'),
611
+ 'free': this.safeNumber(response, 'available'),
612
+ };
613
+ singleCurrencyresult[code] = account;
614
+ return this.safeBalance(singleCurrencyresult);
615
+ }
616
+ else {
617
+ response = await this.privateGetAccountBalances(params);
618
+ }
601
619
  const result = this.safeDict(response, 'balances', {});
602
620
  return this.parseBalance(result);
603
621
  }
@@ -761,11 +779,11 @@ export default class tradeogre extends Exchange {
761
779
  'side': this.safeString(order, 'type'),
762
780
  'price': this.safeString(order, 'price'),
763
781
  'triggerPrice': undefined,
764
- 'amount': this.safeString(order, 'quantity'),
782
+ 'amount': undefined,
765
783
  'cost': undefined,
766
784
  'average': undefined,
767
785
  'filled': this.safeString(order, 'fulfilled'),
768
- 'remaining': undefined,
786
+ 'remaining': this.safeString(order, 'quantity'),
769
787
  'status': undefined,
770
788
  'fee': {
771
789
  'currency': undefined,
@@ -1354,9 +1354,11 @@ export default class whitebit extends Exchange {
1354
1354
  * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
1355
1355
  */
1356
1356
  async createMarketOrderWithCost(symbol, side, cost, params = {}) {
1357
- params['cost'] = cost;
1357
+ const req = {
1358
+ 'cost': cost,
1359
+ };
1358
1360
  // only buy side is supported
1359
- return await this.createOrder(symbol, 'market', side, 0, undefined, params);
1361
+ return await this.createOrder(symbol, 'market', side, 0, undefined, this.extend(req, params));
1360
1362
  }
1361
1363
  /**
1362
1364
  * @method
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ccxt",
3
- "version": "4.4.69",
3
+ "version": "4.4.71",
4
4
  "description": "A JavaScript / TypeScript / Python / C# / PHP cryptocurrency trading library with support for 100+ exchanges",
5
5
  "unpkg": "dist/ccxt.browser.min.js",
6
6
  "type": "module",