ccxt 4.3.5 → 4.3.7

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 (211) hide show
  1. package/README.md +3 -3
  2. package/dist/cjs/ccxt.js +1 -1
  3. package/dist/cjs/src/ace.js +5 -0
  4. package/dist/cjs/src/alpaca.js +6 -0
  5. package/dist/cjs/src/base/Exchange.js +37 -0
  6. package/dist/cjs/src/binance.js +4 -0
  7. package/dist/cjs/src/bingx.js +47 -0
  8. package/dist/cjs/src/bitbank.js +3 -0
  9. package/dist/cjs/src/bitget.js +74 -1
  10. package/dist/cjs/src/bithumb.js +4 -0
  11. package/dist/cjs/src/bitmex.js +26 -0
  12. package/dist/cjs/src/bitopro.js +5 -0
  13. package/dist/cjs/src/bitso.js +3 -0
  14. package/dist/cjs/src/bitstamp.js +3 -0
  15. package/dist/cjs/src/bitteam.js +4 -0
  16. package/dist/cjs/src/bitvavo.js +3 -0
  17. package/dist/cjs/src/bl3p.js +3 -0
  18. package/dist/cjs/src/btcalpha.js +3 -0
  19. package/dist/cjs/src/btcbox.js +3 -0
  20. package/dist/cjs/src/btcmarkets.js +3 -0
  21. package/dist/cjs/src/btcturk.js +3 -0
  22. package/dist/cjs/src/bybit.js +209 -12
  23. package/dist/cjs/src/cex.js +6 -0
  24. package/dist/cjs/src/coinbase.js +100 -21
  25. package/dist/cjs/src/coinbaseinternational.js +2 -0
  26. package/dist/cjs/src/coinbasepro.js +6 -0
  27. package/dist/cjs/src/coincheck.js +3 -0
  28. package/dist/cjs/src/coinex.js +180 -75
  29. package/dist/cjs/src/coinlist.js +4 -0
  30. package/dist/cjs/src/coinmate.js +3 -0
  31. package/dist/cjs/src/coinone.js +3 -0
  32. package/dist/cjs/src/coinsph.js +4 -0
  33. package/dist/cjs/src/coinspot.js +3 -0
  34. package/dist/cjs/src/cryptocom.js +34 -0
  35. package/dist/cjs/src/exmo.js +5 -0
  36. package/dist/cjs/src/gate.js +124 -22
  37. package/dist/cjs/src/hitbtc.js +4 -3
  38. package/dist/cjs/src/htx.js +30 -0
  39. package/dist/cjs/src/hyperliquid.js +40 -0
  40. package/dist/cjs/src/idex.js +3 -0
  41. package/dist/cjs/src/independentreserve.js +3 -0
  42. package/dist/cjs/src/indodax.js +3 -0
  43. package/dist/cjs/src/kraken.js +30 -0
  44. package/dist/cjs/src/krakenfutures.js +28 -0
  45. package/dist/cjs/src/kucoin.js +2 -0
  46. package/dist/cjs/src/kucoinfutures.js +4 -2
  47. package/dist/cjs/src/latoken.js +6 -0
  48. package/dist/cjs/src/luno.js +3 -0
  49. package/dist/cjs/src/lykke.js +5 -0
  50. package/dist/cjs/src/mercado.js +3 -0
  51. package/dist/cjs/src/mexc.js +111 -0
  52. package/dist/cjs/src/ndax.js +4 -0
  53. package/dist/cjs/src/novadax.js +4 -0
  54. package/dist/cjs/src/okx.js +196 -0
  55. package/dist/cjs/src/onetrading.js +3 -0
  56. package/dist/cjs/src/p2b.js +3 -0
  57. package/dist/cjs/src/pro/bitget.js +1 -1
  58. package/dist/cjs/src/pro/bybit.js +1 -1
  59. package/dist/cjs/src/pro/coinbase.js +30 -29
  60. package/dist/cjs/src/probit.js +3 -0
  61. package/dist/cjs/src/timex.js +3 -0
  62. package/dist/cjs/src/tradeogre.js +3 -0
  63. package/dist/cjs/src/wavesexchange.js +3 -0
  64. package/dist/cjs/src/wazirx.js +3 -0
  65. package/dist/cjs/src/whitebit.js +42 -0
  66. package/dist/cjs/src/woo.js +31 -0
  67. package/dist/cjs/src/yobit.js +3 -0
  68. package/js/ccxt.d.ts +1 -1
  69. package/js/ccxt.js +1 -1
  70. package/js/src/abstract/binance.d.ts +1 -0
  71. package/js/src/abstract/binancecoinm.d.ts +1 -0
  72. package/js/src/abstract/binanceus.d.ts +1 -0
  73. package/js/src/abstract/binanceusdm.d.ts +1 -0
  74. package/js/src/abstract/bingx.d.ts +1 -0
  75. package/js/src/abstract/coinbase.d.ts +5 -0
  76. package/js/src/abstract/woo.d.ts +1 -0
  77. package/js/src/ace.js +5 -0
  78. package/js/src/alpaca.js +6 -0
  79. package/js/src/ascendex.d.ts +2 -2
  80. package/js/src/base/Exchange.d.ts +5 -0
  81. package/js/src/base/Exchange.js +37 -0
  82. package/js/src/bigone.d.ts +1 -1
  83. package/js/src/binance.d.ts +3 -3
  84. package/js/src/binance.js +4 -0
  85. package/js/src/bingx.d.ts +2 -1
  86. package/js/src/bingx.js +47 -0
  87. package/js/src/bitbank.d.ts +1 -1
  88. package/js/src/bitbank.js +3 -0
  89. package/js/src/bitfinex.d.ts +1 -1
  90. package/js/src/bitfinex2.d.ts +1 -1
  91. package/js/src/bitflyer.d.ts +1 -1
  92. package/js/src/bitget.d.ts +4 -3
  93. package/js/src/bitget.js +74 -1
  94. package/js/src/bithumb.d.ts +1 -1
  95. package/js/src/bithumb.js +4 -0
  96. package/js/src/bitmart.d.ts +1 -1
  97. package/js/src/bitmex.d.ts +2 -1
  98. package/js/src/bitmex.js +26 -0
  99. package/js/src/bitopro.d.ts +1 -1
  100. package/js/src/bitopro.js +5 -0
  101. package/js/src/bitrue.d.ts +1 -1
  102. package/js/src/bitso.d.ts +1 -1
  103. package/js/src/bitso.js +3 -0
  104. package/js/src/bitstamp.d.ts +1 -1
  105. package/js/src/bitstamp.js +3 -0
  106. package/js/src/bitteam.js +4 -0
  107. package/js/src/bitvavo.d.ts +1 -1
  108. package/js/src/bitvavo.js +3 -0
  109. package/js/src/bl3p.js +3 -0
  110. package/js/src/blockchaincom.d.ts +1 -1
  111. package/js/src/btcalpha.js +3 -0
  112. package/js/src/btcbox.js +3 -0
  113. package/js/src/btcmarkets.d.ts +1 -1
  114. package/js/src/btcmarkets.js +3 -0
  115. package/js/src/btcturk.js +3 -0
  116. package/js/src/bybit.d.ts +8 -6
  117. package/js/src/bybit.js +209 -12
  118. package/js/src/cex.js +6 -0
  119. package/js/src/coinbase.d.ts +1 -1
  120. package/js/src/coinbase.js +100 -21
  121. package/js/src/coinbaseinternational.d.ts +1 -1
  122. package/js/src/coinbaseinternational.js +2 -0
  123. package/js/src/coinbasepro.d.ts +1 -1
  124. package/js/src/coinbasepro.js +6 -0
  125. package/js/src/coincheck.js +3 -0
  126. package/js/src/coinex.d.ts +8 -7
  127. package/js/src/coinex.js +180 -75
  128. package/js/src/coinlist.d.ts +1 -1
  129. package/js/src/coinlist.js +4 -0
  130. package/js/src/coinmate.d.ts +1 -1
  131. package/js/src/coinmate.js +3 -0
  132. package/js/src/coinone.js +3 -0
  133. package/js/src/coinsph.d.ts +1 -1
  134. package/js/src/coinsph.js +4 -0
  135. package/js/src/coinspot.js +3 -0
  136. package/js/src/cryptocom.d.ts +3 -2
  137. package/js/src/cryptocom.js +34 -0
  138. package/js/src/delta.d.ts +2 -2
  139. package/js/src/deribit.d.ts +1 -1
  140. package/js/src/digifinex.d.ts +3 -3
  141. package/js/src/exmo.d.ts +3 -3
  142. package/js/src/exmo.js +5 -0
  143. package/js/src/gate.d.ts +8 -7
  144. package/js/src/gate.js +124 -22
  145. package/js/src/gemini.d.ts +1 -1
  146. package/js/src/hitbtc.d.ts +3 -3
  147. package/js/src/hitbtc.js +4 -3
  148. package/js/src/hollaex.d.ts +1 -1
  149. package/js/src/htx.d.ts +2 -1
  150. package/js/src/htx.js +30 -0
  151. package/js/src/huobijp.d.ts +1 -1
  152. package/js/src/hyperliquid.d.ts +3 -2
  153. package/js/src/hyperliquid.js +40 -0
  154. package/js/src/idex.d.ts +1 -1
  155. package/js/src/idex.js +3 -0
  156. package/js/src/independentreserve.js +3 -0
  157. package/js/src/indodax.d.ts +1 -1
  158. package/js/src/indodax.js +3 -0
  159. package/js/src/kraken.d.ts +2 -1
  160. package/js/src/kraken.js +30 -0
  161. package/js/src/krakenfutures.d.ts +1 -0
  162. package/js/src/krakenfutures.js +28 -0
  163. package/js/src/kucoin.d.ts +1 -1
  164. package/js/src/kucoin.js +2 -0
  165. package/js/src/kucoinfutures.d.ts +1 -1
  166. package/js/src/kucoinfutures.js +4 -2
  167. package/js/src/kuna.d.ts +1 -1
  168. package/js/src/latoken.js +6 -0
  169. package/js/src/lbank.d.ts +1 -1
  170. package/js/src/luno.js +3 -0
  171. package/js/src/lykke.d.ts +1 -1
  172. package/js/src/lykke.js +5 -0
  173. package/js/src/mercado.d.ts +1 -1
  174. package/js/src/mercado.js +3 -0
  175. package/js/src/mexc.d.ts +4 -3
  176. package/js/src/mexc.js +111 -0
  177. package/js/src/ndax.d.ts +1 -1
  178. package/js/src/ndax.js +4 -0
  179. package/js/src/novadax.d.ts +1 -1
  180. package/js/src/novadax.js +4 -0
  181. package/js/src/okcoin.d.ts +1 -1
  182. package/js/src/okx.d.ts +11 -8
  183. package/js/src/okx.js +196 -0
  184. package/js/src/onetrading.d.ts +1 -1
  185. package/js/src/onetrading.js +3 -0
  186. package/js/src/p2b.js +3 -0
  187. package/js/src/phemex.d.ts +1 -1
  188. package/js/src/poloniex.d.ts +1 -1
  189. package/js/src/pro/bitget.d.ts +1 -1
  190. package/js/src/pro/bitget.js +1 -1
  191. package/js/src/pro/bybit.js +1 -1
  192. package/js/src/pro/coinbase.d.ts +2 -2
  193. package/js/src/pro/coinbase.js +30 -29
  194. package/js/src/probit.d.ts +1 -1
  195. package/js/src/probit.js +3 -0
  196. package/js/src/timex.js +3 -0
  197. package/js/src/tokocrypto.d.ts +1 -1
  198. package/js/src/tradeogre.js +3 -0
  199. package/js/src/upbit.d.ts +1 -1
  200. package/js/src/wavesexchange.d.ts +1 -1
  201. package/js/src/wavesexchange.js +3 -0
  202. package/js/src/wazirx.js +3 -0
  203. package/js/src/whitebit.d.ts +2 -1
  204. package/js/src/whitebit.js +42 -0
  205. package/js/src/woo.d.ts +3 -2
  206. package/js/src/woo.js +31 -0
  207. package/js/src/yobit.d.ts +1 -1
  208. package/js/src/yobit.js +3 -0
  209. package/js/src/zaif.d.ts +1 -1
  210. package/js/src/zonda.d.ts +1 -1
  211. package/package.json +1 -1
@@ -138,8 +138,10 @@ class gate extends gate$1 {
138
138
  'fetchOrder': true,
139
139
  'fetchOrderBook': true,
140
140
  'fetchPosition': true,
141
+ 'fetchPositionHistory': 'emulated',
141
142
  'fetchPositionMode': false,
142
143
  'fetchPositions': true,
144
+ 'fetchPositionsHistory': true,
143
145
  'fetchPremiumIndexOHLCV': false,
144
146
  'fetchSettlementHistory': true,
145
147
  'fetchTicker': true,
@@ -654,7 +656,6 @@ class gate extends gate$1 {
654
656
  'option': 'options',
655
657
  'options': 'options',
656
658
  },
657
- 'defaultType': 'spot',
658
659
  'swap': {
659
660
  'fetchMarkets': {
660
661
  'settlementCurrencies': ['usdt', 'btc'],
@@ -5320,41 +5321,69 @@ class gate extends gate$1 {
5320
5321
  // "pending_orders": 0
5321
5322
  // }
5322
5323
  //
5324
+ // fetchPositionsHistory (swap and future)
5325
+ //
5326
+ // {
5327
+ // "contract": "SLERF_USDT", // Futures contract
5328
+ // "text": "web", // Text of close order
5329
+ // "long_price": "0.766306", // When 'side' is 'long,' it indicates the opening average price; when 'side' is 'short,' it indicates the closing average price.
5330
+ // "pnl": "-23.41702352", // PNL
5331
+ // "pnl_pnl": "-22.7187", // Position P/L
5332
+ // "pnl_fee": "-0.06527125", // Transaction Fees
5333
+ // "pnl_fund": "-0.63305227", // Funding Fees
5334
+ // "accum_size": "100",
5335
+ // "time": 1711279263, // Position close time
5336
+ // "short_price": "0.539119", // When 'side' is 'long,' it indicates the opening average price; when 'side' is 'short,' it indicates the closing average price
5337
+ // "side": "long", // Position side, long or short
5338
+ // "max_size": "100", // Max Trade Size
5339
+ // "first_open_time": 1711037985 // First Open Time
5340
+ // }
5341
+ //
5323
5342
  const contract = this.safeString(position, 'contract');
5324
5343
  market = this.safeMarket(contract, market, '_', 'contract');
5325
- const size = this.safeString(position, 'size');
5326
- let side = undefined;
5327
- if (Precise["default"].stringGt(size, '0')) {
5328
- side = 'long';
5329
- }
5330
- else if (Precise["default"].stringLt(size, '0')) {
5331
- side = 'short';
5344
+ const size = this.safeString2(position, 'size', 'accum_size');
5345
+ let side = this.safeString(position, 'side');
5346
+ if (side === undefined) {
5347
+ if (Precise["default"].stringGt(size, '0')) {
5348
+ side = 'long';
5349
+ }
5350
+ else if (Precise["default"].stringLt(size, '0')) {
5351
+ side = 'short';
5352
+ }
5332
5353
  }
5333
5354
  const maintenanceRate = this.safeString(position, 'maintenance_rate');
5334
5355
  const notional = this.safeString(position, 'value');
5335
5356
  const leverage = this.safeString(position, 'leverage');
5336
5357
  let marginMode = undefined;
5337
- if (leverage === '0') {
5338
- marginMode = 'cross';
5339
- }
5340
- else {
5341
- marginMode = 'isolated';
5358
+ if (leverage !== undefined) {
5359
+ if (leverage === '0') {
5360
+ marginMode = 'cross';
5361
+ }
5362
+ else {
5363
+ marginMode = 'isolated';
5364
+ }
5342
5365
  }
5343
- const unrealisedPnl = this.safeString(position, 'unrealised_pnl');
5344
5366
  // Initial Position Margin = ( Position Value / Leverage ) + Close Position Fee
5345
5367
  // *The default leverage under the full position is the highest leverage in the market.
5346
5368
  // *Trading fee is charged as Taker Fee Rate (0.075%).
5347
- const takerFee = '0.00075';
5348
- const feePaid = Precise["default"].stringMul(takerFee, notional);
5349
- const initialMarginString = Precise["default"].stringAdd(Precise["default"].stringDiv(notional, leverage), feePaid);
5350
- const timestamp = this.safeTimestamp(position, 'open_time');
5369
+ let feePaid = this.safeString(position, 'pnl_fee');
5370
+ let initialMarginString = undefined;
5371
+ if (feePaid === undefined) {
5372
+ const takerFee = '0.00075';
5373
+ feePaid = Precise["default"].stringMul(takerFee, notional);
5374
+ initialMarginString = Precise["default"].stringAdd(Precise["default"].stringDiv(notional, leverage), feePaid);
5375
+ }
5376
+ let timestamp = this.safeTimestamp2(position, 'open_time', 'first_open_time');
5377
+ if (timestamp === 0) {
5378
+ timestamp = undefined;
5379
+ }
5351
5380
  return this.safePosition({
5352
5381
  'info': position,
5353
5382
  'id': undefined,
5354
5383
  'symbol': this.safeString(market, 'symbol'),
5355
5384
  'timestamp': timestamp,
5356
5385
  'datetime': this.iso8601(timestamp),
5357
- 'lastUpdateTimestamp': this.safeTimestamp(position, 'update_time'),
5386
+ 'lastUpdateTimestamp': this.safeTimestamp2(position, 'update_time', 'time'),
5358
5387
  'initialMargin': this.parseNumber(initialMarginString),
5359
5388
  'initialMarginPercentage': this.parseNumber(Precise["default"].stringDiv(initialMarginString, notional)),
5360
5389
  'maintenanceMargin': this.parseNumber(Precise["default"].stringMul(maintenanceRate, notional)),
@@ -5362,11 +5391,10 @@ class gate extends gate$1 {
5362
5391
  'entryPrice': this.safeNumber(position, 'entry_price'),
5363
5392
  'notional': this.parseNumber(notional),
5364
5393
  'leverage': this.safeNumber(position, 'leverage'),
5365
- 'unrealizedPnl': this.parseNumber(unrealisedPnl),
5366
- 'realizedPnl': this.safeNumber(position, 'realised_pnl'),
5394
+ 'unrealizedPnl': this.safeNumber(position, 'unrealised_pnl'),
5395
+ 'realizedPnl': this.safeNumber2(position, 'realised_pnl', 'pnl'),
5367
5396
  'contracts': this.parseNumber(Precise["default"].stringAbs(size)),
5368
5397
  'contractSize': this.safeNumber(market, 'contractSize'),
5369
- // 'realisedPnl': position['realised_pnl'],
5370
5398
  'marginRatio': undefined,
5371
5399
  'liquidationPrice': this.safeNumber(position, 'liq_price'),
5372
5400
  'markPrice': this.safeNumber(position, 'mark_price'),
@@ -7387,6 +7415,80 @@ class gate extends gate$1 {
7387
7415
  'quoteVolume': undefined,
7388
7416
  };
7389
7417
  }
7418
+ async fetchPositionsHistory(symbols = undefined, since = undefined, limit = undefined, params = {}) {
7419
+ /**
7420
+ * @method
7421
+ * @name gate#fetchPositionsHistory
7422
+ * @description fetches historical positions
7423
+ * @see https://www.gate.io/docs/developers/apiv4/#list-position-close-history
7424
+ * @see https://www.gate.io/docs/developers/apiv4/#list-position-close-history-2
7425
+ * @param {string[]} symbols unified conract symbols, must all have the same settle currency and the same market type
7426
+ * @param {int} [since] the earliest time in ms to fetch positions for
7427
+ * @param {int} [limit] the maximum amount of records to fetch, default=1000
7428
+ * @param {object} params extra parameters specific to the exchange api endpoint
7429
+ * @param {int} [params.until] the latest time in ms to fetch positions for
7430
+ *
7431
+ * EXCHANGE SPECIFIC PARAMETERS
7432
+ * @param {int} offset list offset, starting from 0
7433
+ * @param {string} side long or short
7434
+ * @param {string} pnl query profit or loss
7435
+ * @returns {object[]} a list of [position structures]{@link https://docs.ccxt.com/#/?id=position-structure}
7436
+ */
7437
+ await this.loadMarkets();
7438
+ let market = undefined;
7439
+ if (symbols !== undefined) {
7440
+ const symbolsLength = symbols.length;
7441
+ if (symbolsLength === 1) {
7442
+ market = this.market(symbols[0]);
7443
+ }
7444
+ }
7445
+ let marketType = undefined;
7446
+ [marketType, params] = this.handleMarketTypeAndParams('fetchPositionsHistory', market, params, 'swap');
7447
+ const until = this.safeInteger(params, 'until');
7448
+ params = this.omit(params, 'until');
7449
+ let request = {};
7450
+ [request, params] = this.prepareRequest(market, marketType, params);
7451
+ if (limit !== undefined) {
7452
+ request['limit'] = limit;
7453
+ }
7454
+ if (since !== undefined) {
7455
+ request['from'] = this.parseToInt(since / 1000);
7456
+ }
7457
+ if (until !== undefined) {
7458
+ request['to'] = this.parseToInt(until / 1000);
7459
+ }
7460
+ let response = undefined;
7461
+ if (marketType === 'swap') {
7462
+ response = await this.privateFuturesGetSettlePositionClose(this.extend(request, params));
7463
+ }
7464
+ else if (marketType === 'future') {
7465
+ response = await this.privateDeliveryGetSettlePositionClose(this.extend(request, params));
7466
+ }
7467
+ else {
7468
+ throw new errors.NotSupported(this.id + ' fetchPositionsHistory() does not support markets of type ' + marketType);
7469
+ }
7470
+ //
7471
+ // [
7472
+ // {
7473
+ // "contract": "SLERF_USDT",
7474
+ // "text": "web",
7475
+ // "long_price": "0.766306",
7476
+ // "pnl": "-23.41702352",
7477
+ // "pnl_pnl": "-22.7187",
7478
+ // "pnl_fee": "-0.06527125",
7479
+ // "pnl_fund": "-0.63305227",
7480
+ // "accum_size": "100",
7481
+ // "time": 1711279263,
7482
+ // "short_price": "0.539119",
7483
+ // "side": "long",
7484
+ // "max_size": "100",
7485
+ // "first_open_time": 1711037985
7486
+ // },
7487
+ // ...
7488
+ // ]
7489
+ //
7490
+ return this.parsePositions(response, symbols, params);
7491
+ }
7390
7492
  handleErrors(code, reason, url, method, headers, body, response, requestHeaders, requestBody) {
7391
7493
  if (response === undefined) {
7392
7494
  return undefined;
@@ -3241,8 +3241,9 @@ class hitbtc extends hitbtc$1 {
3241
3241
  throw new errors.ArgumentsRequired(this.id + ' modifyMarginHelper() requires a leverage parameter for swap markets');
3242
3242
  }
3243
3243
  }
3244
- if (amount !== 0) {
3245
- amount = this.amountToPrecision(symbol, amount);
3244
+ const stringAmount = this.numberToString(amount);
3245
+ if (stringAmount !== '0') {
3246
+ amount = this.amountToPrecision(symbol, stringAmount);
3246
3247
  }
3247
3248
  else {
3248
3249
  amount = '0';
@@ -3344,7 +3345,7 @@ class hitbtc extends hitbtc$1 {
3344
3345
  * @param {bool} [params.margin] true for reducing spot-margin
3345
3346
  * @returns {object} a [margin structure]{@link https://docs.ccxt.com/#/?id=reduce-margin-structure}
3346
3347
  */
3347
- if (amount !== 0) {
3348
+ if (this.numberToString(amount) !== '0') {
3348
3349
  throw new errors.BadRequest(this.id + ' reduceMargin() on hitbtc requires the amount to be 0 and that will remove the entire margin amount');
3349
3350
  }
3350
3351
  return await this.modifyMarginHelper(symbol, amount, 'reduce', params);
@@ -35,6 +35,7 @@ class htx extends htx$1 {
35
35
  'borrowCrossMargin': true,
36
36
  'borrowIsolatedMargin': true,
37
37
  'cancelAllOrders': true,
38
+ 'cancelAllOrdersAfter': true,
38
39
  'cancelOrder': true,
39
40
  'cancelOrders': true,
40
41
  'createDepositAddress': undefined,
@@ -101,7 +102,9 @@ class htx extends htx$1 {
101
102
  'fetchOrders': true,
102
103
  'fetchOrderTrades': true,
103
104
  'fetchPosition': true,
105
+ 'fetchPositionHistory': 'emulated',
104
106
  'fetchPositions': true,
107
+ 'fetchPositionsHistory': false,
105
108
  'fetchPositionsRisk': false,
106
109
  'fetchPremiumIndexOHLCV': true,
107
110
  'fetchSettlementHistory': true,
@@ -6163,6 +6166,33 @@ class htx extends htx$1 {
6163
6166
  //
6164
6167
  return response;
6165
6168
  }
6169
+ async cancelAllOrdersAfter(timeout, params = {}) {
6170
+ /**
6171
+ * @method
6172
+ * @name huobi#cancelAllOrdersAfter
6173
+ * @description dead man's switch, cancel all orders after the given timeout
6174
+ * @see https://huobiapi.github.io/docs/spot/v1/en/#dead-man-s-switch
6175
+ * @param {number} timeout time in milliseconds, 0 represents cancel the timer
6176
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
6177
+ * @returns {object} the api result
6178
+ */
6179
+ await this.loadMarkets();
6180
+ const request = {
6181
+ 'timeout': (timeout > 0) ? this.parseToInt(timeout / 1000) : 0,
6182
+ };
6183
+ const response = await this.v2PrivatePostAlgoOrdersCancelAllAfter(this.extend(request, params));
6184
+ //
6185
+ // {
6186
+ // "code": 200,
6187
+ // "message": "success",
6188
+ // "data": {
6189
+ // "currentTime": 1630491627230,
6190
+ // "triggerTime": 1630491637230
6191
+ // }
6192
+ // }
6193
+ //
6194
+ return response;
6195
+ }
6166
6196
  parseDepositAddress(depositAddress, currency = undefined) {
6167
6197
  //
6168
6198
  // {
@@ -35,6 +35,7 @@ class hyperliquid extends hyperliquid$1 {
35
35
  'borrowCrossMargin': false,
36
36
  'borrowIsolatedMargin': false,
37
37
  'cancelAllOrders': false,
38
+ 'cancelAllOrdersAfter': true,
38
39
  'cancelOrder': true,
39
40
  'cancelOrders': true,
40
41
  'cancelOrdersForSymbols': true,
@@ -1361,6 +1362,45 @@ class hyperliquid extends hyperliquid$1 {
1361
1362
  //
1362
1363
  return response;
1363
1364
  }
1365
+ async cancelAllOrdersAfter(timeout, params = {}) {
1366
+ /**
1367
+ * @method
1368
+ * @name hyperliquid#cancelAllOrdersAfter
1369
+ * @description dead man's switch, cancel all orders after the given timeout
1370
+ * @param {number} timeout time in milliseconds, 0 represents cancel the timer
1371
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1372
+ * @param {string} [params.vaultAddress] the vault address
1373
+ * @returns {object} the api result
1374
+ */
1375
+ this.checkRequiredCredentials();
1376
+ await this.loadMarkets();
1377
+ params = this.omit(params, ['clientOrderId', 'client_id']);
1378
+ const nonce = this.milliseconds();
1379
+ const request = {
1380
+ 'nonce': nonce,
1381
+ // 'vaultAddress': vaultAddress,
1382
+ };
1383
+ const cancelAction = {
1384
+ 'type': 'scheduleCancel',
1385
+ 'time': nonce + timeout,
1386
+ };
1387
+ const vaultAddress = this.formatVaultAddress(this.safeString(params, 'vaultAddress'));
1388
+ const signature = this.signL1Action(cancelAction, nonce, vaultAddress);
1389
+ request['action'] = cancelAction;
1390
+ request['signature'] = signature;
1391
+ if (vaultAddress !== undefined) {
1392
+ params = this.omit(params, 'vaultAddress');
1393
+ request['vaultAddress'] = vaultAddress;
1394
+ }
1395
+ const response = await this.privatePostExchange(this.extend(request, params));
1396
+ //
1397
+ // {
1398
+ // "status":"err",
1399
+ // "response":"Cannot set scheduled cancel time until enough volume traded. Required: $1000000. Traded: $373.47205."
1400
+ // }
1401
+ //
1402
+ return response;
1403
+ }
1364
1404
  async editOrder(id, symbol, type, side, amount = undefined, price = undefined, params = {}) {
1365
1405
  /**
1366
1406
  * @method
@@ -77,8 +77,11 @@ class idex extends idex$1 {
77
77
  'fetchOrderBook': true,
78
78
  'fetchOrders': false,
79
79
  'fetchPosition': false,
80
+ 'fetchPositionHistory': false,
80
81
  'fetchPositionMode': false,
81
82
  'fetchPositions': false,
83
+ 'fetchPositionsForSymbol': false,
84
+ 'fetchPositionsHistory': false,
82
85
  'fetchPositionsRisk': false,
83
86
  'fetchPremiumIndexOHLCV': false,
84
87
  'fetchStatus': true,
@@ -62,8 +62,11 @@ class independentreserve extends independentreserve$1 {
62
62
  'fetchOrder': true,
63
63
  'fetchOrderBook': true,
64
64
  'fetchPosition': false,
65
+ 'fetchPositionHistory': false,
65
66
  'fetchPositionMode': false,
66
67
  'fetchPositions': false,
68
+ 'fetchPositionsForSymbol': false,
69
+ 'fetchPositionsHistory': false,
67
70
  'fetchPositionsRisk': false,
68
71
  'fetchPremiumIndexOHLCV': false,
69
72
  'fetchTicker': true,
@@ -69,8 +69,11 @@ class indodax extends indodax$1 {
69
69
  'fetchOrderBook': true,
70
70
  'fetchOrders': false,
71
71
  'fetchPosition': false,
72
+ 'fetchPositionHistory': false,
72
73
  'fetchPositionMode': false,
73
74
  'fetchPositions': false,
75
+ 'fetchPositionsForSymbol': false,
76
+ 'fetchPositionsHistory': false,
74
77
  'fetchPositionsRisk': false,
75
78
  'fetchPremiumIndexOHLCV': false,
76
79
  'fetchTicker': true,
@@ -36,6 +36,7 @@ class kraken extends kraken$1 {
36
36
  'option': false,
37
37
  'addMargin': false,
38
38
  'cancelAllOrders': true,
39
+ 'cancelAllOrdersAfter': true,
39
40
  'cancelOrder': true,
40
41
  'cancelOrders': true,
41
42
  'createDepositAddress': true,
@@ -2136,6 +2137,35 @@ class kraken extends kraken$1 {
2136
2137
  await this.loadMarkets();
2137
2138
  return await this.privatePostCancelAll(params);
2138
2139
  }
2140
+ async cancelAllOrdersAfter(timeout, params = {}) {
2141
+ /**
2142
+ * @method
2143
+ * @name kraken#cancelAllOrdersAfter
2144
+ * @description dead man's switch, cancel all orders after the given timeout
2145
+ * @see https://docs.kraken.com/rest/#tag/Spot-Trading/operation/cancelAllOrdersAfter
2146
+ * @param {number} timeout time in milliseconds, 0 represents cancel the timer
2147
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
2148
+ * @returns {object} the api result
2149
+ */
2150
+ if (timeout > 86400000) {
2151
+ throw new errors.BadRequest(this.id + 'cancelAllOrdersAfter timeout should be less than 86400000 milliseconds');
2152
+ }
2153
+ await this.loadMarkets();
2154
+ const request = {
2155
+ 'timeout': (timeout > 0) ? (this.parseToInt(timeout / 1000)) : 0,
2156
+ };
2157
+ const response = await this.privatePostCancelAllOrdersAfter(this.extend(request, params));
2158
+ //
2159
+ // {
2160
+ // "error": [ ],
2161
+ // "result": {
2162
+ // "currentTime": "2023-03-24T17:41:56Z",
2163
+ // "triggerTime": "2023-03-24T17:42:56Z"
2164
+ // }
2165
+ // }
2166
+ //
2167
+ return response;
2168
+ }
2139
2169
  async fetchOpenOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
2140
2170
  /**
2141
2171
  * @method
@@ -31,6 +31,7 @@ class krakenfutures extends krakenfutures$1 {
31
31
  'future': true,
32
32
  'option': false,
33
33
  'cancelAllOrders': true,
34
+ 'cancelAllOrdersAfter': true,
34
35
  'cancelOrder': true,
35
36
  'cancelOrders': true,
36
37
  'createMarketOrder': false,
@@ -1269,6 +1270,33 @@ class krakenfutures extends krakenfutures$1 {
1269
1270
  const response = await this.privatePostCancelallorders(this.extend(request, params));
1270
1271
  return response;
1271
1272
  }
1273
+ async cancelAllOrdersAfter(timeout, params = {}) {
1274
+ /**
1275
+ * @method
1276
+ * @name krakenfutures#cancelAllOrdersAfter
1277
+ * @description dead man's switch, cancel all orders after the given timeout
1278
+ * @see https://docs.futures.kraken.com/#http-api-trading-v3-api-order-management-dead-man-39-s-switch
1279
+ * @param {number} timeout time in milliseconds, 0 represents cancel the timer
1280
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1281
+ * @returns {object} the api result
1282
+ */
1283
+ await this.loadMarkets();
1284
+ const request = {
1285
+ 'timeout': (timeout > 0) ? (this.parseToInt(timeout / 1000)) : 0,
1286
+ };
1287
+ const response = await this.privatePostCancelallordersafter(this.extend(request, params));
1288
+ //
1289
+ // {
1290
+ // "result": "success",
1291
+ // "serverTime": "2018-06-19T16:51:23.839Z",
1292
+ // "status": {
1293
+ // "currentTime": "2018-06-19T16:51:23.839Z",
1294
+ // "triggerTime": "0"
1295
+ // }
1296
+ // }
1297
+ //
1298
+ return response;
1299
+ }
1272
1300
  async fetchOpenOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
1273
1301
  /**
1274
1302
  * @method
@@ -88,7 +88,9 @@ class kucoin extends kucoin$1 {
88
88
  'fetchOrderBooks': false,
89
89
  'fetchOrdersByStatus': true,
90
90
  'fetchOrderTrades': true,
91
+ 'fetchPositionHistory': false,
91
92
  'fetchPositionMode': false,
93
+ 'fetchPositionsHistory': false,
92
94
  'fetchPremiumIndexOHLCV': false,
93
95
  'fetchStatus': true,
94
96
  'fetchTicker': true,
@@ -78,8 +78,10 @@ class kucoinfutures extends kucoinfutures$1 {
78
78
  'fetchOrder': true,
79
79
  'fetchOrderBook': true,
80
80
  'fetchPosition': true,
81
+ 'fetchPositionHistory': false,
81
82
  'fetchPositionMode': false,
82
83
  'fetchPositions': true,
84
+ 'fetchPositionsHistory': false,
83
85
  'fetchPremiumIndexOHLCV': false,
84
86
  'fetchStatus': true,
85
87
  'fetchTicker': true,
@@ -2195,8 +2197,8 @@ class kucoinfutures extends kucoinfutures$1 {
2195
2197
  // symbol (String) [optional] Symbol of the contract
2196
2198
  // side (String) [optional] buy or sell
2197
2199
  // type (String) [optional] limit, market, limit_stop or market_stop
2198
- // startAt (long) [optional] Start time (milisecond)
2199
- // endAt (long) [optional] End time (milisecond)
2200
+ // startAt (long) [optional] Start time (millisecond)
2201
+ // endAt (long) [optional] End time (millisecond)
2200
2202
  };
2201
2203
  let market = undefined;
2202
2204
  if (symbol !== undefined) {
@@ -55,7 +55,13 @@ class latoken extends latoken$1 {
55
55
  'fetchOrder': true,
56
56
  'fetchOrderBook': true,
57
57
  'fetchOrders': true,
58
+ 'fetchPosition': false,
59
+ 'fetchPositionHistory': false,
58
60
  'fetchPositionMode': false,
61
+ 'fetchPositions': false,
62
+ 'fetchPositionsForSymbol': false,
63
+ 'fetchPositionsHistory': false,
64
+ 'fetchPositionsRisk': false,
59
65
  'fetchTicker': true,
60
66
  'fetchTickers': true,
61
67
  'fetchTime': true,
@@ -61,8 +61,11 @@ class luno extends luno$1 {
61
61
  'fetchOrderBook': true,
62
62
  'fetchOrders': true,
63
63
  'fetchPosition': false,
64
+ 'fetchPositionHistory': false,
64
65
  'fetchPositionMode': false,
65
66
  'fetchPositions': false,
67
+ 'fetchPositionsForSymbol': false,
68
+ 'fetchPositionsHistory': false,
66
69
  'fetchPositionsRisk': false,
67
70
  'fetchPremiumIndexOHLCV': false,
68
71
  'fetchTicker': true,
@@ -63,8 +63,13 @@ class lykke extends lykke$1 {
63
63
  'fetchOrderBook': true,
64
64
  'fetchOrders': false,
65
65
  'fetchOrderTrades': false,
66
+ 'fetchPosition': false,
67
+ 'fetchPositionHistory': false,
66
68
  'fetchPositionMode': false,
67
69
  'fetchPositions': false,
70
+ 'fetchPositionsForSymbol': false,
71
+ 'fetchPositionsHistory': false,
72
+ 'fetchPositionsRisk': false,
68
73
  'fetchPremiumIndexOHLCV': false,
69
74
  'fetchTicker': true,
70
75
  'fetchTickers': true,
@@ -63,8 +63,11 @@ class mercado extends mercado$1 {
63
63
  'fetchOrderBook': true,
64
64
  'fetchOrders': true,
65
65
  'fetchPosition': false,
66
+ 'fetchPositionHistory': false,
66
67
  'fetchPositionMode': false,
67
68
  'fetchPositions': false,
69
+ 'fetchPositionsForSymbol': false,
70
+ 'fetchPositionsHistory': false,
68
71
  'fetchPositionsRisk': false,
69
72
  'fetchPremiumIndexOHLCV': false,
70
73
  'fetchTicker': true,