ccxt 4.2.38 → 4.2.40

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 (127) hide show
  1. package/README.md +3 -3
  2. package/dist/ccxt.browser.js +1340 -407
  3. package/dist/ccxt.browser.min.js +3 -3
  4. package/dist/cjs/ccxt.js +1 -1
  5. package/dist/cjs/src/ascendex.js +28 -24
  6. package/dist/cjs/src/base/Exchange.js +28 -16
  7. package/dist/cjs/src/binance.js +528 -181
  8. package/dist/cjs/src/bingx.js +250 -23
  9. package/dist/cjs/src/bitget.js +14 -3
  10. package/dist/cjs/src/bitso.js +18 -2
  11. package/dist/cjs/src/bitstamp.js +24 -2
  12. package/dist/cjs/src/bl3p.js +6 -0
  13. package/dist/cjs/src/blockchaincom.js +21 -0
  14. package/dist/cjs/src/btcalpha.js +9 -0
  15. package/dist/cjs/src/btcbox.js +9 -0
  16. package/dist/cjs/src/btcmarkets.js +19 -0
  17. package/dist/cjs/src/bybit.js +3 -1
  18. package/dist/cjs/src/coinbase.js +21 -8
  19. package/dist/cjs/src/coinbasepro.js +1 -0
  20. package/dist/cjs/src/coinlist.js +9 -7
  21. package/dist/cjs/src/coinmetro.js +2 -1
  22. package/dist/cjs/src/krakenfutures.js +133 -16
  23. package/dist/cjs/src/luno.js +1 -1
  24. package/dist/cjs/src/mexc.js +43 -43
  25. package/dist/cjs/src/okx.js +11 -17
  26. package/dist/cjs/src/phemex.js +1 -0
  27. package/dist/cjs/src/poloniexfutures.js +11 -5
  28. package/dist/cjs/src/pro/bitmart.js +141 -48
  29. package/dist/cjs/src/pro/bybit.js +5 -5
  30. package/dist/cjs/src/pro/mexc.js +1 -1
  31. package/dist/cjs/src/wavesexchange.js +1 -1
  32. package/dist/cjs/src/woo.js +1 -1
  33. package/js/ccxt.d.ts +1 -1
  34. package/js/ccxt.js +1 -1
  35. package/js/src/abstract/bingx.d.ts +4 -0
  36. package/js/src/abstract/coinbase.d.ts +1 -0
  37. package/js/src/abstract/coinbasepro.d.ts +1 -0
  38. package/js/src/abstract/okx.d.ts +1 -0
  39. package/js/src/ascendex.d.ts +2 -2
  40. package/js/src/ascendex.js +28 -24
  41. package/js/src/base/Exchange.d.ts +12 -8
  42. package/js/src/base/Exchange.js +28 -16
  43. package/js/src/base/types.d.ts +2 -0
  44. package/js/src/bigone.d.ts +2 -2
  45. package/js/src/binance.d.ts +9 -9
  46. package/js/src/binance.js +528 -181
  47. package/js/src/bingx.d.ts +6 -5
  48. package/js/src/bingx.js +250 -23
  49. package/js/src/bitfinex.d.ts +3 -3
  50. package/js/src/bitfinex2.d.ts +2 -2
  51. package/js/src/bitget.d.ts +5 -5
  52. package/js/src/bitget.js +14 -3
  53. package/js/src/bitmart.d.ts +2 -2
  54. package/js/src/bitmex.d.ts +2 -2
  55. package/js/src/bitrue.d.ts +2 -2
  56. package/js/src/bitso.d.ts +1 -1
  57. package/js/src/bitso.js +18 -2
  58. package/js/src/bitstamp.d.ts +1 -1
  59. package/js/src/bitstamp.js +24 -2
  60. package/js/src/bitvavo.d.ts +1 -1
  61. package/js/src/bl3p.js +6 -0
  62. package/js/src/blockchaincom.js +21 -0
  63. package/js/src/blofin.d.ts +2 -2
  64. package/js/src/btcalpha.js +9 -0
  65. package/js/src/btcbox.js +9 -0
  66. package/js/src/btcmarkets.js +19 -0
  67. package/js/src/bybit.d.ts +7 -7
  68. package/js/src/bybit.js +3 -1
  69. package/js/src/cex.d.ts +1 -1
  70. package/js/src/coinbase.d.ts +2 -2
  71. package/js/src/coinbase.js +21 -8
  72. package/js/src/coinbasepro.js +1 -0
  73. package/js/src/coinex.d.ts +4 -4
  74. package/js/src/coinlist.d.ts +2 -2
  75. package/js/src/coinlist.js +9 -7
  76. package/js/src/coinmetro.js +2 -1
  77. package/js/src/coinone.d.ts +1 -1
  78. package/js/src/delta.d.ts +2 -2
  79. package/js/src/deribit.d.ts +3 -3
  80. package/js/src/digifinex.d.ts +3 -3
  81. package/js/src/exmo.d.ts +2 -2
  82. package/js/src/gate.d.ts +6 -6
  83. package/js/src/hitbtc.d.ts +2 -2
  84. package/js/src/hollaex.d.ts +1 -1
  85. package/js/src/htx.d.ts +3 -3
  86. package/js/src/huobijp.d.ts +1 -1
  87. package/js/src/kraken.d.ts +2 -2
  88. package/js/src/krakenfutures.d.ts +4 -2
  89. package/js/src/krakenfutures.js +133 -16
  90. package/js/src/kucoin.d.ts +5 -5
  91. package/js/src/kucoinfutures.d.ts +2 -2
  92. package/js/src/latoken.d.ts +1 -1
  93. package/js/src/lbank.d.ts +2 -2
  94. package/js/src/luno.d.ts +1 -1
  95. package/js/src/luno.js +1 -1
  96. package/js/src/mexc.d.ts +4 -4
  97. package/js/src/mexc.js +43 -43
  98. package/js/src/ndax.d.ts +1 -1
  99. package/js/src/novadax.d.ts +1 -1
  100. package/js/src/okcoin.d.ts +2 -2
  101. package/js/src/okx.d.ts +7 -7
  102. package/js/src/okx.js +11 -17
  103. package/js/src/paymium.d.ts +2 -2
  104. package/js/src/phemex.d.ts +4 -4
  105. package/js/src/phemex.js +1 -0
  106. package/js/src/poloniex.d.ts +2 -2
  107. package/js/src/poloniexfutures.d.ts +2 -2
  108. package/js/src/poloniexfutures.js +11 -5
  109. package/js/src/pro/bitmart.d.ts +4 -0
  110. package/js/src/pro/bitmart.js +141 -48
  111. package/js/src/pro/bitvavo.d.ts +1 -1
  112. package/js/src/pro/bybit.d.ts +1 -1
  113. package/js/src/pro/bybit.js +5 -5
  114. package/js/src/pro/cex.d.ts +2 -2
  115. package/js/src/pro/coinbase.d.ts +2 -2
  116. package/js/src/pro/coinex.d.ts +1 -1
  117. package/js/src/pro/lbank.d.ts +1 -1
  118. package/js/src/pro/mexc.js +1 -1
  119. package/js/src/probit.d.ts +1 -1
  120. package/js/src/timex.d.ts +1 -1
  121. package/js/src/upbit.d.ts +1 -1
  122. package/js/src/wavesexchange.js +1 -1
  123. package/js/src/whitebit.d.ts +2 -2
  124. package/js/src/woo.d.ts +3 -3
  125. package/js/src/woo.js +1 -1
  126. package/js/src/zonda.d.ts +3 -3
  127. 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
@@ -2217,6 +2217,7 @@ class bybit extends bybit$1 {
2217
2217
  * @param {int} [since] timestamp in ms of the earliest candle to fetch
2218
2218
  * @param {int} [limit] the maximum amount of candles to fetch
2219
2219
  * @param {object} [params] extra parameters specific to the exchange API endpoint
2220
+ * @param {int} [params.until] the latest time in ms to fetch orders for
2220
2221
  * @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [availble parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
2221
2222
  * @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
2222
2223
  */
@@ -2230,7 +2231,7 @@ class bybit extends bybit$1 {
2230
2231
  return await this.fetchPaginatedCallDeterministic('fetchOHLCV', symbol, since, limit, timeframe, params, 1000);
2231
2232
  }
2232
2233
  const market = this.market(symbol);
2233
- const request = {
2234
+ let request = {
2234
2235
  'symbol': market['id'],
2235
2236
  };
2236
2237
  if (limit === undefined) {
@@ -2242,6 +2243,7 @@ class bybit extends bybit$1 {
2242
2243
  if (limit !== undefined) {
2243
2244
  request['limit'] = limit; // max 1000, default 1000
2244
2245
  }
2246
+ [request, params] = this.handleUntilOption('end', request, params);
2245
2247
  request['interval'] = this.safeString(this.timeframes, timeframe, timeframe);
2246
2248
  let response = undefined;
2247
2249
  if (market['spot']) {
@@ -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',
@@ -426,11 +427,12 @@ class coinbase extends coinbase$1 {
426
427
  // ]
427
428
  // }
428
429
  //
429
- const data = this.safeValue(response, 'data', []);
430
- const pagination = this.safeValue(response, 'pagination', {});
430
+ const data = this.safeList(response, 'data', []);
431
+ const pagination = this.safeDict(response, 'pagination', {});
431
432
  const cursor = this.safeString(pagination, 'next_starting_after');
432
- const accounts = this.safeValue(response, 'data', []);
433
- const lastIndex = accounts.length - 1;
433
+ const accounts = this.safeList(response, 'data', []);
434
+ const length = accounts.length;
435
+ const lastIndex = length - 1;
434
436
  const last = this.safeValue(accounts, lastIndex);
435
437
  if ((cursor !== undefined) && (cursor !== '')) {
436
438
  last['next_starting_after'] = cursor;
@@ -479,8 +481,9 @@ class coinbase extends coinbase$1 {
479
481
  // "size": 9
480
482
  // }
481
483
  //
482
- const accounts = this.safeValue(response, 'accounts', []);
483
- const lastIndex = accounts.length - 1;
484
+ const accounts = this.safeList(response, 'accounts', []);
485
+ const length = accounts.length;
486
+ const lastIndex = length - 1;
484
487
  const last = this.safeValue(accounts, lastIndex);
485
488
  const cursor = this.safeString(response, 'cursor');
486
489
  if ((cursor !== undefined) && (cursor !== '')) {
@@ -2212,11 +2215,12 @@ class coinbase extends coinbase$1 {
2212
2215
  * @param {string} [params.stop_direction] 'UNKNOWN_STOP_DIRECTION', 'STOP_DIRECTION_STOP_UP', 'STOP_DIRECTION_STOP_DOWN' the direction the stopPrice is triggered from
2213
2216
  * @param {string} [params.end_time] '2023-05-25T17:01:05.092Z' for 'GTD' orders
2214
2217
  * @param {float} [params.cost] *spot market buy only* the quote quantity that can be used as an alternative for the amount
2218
+ * @param {boolean} [params.preview] default to false, wether to use the test/preview endpoint or not
2215
2219
  * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
2216
2220
  */
2217
2221
  await this.loadMarkets();
2218
2222
  const market = this.market(symbol);
2219
- const request = {
2223
+ let request = {
2220
2224
  'client_order_id': this.uuid(),
2221
2225
  'product_id': market['id'],
2222
2226
  'side': side.toUpperCase(),
@@ -2351,7 +2355,16 @@ class coinbase extends coinbase$1 {
2351
2355
  }
2352
2356
  }
2353
2357
  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));
2358
+ const preview = this.safeValue2(params, 'preview', 'test', false);
2359
+ let response = undefined;
2360
+ if (preview) {
2361
+ params = this.omit(params, ['preview', 'test']);
2362
+ request = this.omit(request, 'client_order_id');
2363
+ response = await this.v3PrivatePostBrokerageOrdersPreview(this.extend(request, params));
2364
+ }
2365
+ else {
2366
+ response = await this.v3PrivatePostBrokerageOrders(this.extend(request, params));
2367
+ }
2355
2368
  //
2356
2369
  // successful order
2357
2370
  //
@@ -147,6 +147,7 @@ class coinbasepro extends coinbasepro$1 {
147
147
  'users/self/trailing-volume',
148
148
  'withdrawals/fee-estimate',
149
149
  'conversions/{conversion_id}',
150
+ 'conversions/fees',
150
151
  ],
151
152
  'post': [
152
153
  'conversions',
@@ -1034,13 +1034,15 @@ class coinlist extends coinlist$1 {
1034
1034
  }
1035
1035
  takerFees = this.sortBy(takerFees, 1, true);
1036
1036
  makerFees = this.sortBy(makerFees, 1, true);
1037
- const firstTier = this.safeValue(takerFees, 0, []);
1038
- const exchangeFees = this.safeValue(this, 'fees', {});
1039
- const exchangeFeesTrading = this.safeValue(exchangeFees, 'trading', {});
1040
- const exchangeFeesTradingTiers = this.safeValue(exchangeFeesTrading, 'tiers', {});
1041
- const exchangeFeesTradingTiersTaker = this.safeValue(exchangeFeesTradingTiers, 'taker', []);
1042
- const exchangeFeesTradingTiersMaker = this.safeValue(exchangeFeesTradingTiers, 'maker', []);
1043
- if ((keysLength === exchangeFeesTradingTiersTaker.length) && (firstTier.length > 0)) {
1037
+ const firstTier = this.safeDict(takerFees, 0, []);
1038
+ const exchangeFees = this.safeDict(this, 'fees', {});
1039
+ const exchangeFeesTrading = this.safeDict(exchangeFees, 'trading', {});
1040
+ const exchangeFeesTradingTiers = this.safeDict(exchangeFeesTrading, 'tiers', {});
1041
+ const exchangeFeesTradingTiersTaker = this.safeList(exchangeFeesTradingTiers, 'taker', []);
1042
+ const exchangeFeesTradingTiersMaker = this.safeList(exchangeFeesTradingTiers, 'maker', []);
1043
+ const exchangeFeesTradingTiersTakerLength = exchangeFeesTradingTiersTaker.length;
1044
+ const firstTierLength = firstTier.length;
1045
+ if ((keysLength === exchangeFeesTradingTiersTakerLength) && (firstTierLength > 0)) {
1044
1046
  for (let i = 0; i < keysLength; i++) {
1045
1047
  takerFees[i][0] = exchangeFeesTradingTiersTaker[i][0];
1046
1048
  makerFees[i][0] = exchangeFeesTradingTiersMaker[i][0];
@@ -1166,7 +1166,8 @@ class coinmetro extends coinmetro$1 {
1166
1166
  }
1167
1167
  let type = undefined;
1168
1168
  let referenceId = undefined;
1169
- if (descriptionArray.length > 1) {
1169
+ const length = descriptionArray.length;
1170
+ if (length > 1) {
1170
1171
  type = this.parseLedgerEntryType(descriptionArray[0]);
1171
1172
  if (descriptionArray[1] !== '-') {
1172
1173
  referenceId = descriptionArray[1];
@@ -39,7 +39,8 @@ class krakenfutures extends krakenfutures$1 {
39
39
  'fetchBalance': true,
40
40
  'fetchBorrowRateHistories': false,
41
41
  'fetchBorrowRateHistory': false,
42
- 'fetchClosedOrders': undefined,
42
+ 'fetchCanceledOrders': true,
43
+ 'fetchClosedOrders': true,
43
44
  'fetchCrossBorrowRate': false,
44
45
  'fetchCrossBorrowRates': false,
45
46
  'fetchDepositAddress': false,
@@ -799,37 +800,30 @@ class krakenfutures extends krakenfutures$1 {
799
800
  id = this.safeString(trade, 'executionId');
800
801
  }
801
802
  let order = this.safeString(trade, 'order_id');
802
- let symbolId = this.safeString(trade, 'symbol');
803
+ let marketId = this.safeString(trade, 'symbol');
803
804
  let side = this.safeString(trade, 'side');
804
805
  let type = undefined;
805
806
  const priorEdit = this.safeValue(trade, 'orderPriorEdit');
806
807
  const priorExecution = this.safeValue(trade, 'orderPriorExecution');
807
808
  if (priorExecution !== undefined) {
808
809
  order = this.safeString(priorExecution, 'orderId');
809
- symbolId = this.safeString(priorExecution, 'symbol');
810
+ marketId = this.safeString(priorExecution, 'symbol');
810
811
  side = this.safeString(priorExecution, 'side');
811
812
  type = this.safeString(priorExecution, 'type');
812
813
  }
813
814
  else if (priorEdit !== undefined) {
814
815
  order = this.safeString(priorEdit, 'orderId');
815
- symbolId = this.safeString(priorEdit, 'symbol');
816
+ marketId = this.safeString(priorEdit, 'symbol');
816
817
  side = this.safeString(priorEdit, 'type');
817
818
  type = this.safeString(priorEdit, 'type');
818
819
  }
819
820
  if (type !== undefined) {
820
821
  type = this.parseOrderType(type);
821
822
  }
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);
823
+ market = this.safeMarket(marketId, market);
830
824
  let cost = undefined;
825
+ const linear = this.safeBool(market, 'linear');
831
826
  if ((amount !== undefined) && (price !== undefined) && (market !== undefined)) {
832
- const linear = this.safeValue(market, 'linear');
833
827
  if (linear) {
834
828
  cost = Precise["default"].stringMul(amount, price); // in quote
835
829
  }
@@ -852,15 +846,15 @@ class krakenfutures extends krakenfutures$1 {
852
846
  return this.safeTrade({
853
847
  'info': trade,
854
848
  'id': id,
849
+ 'symbol': this.safeString(market, 'symbol'),
855
850
  'timestamp': timestamp,
856
851
  'datetime': this.iso8601(timestamp),
857
- 'symbol': symbol,
858
852
  'order': order,
859
853
  'type': type,
860
854
  'side': side,
861
855
  'takerOrMaker': takerOrMaker,
862
856
  'price': price,
863
- 'amount': amount,
857
+ 'amount': linear ? amount : undefined,
864
858
  'cost': cost,
865
859
  'fee': undefined,
866
860
  });
@@ -1193,6 +1187,102 @@ class krakenfutures extends krakenfutures$1 {
1193
1187
  const orders = this.safeValue(response, 'openOrders', []);
1194
1188
  return this.parseOrders(orders, market, since, limit);
1195
1189
  }
1190
+ async fetchClosedOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
1191
+ /**
1192
+ * @method
1193
+ * @name krakenfutures#fetchClosedOrders
1194
+ * @see https://docs.futures.kraken.com/#http-api-history-account-history-get-order-events
1195
+ * @description Gets all closed orders, including trigger orders, for an account from the exchange api
1196
+ * @param {string} symbol Unified market symbol
1197
+ * @param {int} [since] Timestamp (ms) of earliest order.
1198
+ * @param {int} [limit] How many orders to return.
1199
+ * @param {object} [params] Exchange specific parameters
1200
+ * @returns An array of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
1201
+ */
1202
+ await this.loadMarkets();
1203
+ let market = undefined;
1204
+ if (symbol !== undefined) {
1205
+ market = this.market(symbol);
1206
+ }
1207
+ const request = {};
1208
+ if (limit !== undefined) {
1209
+ request['count'] = limit;
1210
+ }
1211
+ if (since !== undefined) {
1212
+ request['from'] = since;
1213
+ }
1214
+ const response = await this.historyGetOrders(this.extend(request, params));
1215
+ const allOrders = this.safeList(response, 'elements', []);
1216
+ const closedOrders = [];
1217
+ for (let i = 0; i < allOrders.length; i++) {
1218
+ const order = allOrders[i];
1219
+ const event = this.safeDict(order, 'event', {});
1220
+ const orderPlaced = this.safeDict(event, 'OrderPlaced');
1221
+ if (orderPlaced !== undefined) {
1222
+ const innerOrder = this.safeDict(orderPlaced, 'order', {});
1223
+ const filled = this.safeString(innerOrder, 'filled');
1224
+ if (filled !== '0') {
1225
+ innerOrder['status'] = 'closed'; // status not available in the response
1226
+ closedOrders.push(innerOrder);
1227
+ }
1228
+ }
1229
+ }
1230
+ return this.parseOrders(closedOrders, market, since, limit);
1231
+ }
1232
+ async fetchCanceledOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
1233
+ /**
1234
+ * @method
1235
+ * @name krakenfutures#fetchCanceledOrders
1236
+ * @see https://docs.futures.kraken.com/#http-api-history-account-history-get-order-events
1237
+ * @description Gets all canceled orders, including trigger orders, for an account from the exchange api
1238
+ * @param {string} symbol Unified market symbol
1239
+ * @param {int} [since] Timestamp (ms) of earliest order.
1240
+ * @param {int} [limit] How many orders to return.
1241
+ * @param {object} [params] Exchange specific parameters
1242
+ * @returns An array of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
1243
+ */
1244
+ await this.loadMarkets();
1245
+ let market = undefined;
1246
+ if (symbol !== undefined) {
1247
+ market = this.market(symbol);
1248
+ }
1249
+ const request = {};
1250
+ if (limit !== undefined) {
1251
+ request['count'] = limit;
1252
+ }
1253
+ if (since !== undefined) {
1254
+ request['from'] = since;
1255
+ }
1256
+ const response = await this.historyGetOrders(this.extend(request, params));
1257
+ const allOrders = this.safeList(response, 'elements', []);
1258
+ const canceledAndRejected = [];
1259
+ for (let i = 0; i < allOrders.length; i++) {
1260
+ const order = allOrders[i];
1261
+ const event = this.safeDict(order, 'event', {});
1262
+ const orderPlaced = this.safeDict(event, 'OrderPlaced');
1263
+ if (orderPlaced !== undefined) {
1264
+ const innerOrder = this.safeDict(orderPlaced, 'order', {});
1265
+ const filled = this.safeString(innerOrder, 'filled');
1266
+ if (filled === '0') {
1267
+ innerOrder['status'] = 'canceled'; // status not available in the response
1268
+ canceledAndRejected.push(innerOrder);
1269
+ }
1270
+ }
1271
+ const orderCanceled = this.safeDict(event, 'OrderCancelled');
1272
+ if (orderCanceled !== undefined) {
1273
+ const innerOrder = this.safeDict(orderCanceled, 'order', {});
1274
+ innerOrder['status'] = 'canceled'; // status not available in the response
1275
+ canceledAndRejected.push(innerOrder);
1276
+ }
1277
+ const orderRejected = this.safeDict(event, 'OrderRejected');
1278
+ if (orderRejected !== undefined) {
1279
+ const innerOrder = this.safeDict(orderRejected, 'order', {});
1280
+ innerOrder['status'] = 'rejected'; // status not available in the response
1281
+ canceledAndRejected.push(innerOrder);
1282
+ }
1283
+ }
1284
+ return this.parseOrders(canceledAndRejected, market, since, limit);
1285
+ }
1196
1286
  parseOrderType(orderType) {
1197
1287
  const map = {
1198
1288
  'lmt': 'limit',
@@ -1436,6 +1526,32 @@ class krakenfutures extends krakenfutures$1 {
1436
1526
  // "status": "requiredArgumentMissing",
1437
1527
  // "orderEvents": []
1438
1528
  // }
1529
+ // closed orders
1530
+ // {
1531
+ // uid: '2f00cd63-e61d-44f8-8569-adabde885941',
1532
+ // timestamp: '1707258274849',
1533
+ // event: {
1534
+ // OrderPlaced: {
1535
+ // order: {
1536
+ // uid: '85805e01-9eed-4395-8360-ed1a228237c9',
1537
+ // accountUid: '406142dd-7c5c-4a8b-acbc-5f16eca30009',
1538
+ // tradeable: 'PF_LTCUSD',
1539
+ // direction: 'Buy',
1540
+ // quantity: '0',
1541
+ // filled: '0.1',
1542
+ // timestamp: '1707258274849',
1543
+ // limitPrice: '69.2200000000',
1544
+ // orderType: 'IoC',
1545
+ // clientId: '',
1546
+ // reduceOnly: false,
1547
+ // lastUpdateTimestamp: '1707258274849'
1548
+ // },
1549
+ // reason: 'new_user_order',
1550
+ // reducedQuantity: '',
1551
+ // algoId: ''
1552
+ // }
1553
+ // }
1554
+ // }
1439
1555
  //
1440
1556
  const orderEvents = this.safeValue(order, 'orderEvents', []);
1441
1557
  const errorStatus = this.safeString(order, 'status');
@@ -1498,7 +1614,8 @@ class krakenfutures extends krakenfutures$1 {
1498
1614
  let remaining = this.safeString(details, 'unfilledSize');
1499
1615
  let average = undefined;
1500
1616
  let filled2 = '0.0';
1501
- if (trades.length) {
1617
+ const tradesLength = trades.length;
1618
+ if (tradesLength > 0) {
1502
1619
  let vwapSum = '0.0';
1503
1620
  for (let i = 0; i < trades.length; i++) {
1504
1621
  const trade = trades[i];
@@ -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);