ccxt 4.2.38 → 4.2.39

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 (106) hide show
  1. package/README.md +3 -3
  2. package/dist/ccxt.browser.js +425 -105
  3. package/dist/ccxt.browser.min.js +3 -3
  4. package/dist/cjs/ccxt.js +1 -1
  5. package/dist/cjs/src/base/Exchange.js +14 -2
  6. package/dist/cjs/src/binance.js +156 -35
  7. package/dist/cjs/src/bitget.js +1 -1
  8. package/dist/cjs/src/bitso.js +18 -2
  9. package/dist/cjs/src/bitstamp.js +24 -2
  10. package/dist/cjs/src/bl3p.js +6 -0
  11. package/dist/cjs/src/blockchaincom.js +21 -0
  12. package/dist/cjs/src/btcalpha.js +9 -0
  13. package/dist/cjs/src/btcbox.js +9 -0
  14. package/dist/cjs/src/btcmarkets.js +19 -0
  15. package/dist/cjs/src/coinbase.js +13 -2
  16. package/dist/cjs/src/krakenfutures.js +7 -14
  17. package/dist/cjs/src/luno.js +1 -1
  18. package/dist/cjs/src/okx.js +2 -2
  19. package/dist/cjs/src/poloniexfutures.js +11 -5
  20. package/dist/cjs/src/pro/bitmart.js +110 -35
  21. package/dist/cjs/src/pro/mexc.js +1 -1
  22. package/dist/cjs/src/wavesexchange.js +1 -1
  23. package/dist/cjs/src/woo.js +1 -1
  24. package/js/ccxt.d.ts +1 -1
  25. package/js/ccxt.js +1 -1
  26. package/js/src/abstract/coinbase.d.ts +1 -0
  27. package/js/src/abstract/okx.d.ts +1 -0
  28. package/js/src/ascendex.d.ts +2 -2
  29. package/js/src/base/Exchange.d.ts +4 -0
  30. package/js/src/base/Exchange.js +14 -2
  31. package/js/src/base/types.d.ts +2 -0
  32. package/js/src/bigone.d.ts +2 -2
  33. package/js/src/binance.d.ts +8 -8
  34. package/js/src/binance.js +156 -35
  35. package/js/src/bingx.d.ts +5 -5
  36. package/js/src/bitfinex.d.ts +3 -3
  37. package/js/src/bitfinex2.d.ts +2 -2
  38. package/js/src/bitget.d.ts +5 -5
  39. package/js/src/bitget.js +1 -1
  40. package/js/src/bitmart.d.ts +2 -2
  41. package/js/src/bitmex.d.ts +2 -2
  42. package/js/src/bitrue.d.ts +2 -2
  43. package/js/src/bitso.d.ts +1 -1
  44. package/js/src/bitso.js +18 -2
  45. package/js/src/bitstamp.d.ts +1 -1
  46. package/js/src/bitstamp.js +24 -2
  47. package/js/src/bitvavo.d.ts +1 -1
  48. package/js/src/bl3p.js +6 -0
  49. package/js/src/blockchaincom.js +21 -0
  50. package/js/src/blofin.d.ts +2 -2
  51. package/js/src/btcalpha.js +9 -0
  52. package/js/src/btcbox.js +9 -0
  53. package/js/src/btcmarkets.js +19 -0
  54. package/js/src/bybit.d.ts +7 -7
  55. package/js/src/cex.d.ts +1 -1
  56. package/js/src/coinbase.d.ts +2 -2
  57. package/js/src/coinbase.js +13 -2
  58. package/js/src/coinex.d.ts +4 -4
  59. package/js/src/coinlist.d.ts +2 -2
  60. package/js/src/coinone.d.ts +1 -1
  61. package/js/src/delta.d.ts +2 -2
  62. package/js/src/deribit.d.ts +3 -3
  63. package/js/src/digifinex.d.ts +3 -3
  64. package/js/src/exmo.d.ts +2 -2
  65. package/js/src/gate.d.ts +6 -6
  66. package/js/src/hitbtc.d.ts +2 -2
  67. package/js/src/hollaex.d.ts +1 -1
  68. package/js/src/htx.d.ts +3 -3
  69. package/js/src/huobijp.d.ts +1 -1
  70. package/js/src/kraken.d.ts +2 -2
  71. package/js/src/krakenfutures.d.ts +2 -2
  72. package/js/src/krakenfutures.js +7 -14
  73. package/js/src/kucoin.d.ts +5 -5
  74. package/js/src/kucoinfutures.d.ts +2 -2
  75. package/js/src/latoken.d.ts +1 -1
  76. package/js/src/lbank.d.ts +2 -2
  77. package/js/src/luno.d.ts +1 -1
  78. package/js/src/luno.js +1 -1
  79. package/js/src/mexc.d.ts +4 -4
  80. package/js/src/ndax.d.ts +1 -1
  81. package/js/src/novadax.d.ts +1 -1
  82. package/js/src/okcoin.d.ts +2 -2
  83. package/js/src/okx.d.ts +7 -7
  84. package/js/src/okx.js +2 -2
  85. package/js/src/paymium.d.ts +2 -2
  86. package/js/src/phemex.d.ts +4 -4
  87. package/js/src/poloniex.d.ts +2 -2
  88. package/js/src/poloniexfutures.d.ts +2 -2
  89. package/js/src/poloniexfutures.js +11 -5
  90. package/js/src/pro/bitmart.d.ts +2 -0
  91. package/js/src/pro/bitmart.js +110 -35
  92. package/js/src/pro/bitvavo.d.ts +1 -1
  93. package/js/src/pro/cex.d.ts +2 -2
  94. package/js/src/pro/coinbase.d.ts +2 -2
  95. package/js/src/pro/coinex.d.ts +1 -1
  96. package/js/src/pro/lbank.d.ts +1 -1
  97. package/js/src/pro/mexc.js +1 -1
  98. package/js/src/probit.d.ts +1 -1
  99. package/js/src/timex.d.ts +1 -1
  100. package/js/src/upbit.d.ts +1 -1
  101. package/js/src/wavesexchange.js +1 -1
  102. package/js/src/whitebit.d.ts +2 -2
  103. package/js/src/woo.d.ts +3 -3
  104. package/js/src/woo.js +1 -1
  105. package/js/src/zonda.d.ts +3 -3
  106. package/package.json +2 -2
@@ -194,6 +194,7 @@ class btcmarkets extends btcmarkets$1 {
194
194
  * @method
195
195
  * @name btcmarkets#fetchDepositsWithdrawals
196
196
  * @description fetch history of deposits and withdrawals
197
+ * @see https://docs.btcmarkets.net/v3/#tag/Fund-Management-APIs/paths/~1v3~1transfers/get
197
198
  * @param {string} [code] unified currency code for the currency of the deposit/withdrawals, default is undefined
198
199
  * @param {int} [since] timestamp in ms of the earliest deposit/withdrawal, default is undefined
199
200
  * @param {int} [limit] max number of deposit/withdrawals to return, default is undefined
@@ -207,6 +208,7 @@ class btcmarkets extends btcmarkets$1 {
207
208
  * @method
208
209
  * @name btcmarkets#fetchDeposits
209
210
  * @description fetch all deposits made to an account
211
+ * @see https://docs.btcmarkets.net/v3/#tag/Fund-Management-APIs/paths/~1v3~1deposits/get
210
212
  * @param {string} code unified currency code
211
213
  * @param {int} [since] the earliest time in ms to fetch deposits for
212
214
  * @param {int} [limit] the maximum number of deposits structures to retrieve
@@ -220,6 +222,7 @@ class btcmarkets extends btcmarkets$1 {
220
222
  * @method
221
223
  * @name btcmarkets#fetchWithdrawals
222
224
  * @description fetch all withdrawals made from an account
225
+ * @see https://docs.btcmarkets.net/v3/#tag/Fund-Management-APIs/paths/~1v3~1withdrawals/get
223
226
  * @param {string} code unified currency code
224
227
  * @param {int} [since] the earliest time in ms to fetch withdrawals for
225
228
  * @param {int} [limit] the maximum number of withdrawals structures to retrieve
@@ -353,6 +356,7 @@ class btcmarkets extends btcmarkets$1 {
353
356
  * @method
354
357
  * @name btcmarkets#fetchMarkets
355
358
  * @description retrieves data on all markets for btcmarkets
359
+ * @see https://docs.btcmarkets.net/v3/#tag/Market-Data-APIs/paths/~1v3~1markets/get
356
360
  * @param {object} [params] extra parameters specific to the exchange API endpoint
357
361
  * @returns {object[]} an array of objects representing market data
358
362
  */
@@ -444,6 +448,7 @@ class btcmarkets extends btcmarkets$1 {
444
448
  * @method
445
449
  * @name btcmarkets#fetchTime
446
450
  * @description fetches the current integer timestamp in milliseconds from the exchange server
451
+ * @see https://docs.btcmarkets.net/v3/#tag/Misc-APIs/paths/~1v3~1time/get
447
452
  * @param {object} [params] extra parameters specific to the exchange API endpoint
448
453
  * @returns {int} the current integer timestamp in milliseconds from the exchange server
449
454
  */
@@ -473,6 +478,7 @@ class btcmarkets extends btcmarkets$1 {
473
478
  * @method
474
479
  * @name btcmarkets#fetchBalance
475
480
  * @description query for balance and get the amount of funds available for trading or funds locked in orders
481
+ * @see https://docs.btcmarkets.net/v3/#tag/Account-APIs/paths/~1v3~1accounts~1me~1balances/get
476
482
  * @param {object} [params] extra parameters specific to the exchange API endpoint
477
483
  * @returns {object} a [balance structure]{@link https://docs.ccxt.com/#/?id=balance-structure}
478
484
  */
@@ -505,6 +511,7 @@ class btcmarkets extends btcmarkets$1 {
505
511
  * @method
506
512
  * @name btcmarkets#fetchOHLCV
507
513
  * @description fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
514
+ * @see https://docs.btcmarkets.net/v3/#tag/Market-Data-APIs/paths/~1v3~1markets~1{marketId}~1candles/get
508
515
  * @param {string} symbol unified symbol of the market to fetch OHLCV data for
509
516
  * @param {string} timeframe the length of time each candle represents
510
517
  * @param {int} [since] timestamp in ms of the earliest candle to fetch
@@ -544,6 +551,7 @@ class btcmarkets extends btcmarkets$1 {
544
551
  * @method
545
552
  * @name btcmarkets#fetchOrderBook
546
553
  * @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
554
+ * @see https://docs.btcmarkets.net/v3/#tag/Market-Data-APIs/paths/~1v3~1markets~1{marketId}~1orderbook/get
547
555
  * @param {string} symbol unified symbol of the market to fetch the order book for
548
556
  * @param {int} [limit] the maximum amount of order book entries to return
549
557
  * @param {object} [params] extra parameters specific to the exchange API endpoint
@@ -631,6 +639,7 @@ class btcmarkets extends btcmarkets$1 {
631
639
  * @method
632
640
  * @name btcmarkets#fetchTicker
633
641
  * @description fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
642
+ * @see https://docs.btcmarkets.net/v3/#tag/Market-Data-APIs/paths/~1v3~1markets~1{marketId}~1ticker/get
634
643
  * @param {string} symbol unified symbol of the market to fetch the ticker for
635
644
  * @param {object} [params] extra parameters specific to the exchange API endpoint
636
645
  * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
@@ -739,6 +748,7 @@ class btcmarkets extends btcmarkets$1 {
739
748
  * @method
740
749
  * @name btcmarkets#fetchTrades
741
750
  * @description get the list of most recent trades for a particular symbol
751
+ * @see https://docs.btcmarkets.net/v3/#tag/Market-Data-APIs/paths/~1v3~1markets~1{marketId}~1trades/get
742
752
  * @param {string} symbol unified symbol of the market to fetch trades for
743
753
  * @param {int} [since] timestamp in ms of the earliest trade to fetch
744
754
  * @param {int} [limit] the maximum amount of trades to fetch
@@ -766,6 +776,7 @@ class btcmarkets extends btcmarkets$1 {
766
776
  * @method
767
777
  * @name btcmarkets#createOrder
768
778
  * @description create a trade order
779
+ * @see https://docs.btcmarkets.net/v3/#tag/Order-Placement-APIs/paths/~1v3~1orders/post
769
780
  * @param {string} symbol unified symbol of the market to create an order in
770
781
  * @param {string} type 'market' or 'limit'
771
782
  * @param {string} side 'buy' or 'sell'
@@ -866,6 +877,7 @@ class btcmarkets extends btcmarkets$1 {
866
877
  * @method
867
878
  * @name btcmarkets#cancelOrders
868
879
  * @description cancel multiple orders
880
+ * @see https://docs.btcmarkets.net/v3/#tag/Batch-Order-APIs/paths/~1v3~1batchorders~1{ids}/delete
869
881
  * @param {string[]} ids order ids
870
882
  * @param {string} symbol not used by btcmarkets cancelOrders ()
871
883
  * @param {object} [params] extra parameters specific to the exchange API endpoint
@@ -885,6 +897,7 @@ class btcmarkets extends btcmarkets$1 {
885
897
  * @method
886
898
  * @name btcmarkets#cancelOrder
887
899
  * @description cancels an open order
900
+ * @see https://docs.btcmarkets.net/v3/#operation/cancelOrder
888
901
  * @param {string} id order id
889
902
  * @param {string} symbol not used by btcmarket cancelOrder ()
890
903
  * @param {object} [params] extra parameters specific to the exchange API endpoint
@@ -1004,6 +1017,7 @@ class btcmarkets extends btcmarkets$1 {
1004
1017
  * @method
1005
1018
  * @name btcmarkets#fetchOrder
1006
1019
  * @description fetches information on an order made by the user
1020
+ * @see https://docs.btcmarkets.net/v3/#operation/getOrderById
1007
1021
  * @param {string} symbol not used by btcmarkets fetchOrder
1008
1022
  * @param {object} [params] extra parameters specific to the exchange API endpoint
1009
1023
  * @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
@@ -1020,6 +1034,7 @@ class btcmarkets extends btcmarkets$1 {
1020
1034
  * @method
1021
1035
  * @name btcmarkets#fetchOrders
1022
1036
  * @description fetches information on multiple orders made by the user
1037
+ * @see https://docs.btcmarkets.net/v3/#operation/listOrders
1023
1038
  * @param {string} symbol unified market symbol of the market orders were made in
1024
1039
  * @param {int} [since] the earliest time in ms to fetch orders for
1025
1040
  * @param {int} [limit] the maximum number of order structures to retrieve
@@ -1049,6 +1064,7 @@ class btcmarkets extends btcmarkets$1 {
1049
1064
  * @method
1050
1065
  * @name btcmarkets#fetchOpenOrders
1051
1066
  * @description fetch all unfilled currently open orders
1067
+ * @see https://docs.btcmarkets.net/v3/#operation/listOrders
1052
1068
  * @param {string} symbol unified market symbol
1053
1069
  * @param {int} [since] the earliest time in ms to fetch open orders for
1054
1070
  * @param {int} [limit] the maximum number of open orders structures to retrieve
@@ -1063,6 +1079,7 @@ class btcmarkets extends btcmarkets$1 {
1063
1079
  * @method
1064
1080
  * @name btcmarkets#fetchClosedOrders
1065
1081
  * @description fetches information on multiple closed orders made by the user
1082
+ * @see https://docs.btcmarkets.net/v3/#operation/listOrders
1066
1083
  * @param {string} symbol unified market symbol of the market orders were made in
1067
1084
  * @param {int} [since] the earliest time in ms to fetch orders for
1068
1085
  * @param {int} [limit] the maximum number of order structures to retrieve
@@ -1077,6 +1094,7 @@ class btcmarkets extends btcmarkets$1 {
1077
1094
  * @method
1078
1095
  * @name btcmarkets#fetchMyTrades
1079
1096
  * @description fetch all trades made by the user
1097
+ * @see https://docs.btcmarkets.net/v3/#operation/getTrades
1080
1098
  * @param {string} symbol unified market symbol
1081
1099
  * @param {int} [since] the earliest time in ms to fetch trades for
1082
1100
  * @param {int} [limit] the maximum number of trades structures to retrieve
@@ -1131,6 +1149,7 @@ class btcmarkets extends btcmarkets$1 {
1131
1149
  * @method
1132
1150
  * @name btcmarkets#withdraw
1133
1151
  * @description make a withdrawal
1152
+ * @see https://docs.btcmarkets.net/v3/#tag/Fund-Management-APIs/paths/~1v3~1withdrawals/post
1134
1153
  * @param {string} code unified currency code
1135
1154
  * @param {float} amount the amount to withdraw
1136
1155
  * @param {string} address the address to withdraw to
@@ -217,6 +217,7 @@ class coinbase extends coinbase$1 {
217
217
  'brokerage/orders/batch_cancel',
218
218
  'brokerage/orders/edit',
219
219
  'brokerage/orders/edit_preview',
220
+ 'brokerage/orders/preview',
220
221
  'brokerage/portfolios',
221
222
  'brokerage/portfolios/move_funds',
222
223
  'brokerage/convert/quote',
@@ -2212,11 +2213,12 @@ class coinbase extends coinbase$1 {
2212
2213
  * @param {string} [params.stop_direction] 'UNKNOWN_STOP_DIRECTION', 'STOP_DIRECTION_STOP_UP', 'STOP_DIRECTION_STOP_DOWN' the direction the stopPrice is triggered from
2213
2214
  * @param {string} [params.end_time] '2023-05-25T17:01:05.092Z' for 'GTD' orders
2214
2215
  * @param {float} [params.cost] *spot market buy only* the quote quantity that can be used as an alternative for the amount
2216
+ * @param {boolean} [params.preview] default to false, wether to use the test/preview endpoint or not
2215
2217
  * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
2216
2218
  */
2217
2219
  await this.loadMarkets();
2218
2220
  const market = this.market(symbol);
2219
- const request = {
2221
+ let request = {
2220
2222
  'client_order_id': this.uuid(),
2221
2223
  'product_id': market['id'],
2222
2224
  'side': side.toUpperCase(),
@@ -2351,7 +2353,16 @@ class coinbase extends coinbase$1 {
2351
2353
  }
2352
2354
  }
2353
2355
  params = this.omit(params, ['timeInForce', 'triggerPrice', 'stopLossPrice', 'takeProfitPrice', 'stopPrice', 'stop_price', 'stopDirection', 'stop_direction', 'clientOrderId', 'postOnly', 'post_only', 'end_time']);
2354
- const response = await this.v3PrivatePostBrokerageOrders(this.extend(request, params));
2356
+ const preview = this.safeValue2(params, 'preview', 'test', false);
2357
+ let response = undefined;
2358
+ if (preview) {
2359
+ params = this.omit(params, ['preview', 'test']);
2360
+ request = this.omit(request, 'client_order_id');
2361
+ response = await this.v3PrivatePostBrokerageOrdersPreview(this.extend(request, params));
2362
+ }
2363
+ else {
2364
+ response = await this.v3PrivatePostBrokerageOrders(this.extend(request, params));
2365
+ }
2355
2366
  //
2356
2367
  // successful order
2357
2368
  //
@@ -799,37 +799,30 @@ class krakenfutures extends krakenfutures$1 {
799
799
  id = this.safeString(trade, 'executionId');
800
800
  }
801
801
  let order = this.safeString(trade, 'order_id');
802
- let symbolId = this.safeString(trade, 'symbol');
802
+ let marketId = this.safeString(trade, 'symbol');
803
803
  let side = this.safeString(trade, 'side');
804
804
  let type = undefined;
805
805
  const priorEdit = this.safeValue(trade, 'orderPriorEdit');
806
806
  const priorExecution = this.safeValue(trade, 'orderPriorExecution');
807
807
  if (priorExecution !== undefined) {
808
808
  order = this.safeString(priorExecution, 'orderId');
809
- symbolId = this.safeString(priorExecution, 'symbol');
809
+ marketId = this.safeString(priorExecution, 'symbol');
810
810
  side = this.safeString(priorExecution, 'side');
811
811
  type = this.safeString(priorExecution, 'type');
812
812
  }
813
813
  else if (priorEdit !== undefined) {
814
814
  order = this.safeString(priorEdit, 'orderId');
815
- symbolId = this.safeString(priorEdit, 'symbol');
815
+ marketId = this.safeString(priorEdit, 'symbol');
816
816
  side = this.safeString(priorEdit, 'type');
817
817
  type = this.safeString(priorEdit, 'type');
818
818
  }
819
819
  if (type !== undefined) {
820
820
  type = this.parseOrderType(type);
821
821
  }
822
- let symbol = undefined;
823
- if (symbolId !== undefined) {
824
- market = this.safeValue(this.markets_by_id, symbolId);
825
- if (market === undefined) {
826
- symbol = symbolId;
827
- }
828
- }
829
- symbol = this.safeString(market, 'symbol', symbol);
822
+ market = this.safeMarket(marketId, market);
830
823
  let cost = undefined;
824
+ const linear = this.safeBool(market, 'linear');
831
825
  if ((amount !== undefined) && (price !== undefined) && (market !== undefined)) {
832
- const linear = this.safeValue(market, 'linear');
833
826
  if (linear) {
834
827
  cost = Precise["default"].stringMul(amount, price); // in quote
835
828
  }
@@ -852,15 +845,15 @@ class krakenfutures extends krakenfutures$1 {
852
845
  return this.safeTrade({
853
846
  'info': trade,
854
847
  'id': id,
848
+ 'symbol': this.safeString(market, 'symbol'),
855
849
  'timestamp': timestamp,
856
850
  'datetime': this.iso8601(timestamp),
857
- 'symbol': symbol,
858
851
  'order': order,
859
852
  'type': type,
860
853
  'side': side,
861
854
  'takerOrMaker': takerOrMaker,
862
855
  'price': price,
863
- 'amount': amount,
856
+ 'amount': linear ? amount : undefined,
864
857
  'cost': cost,
865
858
  'fee': undefined,
866
859
  });
@@ -759,7 +759,7 @@ class luno extends luno$1 {
759
759
  'pair': market['id'],
760
760
  };
761
761
  if (since !== undefined) {
762
- request['since'] = parseInt(since);
762
+ request['since'] = this.parseToInt(since);
763
763
  }
764
764
  else {
765
765
  const duration = 1000 * 1000 * this.parseTimeframe(timeframe);
@@ -281,6 +281,7 @@ class okx extends okx$1 {
281
281
  'trade/easy-convert-history': 20,
282
282
  'trade/one-click-repay-currency-list': 20,
283
283
  'trade/one-click-repay-history': 20,
284
+ 'trade/account-rate-limit': 1,
284
285
  // asset
285
286
  'asset/currencies': 5 / 3,
286
287
  'asset/balances': 5 / 3,
@@ -1625,7 +1626,7 @@ class okx extends okx$1 {
1625
1626
  if ((networkId !== undefined) && (networkId.indexOf('-') >= 0)) {
1626
1627
  const parts = networkId.split('-');
1627
1628
  const chainPart = this.safeString(parts, 1, networkId);
1628
- const networkCode = this.safeNetwork(chainPart);
1629
+ const networkCode = this.networkIdToCode(chainPart, currency['code']);
1629
1630
  const precision = this.parsePrecision(this.safeString(chain, 'wdTickSz'));
1630
1631
  if (maxPrecision === undefined) {
1631
1632
  maxPrecision = precision;
@@ -3644,7 +3645,6 @@ class okx extends okx$1 {
3644
3645
  * @param {int} [since] the earliest time in ms to fetch open orders for
3645
3646
  * @param {int} [limit] the maximum number of open orders structures to retrieve
3646
3647
  * @param {object} [params] extra parameters specific to the exchange API endpoint
3647
- * @param {int} [params.till] Timestamp in ms of the latest time to retrieve orders for
3648
3648
  * @param {bool} [params.stop] True if fetching trigger or conditional orders
3649
3649
  * @param {string} [params.ordType] "conditional", "oco", "trigger", "move_order_stop", "iceberg", or "twap"
3650
3650
  * @param {string} [params.algoId] Algo ID "'433845797218942976'"
@@ -1702,13 +1702,13 @@ class poloniexfutures extends poloniexfutures$1 {
1702
1702
  const trades = this.safeValue(data, 'items', {});
1703
1703
  return this.parseTrades(trades, market, since, limit);
1704
1704
  }
1705
- async setMarginMode(marginMode, symbol, params = {}) {
1705
+ async setMarginMode(marginMode, symbol = undefined, params = {}) {
1706
1706
  /**
1707
1707
  * @method
1708
1708
  * @name poloniexfutures#setMarginMode
1709
1709
  * @description set margin mode to 'cross' or 'isolated'
1710
1710
  * @see https://futures-docs.poloniex.com/#change-margin-mode
1711
- * @param {int} marginMode 0 (isolated) or 1 (cross)
1711
+ * @param {string} marginMode "0" (isolated) or "1" (cross)
1712
1712
  * @param {string} symbol unified market symbol
1713
1713
  * @param {object} [params] extra parameters specific to the exchange API endpoint
1714
1714
  * @returns {object} response from the exchange
@@ -1716,14 +1716,20 @@ class poloniexfutures extends poloniexfutures$1 {
1716
1716
  if (symbol === undefined) {
1717
1717
  throw new errors.ArgumentsRequired(this.id + ' setMarginMode() requires a symbol argument');
1718
1718
  }
1719
- if ((marginMode !== 0) && (marginMode !== 1)) {
1720
- throw new errors.ArgumentsRequired(this.id + ' setMarginMode() marginMode must be 0 (isolated) or 1 (cross)');
1719
+ if ((marginMode !== '0') && (marginMode !== '1') && (marginMode !== 'isolated') && (marginMode !== 'cross')) {
1720
+ throw new errors.ArgumentsRequired(this.id + ' setMarginMode() marginMode must be 0/isolated or 1/cross');
1721
1721
  }
1722
1722
  await this.loadMarkets();
1723
+ if (marginMode === 'isolated') {
1724
+ marginMode = '0';
1725
+ }
1726
+ if (marginMode === 'cross') {
1727
+ marginMode = '1';
1728
+ }
1723
1729
  const market = this.market(symbol);
1724
1730
  const request = {
1725
1731
  'symbol': market['id'],
1726
- 'marginType': marginMode,
1732
+ 'marginType': this.parseToInt(marginMode),
1727
1733
  };
1728
1734
  return await this.privatePostMarginTypeChange(request);
1729
1735
  }
@@ -24,6 +24,7 @@ class bitmart extends bitmart$1 {
24
24
  'watchTicker': true,
25
25
  'watchTickers': true,
26
26
  'watchOrderBook': true,
27
+ 'watchOrderBookForSymbols': true,
27
28
  'watchOrders': true,
28
29
  'watchTrades': true,
29
30
  'watchOHLCV': true,
@@ -50,8 +51,15 @@ class bitmart extends bitmart$1 {
50
51
  'fetchBalanceSnapshot': true,
51
52
  'awaitBalanceSnapshot': false, // whether to wait for the balance snapshot before providing updates
52
53
  },
54
+ //
55
+ // orderbook channels can have:
56
+ // - 'depth5', 'depth20', 'depth50' // these endpoints emit full Orderbooks once in every 500ms
57
+ // - 'depth/increase100' // this endpoint is preferred, because it emits once in 100ms. however, when this value is chosen, it only affects spot-market, but contracts markets automatically `depth50` will be being used
53
58
  'watchOrderBook': {
54
- 'depth': 'depth/increase100', // depth/increase100, depth5, depth20, depth50
59
+ 'depth': 'depth/increase100',
60
+ },
61
+ 'watchOrderBookForSymbols': {
62
+ 'depth': 'depth/increase100',
55
63
  },
56
64
  'ws': {
57
65
  'inflate': true,
@@ -98,6 +106,24 @@ class bitmart extends bitmart$1 {
98
106
  }
99
107
  return await this.watch(url, messageHash, this.deepExtend(request, params), messageHash);
100
108
  }
109
+ async subscribeMultiple(channel, type, symbols, params = {}) {
110
+ const url = this.implodeHostname(this.urls['api']['ws'][type]['public']);
111
+ const channelType = (type === 'spot') ? 'spot' : 'futures';
112
+ const actionType = (type === 'spot') ? 'op' : 'action';
113
+ const rawSubscriptions = [];
114
+ const messageHashes = [];
115
+ for (let i = 0; i < symbols.length; i++) {
116
+ const market = this.market(symbols[i]);
117
+ const message = channelType + '/' + channel + ':' + market['id'];
118
+ rawSubscriptions.push(message);
119
+ messageHashes.push(channel + ':' + market['symbol']);
120
+ }
121
+ const request = {
122
+ 'args': rawSubscriptions,
123
+ };
124
+ request[actionType] = 'subscribe';
125
+ return await this.watchMultiple(url, messageHashes, this.deepExtend(request, params), rawSubscriptions);
126
+ }
101
127
  async watchBalance(params = {}) {
102
128
  /**
103
129
  * @method
@@ -1156,8 +1182,8 @@ class bitmart extends bitmart$1 {
1156
1182
  // "symbol": "BTC_USDT"
1157
1183
  // }
1158
1184
  //
1159
- const asks = this.safeValue(message, 'asks', []);
1160
- const bids = this.safeValue(message, 'bids', []);
1185
+ const asks = this.safeList(message, 'asks', []);
1186
+ const bids = this.safeList(message, 'bids', []);
1161
1187
  this.handleDeltas(orderbook['asks'], asks);
1162
1188
  this.handleDeltas(orderbook['bids'], bids);
1163
1189
  const timestamp = this.safeInteger(message, 'ms_t');
@@ -1171,6 +1197,7 @@ class bitmart extends bitmart$1 {
1171
1197
  handleOrderBook(client, message) {
1172
1198
  //
1173
1199
  // spot depth-all
1200
+ //
1174
1201
  // {
1175
1202
  // "data": [
1176
1203
  // {
@@ -1190,33 +1217,31 @@ class bitmart extends bitmart$1 {
1190
1217
  // ],
1191
1218
  // "table": "spot/depth5"
1192
1219
  // }
1220
+ //
1193
1221
  // spot increse depth snapshot
1222
+ //
1194
1223
  // {
1195
1224
  // "data":[
1196
1225
  // {
1197
- // "asks":[
1198
- // [
1199
- // "43652.52",
1200
- // "0.02039"
1201
- // ],
1202
- // ...
1203
- // ],
1204
- // "bids":[
1205
- // [
1206
- // "43652.51",
1207
- // "0.00500"
1226
+ // "asks":[
1227
+ // [ "43652.52", "0.02039" ],
1228
+ // ...
1208
1229
  // ],
1209
- // ...
1210
- // ],
1211
- // "ms_t":1703376836487,
1212
- // "symbol":"BTC_USDT",
1213
- // "type":"snapshot", // or update
1214
- // "version":2141731
1230
+ // "bids":[
1231
+ // [ "43652.51", "0.00500" ],
1232
+ // ...
1233
+ // ],
1234
+ // "ms_t":1703376836487,
1235
+ // "symbol":"BTC_USDT",
1236
+ // "type":"snapshot", // or update
1237
+ // "version":2141731
1215
1238
  // }
1216
1239
  // ],
1217
1240
  // "table":"spot/depth/increase100"
1218
1241
  // }
1242
+ //
1219
1243
  // swap
1244
+ //
1220
1245
  // {
1221
1246
  // "group":"futures/depth50:BTCUSDT",
1222
1247
  // "data":{
@@ -1237,50 +1262,69 @@ class bitmart extends bitmart$1 {
1237
1262
  // }
1238
1263
  // }
1239
1264
  //
1240
- const data = this.safeValue(message, 'data');
1241
- if (data === undefined) {
1265
+ const isSpot = ('table' in message);
1266
+ let datas = [];
1267
+ if (isSpot) {
1268
+ datas = this.safeList(message, 'data', datas);
1269
+ }
1270
+ else {
1271
+ const orderBookEntry = this.safeDict(message, 'data');
1272
+ if (orderBookEntry !== undefined) {
1273
+ datas.push(orderBookEntry);
1274
+ }
1275
+ }
1276
+ const length = datas.length;
1277
+ if (length <= 0) {
1242
1278
  return;
1243
1279
  }
1244
- const depths = this.safeValue(data, 'depths');
1245
- const isSpot = (depths === undefined);
1246
- const table = this.safeString2(message, 'table', 'group');
1280
+ const channelName = this.safeString2(message, 'table', 'group');
1247
1281
  // find limit subscribed to
1248
1282
  const limitsToCheck = ['100', '50', '20', '10', '5'];
1249
1283
  let limit = 0;
1250
1284
  for (let i = 0; i < limitsToCheck.length; i++) {
1251
1285
  const limitString = limitsToCheck[i];
1252
- if (table.indexOf(limitString) >= 0) {
1286
+ if (channelName.indexOf(limitString) >= 0) {
1253
1287
  limit = this.parseToInt(limitString);
1254
1288
  break;
1255
1289
  }
1256
1290
  }
1257
1291
  if (isSpot) {
1258
- for (let i = 0; i < data.length; i++) {
1259
- const update = data[i];
1292
+ const channel = channelName.replace('spot/', '');
1293
+ for (let i = 0; i < datas.length; i++) {
1294
+ const update = datas[i];
1260
1295
  const marketId = this.safeString(update, 'symbol');
1261
1296
  const symbol = this.safeSymbol(marketId);
1262
- let orderbook = this.safeValue(this.orderbooks, symbol);
1297
+ let orderbook = this.safeDict(this.orderbooks, symbol);
1263
1298
  if (orderbook === undefined) {
1264
1299
  orderbook = this.orderBook({}, limit);
1265
1300
  orderbook['symbol'] = symbol;
1266
1301
  this.orderbooks[symbol] = orderbook;
1267
1302
  }
1268
1303
  const type = this.safeValue(update, 'type');
1269
- if ((type === 'snapshot') || (!(table.indexOf('increase') >= 0))) {
1304
+ if ((type === 'snapshot') || (!(channelName.indexOf('increase') >= 0))) {
1270
1305
  orderbook.reset({});
1271
1306
  }
1272
1307
  this.handleOrderBookMessage(client, update, orderbook);
1273
1308
  const timestamp = this.safeInteger(update, 'ms_t');
1274
- orderbook['timestamp'] = timestamp;
1275
- orderbook['datetime'] = this.iso8601(timestamp);
1276
- const messageHash = table + ':' + marketId;
1309
+ if (orderbook['timestamp'] === undefined) {
1310
+ orderbook['timestamp'] = timestamp;
1311
+ orderbook['datetime'] = this.iso8601(timestamp);
1312
+ }
1313
+ const messageHash = channelName + ':' + marketId;
1277
1314
  client.resolve(orderbook, messageHash);
1315
+ // resolve ForSymbols
1316
+ const messageHashForMulti = channel + ':' + symbol;
1317
+ client.resolve(orderbook, messageHashForMulti);
1278
1318
  }
1279
1319
  }
1280
1320
  else {
1321
+ const tableParts = channelName.split(':');
1322
+ const channel = tableParts[0].replace('futures/', '');
1323
+ const data = datas[0]; // contract markets always contain only one member
1324
+ const depths = data['depths'];
1281
1325
  const marketId = this.safeString(data, 'symbol');
1282
1326
  const symbol = this.safeSymbol(marketId);
1283
- let orderbook = this.safeValue(this.orderbooks, symbol);
1327
+ let orderbook = this.safeDict(this.orderbooks, symbol);
1284
1328
  if (orderbook === undefined) {
1285
1329
  orderbook = this.orderBook({}, limit);
1286
1330
  orderbook['symbol'] = symbol;
@@ -1309,10 +1353,41 @@ class bitmart extends bitmart$1 {
1309
1353
  const timestamp = this.safeInteger(data, 'ms_t');
1310
1354
  orderbook['timestamp'] = timestamp;
1311
1355
  orderbook['datetime'] = this.iso8601(timestamp);
1312
- const messageHash = table;
1356
+ const messageHash = channelName;
1313
1357
  client.resolve(orderbook, messageHash);
1358
+ // resolve ForSymbols
1359
+ const messageHashForMulti = channel + ':' + symbol;
1360
+ client.resolve(orderbook, messageHashForMulti);
1314
1361
  }
1315
1362
  }
1363
+ async watchOrderBookForSymbols(symbols, limit = undefined, params = {}) {
1364
+ /**
1365
+ * @method
1366
+ * @name bitmart#watchOrderBookForSymbols
1367
+ * @description watches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
1368
+ * @see https://developer-pro.bitmart.com/en/spot/#public-depth-increase-channel
1369
+ * @param {string[]} symbols unified array of symbols
1370
+ * @param {int} [limit] the maximum amount of order book entries to return
1371
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1372
+ * @param {string} [params.depth] the type of order book to subscribe to, default is 'depth/increase100', also accepts 'depth5' or 'depth20' or depth50
1373
+ * @returns {object} A dictionary of [order book structures]{@link https://docs.ccxt.com/#/?id=order-book-structure} indexed by market symbols
1374
+ */
1375
+ await this.loadMarkets();
1376
+ symbols = this.marketSymbols(symbols, undefined, false, true);
1377
+ if (symbols.length > 20) {
1378
+ throw new errors.NotSupported(this.id + ' watchOrderBookForSymbols() accepts a maximum of 20 symbols in one request');
1379
+ }
1380
+ const market = this.market(symbols[0]);
1381
+ let channel = undefined;
1382
+ [channel, params] = this.handleOptionAndParams(params, 'watchOrderBookForSymbols', 'depth', 'depth/increase100');
1383
+ let type = 'spot';
1384
+ [type, params] = this.handleMarketTypeAndParams('watchOrderBookForSymbols', market, params);
1385
+ if (type === 'swap' && channel === 'depth/increase100') {
1386
+ channel = 'depth50';
1387
+ }
1388
+ const orderbook = await this.subscribeMultiple(channel, type, symbols, params);
1389
+ return orderbook.limit();
1390
+ }
1316
1391
  async authenticate(type, params = {}) {
1317
1392
  this.checkRequiredCredentials();
1318
1393
  const url = this.implodeHostname(this.urls['api']['ws'][type]['private']);
@@ -469,7 +469,7 @@ class mexc extends mexc$1 {
469
469
  }
470
470
  try {
471
471
  this.handleDelta(storedOrderBook, data);
472
- const timestamp = this.safeInteger(message, 't');
472
+ const timestamp = this.safeInteger2(message, 't', 'ts');
473
473
  storedOrderBook['timestamp'] = timestamp;
474
474
  storedOrderBook['datetime'] = this.iso8601(timestamp);
475
475
  }
@@ -311,7 +311,7 @@ class wavesexchange extends wavesexchange$1 {
311
311
  },
312
312
  },
313
313
  'currencies': {
314
- 'WX': this.safeCurrencyStructure({ 'id': 'EMAMLxDnv3xiz8RXg8Btj33jcEw3wLczL3JKYYmuubpc', 'numericId': undefined, 'code': 'WX', 'precision': this.parseNumber('8') }),
314
+ 'WX': this.safeCurrencyStructure({ 'id': 'EMAMLxDnv3xiz8RXg8Btj33jcEw3wLczL3JKYYmuubpc', 'numericId': undefined, 'code': 'WX', 'precision': this.parseToInt('8') }),
315
315
  },
316
316
  'precisionMode': number.DECIMAL_PLACES,
317
317
  'options': {
@@ -1065,7 +1065,7 @@ class woo extends woo$1 {
1065
1065
  if (stopPrice !== undefined) {
1066
1066
  request['triggerPrice'] = this.priceToPrecision(symbol, stopPrice);
1067
1067
  }
1068
- const trailingTriggerPrice = this.safeString2(params, 'trailingTriggerPrice', 'activatedPrice', price);
1068
+ const trailingTriggerPrice = this.safeString2(params, 'trailingTriggerPrice', 'activatedPrice', this.numberToString(price));
1069
1069
  const trailingAmount = this.safeString2(params, 'trailingAmount', 'callbackValue');
1070
1070
  const trailingPercent = this.safeString2(params, 'trailingPercent', 'callbackRate');
1071
1071
  const isTrailingAmountOrder = trailingAmount !== undefined;
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 { Market, Trade, Fee, Ticker, OrderBook, Order, Transaction, Tickers, Currency, Balance, DepositAddress, WithdrawalResponse, DepositAddressResponse, OHLCV, Balances, PartialBalances, Dictionary, MinMax, Position, FundingRateHistory, Liquidation, FundingHistory, MarginMode, Greeks } from './src/base/types.js';
6
6
  import { BaseError, ExchangeError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, MarginModeAlreadySet, BadResponse, NullResponse, InsufficientFunds, InvalidAddress, InvalidOrder, OrderNotFound, OrderNotCached, CancelPending, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, NotSupported, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, RequestTimeout, AuthenticationError, AddressPending, NoChange } from './src/base/errors.js';
7
- declare const version = "4.2.37";
7
+ declare const version = "4.2.38";
8
8
  import ace from './src/ace.js';
9
9
  import alpaca from './src/alpaca.js';
10
10
  import ascendex from './src/ascendex.js';
package/js/ccxt.js CHANGED
@@ -38,7 +38,7 @@ import * as errors from './src/base/errors.js';
38
38
  import { BaseError, ExchangeError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, MarginModeAlreadySet, BadResponse, NullResponse, InsufficientFunds, InvalidAddress, InvalidOrder, OrderNotFound, OrderNotCached, CancelPending, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, NotSupported, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, RequestTimeout, AuthenticationError, AddressPending, NoChange } from './src/base/errors.js';
39
39
  //-----------------------------------------------------------------------------
40
40
  // this is updated by vss.js when building
41
- const version = '4.2.38';
41
+ const version = '4.2.39';
42
42
  Exchange.ccxtVersion = version;
43
43
  //-----------------------------------------------------------------------------
44
44
  import ace from './src/ace.js';
@@ -72,6 +72,7 @@ interface Exchange {
72
72
  v3PrivatePostBrokerageOrdersBatchCancel(params?: {}): Promise<implicitReturnType>;
73
73
  v3PrivatePostBrokerageOrdersEdit(params?: {}): Promise<implicitReturnType>;
74
74
  v3PrivatePostBrokerageOrdersEditPreview(params?: {}): Promise<implicitReturnType>;
75
+ v3PrivatePostBrokerageOrdersPreview(params?: {}): Promise<implicitReturnType>;
75
76
  v3PrivatePostBrokeragePortfolios(params?: {}): Promise<implicitReturnType>;
76
77
  v3PrivatePostBrokeragePortfoliosMoveFunds(params?: {}): Promise<implicitReturnType>;
77
78
  v3PrivatePostBrokerageConvertQuote(params?: {}): Promise<implicitReturnType>;
@@ -98,6 +98,7 @@ interface Exchange {
98
98
  privateGetTradeEasyConvertHistory(params?: {}): Promise<implicitReturnType>;
99
99
  privateGetTradeOneClickRepayCurrencyList(params?: {}): Promise<implicitReturnType>;
100
100
  privateGetTradeOneClickRepayHistory(params?: {}): Promise<implicitReturnType>;
101
+ privateGetTradeAccountRateLimit(params?: {}): Promise<implicitReturnType>;
101
102
  privateGetAssetCurrencies(params?: {}): Promise<implicitReturnType>;
102
103
  privateGetAssetBalances(params?: {}): Promise<implicitReturnType>;
103
104
  privateGetAssetNonTradableAssets(params?: {}): Promise<implicitReturnType>;