ccxt 4.4.33 → 4.4.35

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 (122) hide show
  1. package/README.md +8 -7
  2. package/dist/ccxt.browser.min.js +6 -6
  3. package/dist/cjs/ccxt.js +4 -1
  4. package/dist/cjs/src/abstract/ellipx.js +9 -0
  5. package/dist/cjs/src/alpaca.js +2 -0
  6. package/dist/cjs/src/base/Exchange.js +32 -6
  7. package/dist/cjs/src/binance.js +19 -14
  8. package/dist/cjs/src/bingx.js +495 -153
  9. package/dist/cjs/src/bitbank.js +5 -0
  10. package/dist/cjs/src/bitbns.js +2 -0
  11. package/dist/cjs/src/bitfinex2.js +2 -1
  12. package/dist/cjs/src/bitget.js +177 -44
  13. package/dist/cjs/src/bitmex.js +3 -1
  14. package/dist/cjs/src/bitopro.js +3 -0
  15. package/dist/cjs/src/bitrue.js +3 -2
  16. package/dist/cjs/src/btcmarkets.js +5 -3
  17. package/dist/cjs/src/btcturk.js +19 -19
  18. package/dist/cjs/src/bybit.js +14 -11
  19. package/dist/cjs/src/cex.js +13 -4
  20. package/dist/cjs/src/coinbase.js +3 -2
  21. package/dist/cjs/src/coinex.js +1 -0
  22. package/dist/cjs/src/coinone.js +7 -7
  23. package/dist/cjs/src/coinsph.js +7 -7
  24. package/dist/cjs/src/coinspot.js +39 -39
  25. package/dist/cjs/src/cryptocom.js +36 -34
  26. package/dist/cjs/src/ellipx.js +1871 -0
  27. package/dist/cjs/src/gate.js +145 -41
  28. package/dist/cjs/src/hyperliquid.js +75 -11
  29. package/dist/cjs/src/idex.js +3 -3
  30. package/dist/cjs/src/kraken.js +71 -54
  31. package/dist/cjs/src/krakenfutures.js +3 -1
  32. package/dist/cjs/src/kucoin.js +1 -1
  33. package/dist/cjs/src/okcoin.js +2 -0
  34. package/dist/cjs/src/okx.js +16 -11
  35. package/dist/cjs/src/onetrading.js +34 -396
  36. package/dist/cjs/src/paradex.js +2 -0
  37. package/dist/cjs/src/phemex.js +23 -0
  38. package/dist/cjs/src/poloniex.js +3 -1
  39. package/dist/cjs/src/poloniexfutures.js +3 -1
  40. package/dist/cjs/src/pro/bitrue.js +13 -11
  41. package/dist/cjs/src/pro/idex.js +5 -0
  42. package/dist/cjs/src/pro/probit.js +62 -68
  43. package/dist/cjs/src/pro/woo.js +15 -15
  44. package/dist/cjs/src/vertex.js +2 -0
  45. package/dist/cjs/src/woo.js +69 -69
  46. package/dist/cjs/src/xt.js +5 -5
  47. package/examples/js/cli.js +1 -1
  48. package/js/ccxt.d.ts +5 -2
  49. package/js/ccxt.js +4 -2
  50. package/js/src/abstract/bingx.d.ts +17 -0
  51. package/js/src/abstract/bitbank.d.ts +5 -0
  52. package/js/src/abstract/bitfinex2.d.ts +1 -0
  53. package/js/src/abstract/bitpanda.d.ts +0 -12
  54. package/js/src/abstract/bitrue.d.ts +3 -3
  55. package/js/src/abstract/ellipx.d.ts +28 -0
  56. package/js/src/abstract/ellipx.js +11 -0
  57. package/js/src/abstract/okx.d.ts +1 -0
  58. package/js/src/abstract/onetrading.d.ts +0 -12
  59. package/js/src/alpaca.js +2 -0
  60. package/js/src/base/Exchange.d.ts +8 -0
  61. package/js/src/base/Exchange.js +32 -6
  62. package/js/src/binance.js +19 -14
  63. package/js/src/bingx.d.ts +11 -1
  64. package/js/src/bingx.js +495 -153
  65. package/js/src/bitbank.js +5 -0
  66. package/js/src/bitbns.js +2 -0
  67. package/js/src/bitfinex2.js +2 -1
  68. package/js/src/bitget.d.ts +4 -4
  69. package/js/src/bitget.js +177 -44
  70. package/js/src/bitmex.js +3 -1
  71. package/js/src/bitopro.d.ts +1 -0
  72. package/js/src/bitopro.js +3 -0
  73. package/js/src/bitrue.js +3 -2
  74. package/js/src/btcmarkets.d.ts +1 -0
  75. package/js/src/btcmarkets.js +5 -3
  76. package/js/src/btcturk.js +19 -19
  77. package/js/src/bybit.d.ts +3 -2
  78. package/js/src/bybit.js +14 -11
  79. package/js/src/cex.d.ts +1 -0
  80. package/js/src/cex.js +13 -4
  81. package/js/src/coinbase.d.ts +2 -1
  82. package/js/src/coinbase.js +3 -2
  83. package/js/src/coinex.js +1 -0
  84. package/js/src/coinone.js +7 -7
  85. package/js/src/coinsph.js +7 -7
  86. package/js/src/coinspot.js +39 -39
  87. package/js/src/cryptocom.d.ts +1 -1
  88. package/js/src/cryptocom.js +36 -34
  89. package/js/src/ellipx.d.ts +236 -0
  90. package/js/src/ellipx.js +1874 -0
  91. package/js/src/gate.d.ts +7 -7
  92. package/js/src/gate.js +145 -41
  93. package/js/src/hyperliquid.d.ts +10 -0
  94. package/js/src/hyperliquid.js +77 -13
  95. package/js/src/idex.js +4 -4
  96. package/js/src/kraken.d.ts +11 -8
  97. package/js/src/kraken.js +71 -54
  98. package/js/src/krakenfutures.js +3 -1
  99. package/js/src/kucoin.js +1 -1
  100. package/js/src/okcoin.js +2 -0
  101. package/js/src/okx.d.ts +1 -1
  102. package/js/src/okx.js +16 -11
  103. package/js/src/onetrading.d.ts +20 -67
  104. package/js/src/onetrading.js +35 -397
  105. package/js/src/paradex.js +2 -0
  106. package/js/src/phemex.js +23 -0
  107. package/js/src/poloniex.d.ts +1 -1
  108. package/js/src/poloniex.js +3 -1
  109. package/js/src/poloniexfutures.d.ts +1 -1
  110. package/js/src/poloniexfutures.js +3 -1
  111. package/js/src/pro/bitrue.js +13 -11
  112. package/js/src/pro/idex.d.ts +5 -0
  113. package/js/src/pro/idex.js +5 -0
  114. package/js/src/pro/probit.d.ts +2 -1
  115. package/js/src/pro/probit.js +62 -68
  116. package/js/src/pro/woo.d.ts +11 -11
  117. package/js/src/pro/woo.js +15 -15
  118. package/js/src/vertex.js +2 -0
  119. package/js/src/woo.d.ts +60 -60
  120. package/js/src/woo.js +69 -69
  121. package/js/src/xt.js +5 -5
  122. package/package.json +4 -3
@@ -690,6 +690,110 @@ class gate extends gate$1 {
690
690
  },
691
691
  },
692
692
  },
693
+ 'features': {
694
+ 'spot': {
695
+ 'sandbox': true,
696
+ 'createOrder': {
697
+ 'marginMode': true,
698
+ 'triggerPrice': true,
699
+ 'triggerDirection': true,
700
+ 'triggerPriceType': undefined,
701
+ 'stopLossPrice': true,
702
+ 'takeProfitPrice': true,
703
+ 'attachedStopLossTakeProfit': undefined,
704
+ 'timeInForce': {
705
+ 'GTC': true,
706
+ 'IOC': true,
707
+ 'FOK': true,
708
+ 'PO': true,
709
+ 'GTD': false,
710
+ },
711
+ 'hedged': false,
712
+ 'trailing': false,
713
+ // exchange-specific features
714
+ 'iceberg': true,
715
+ 'selfTradePrevention': true,
716
+ },
717
+ 'createOrders': {
718
+ 'max': 40, // NOTE! max 10 per symbol
719
+ },
720
+ 'fetchMyTrades': {
721
+ 'marginMode': true,
722
+ 'limit': 1000,
723
+ 'daysBack': undefined,
724
+ 'untilDays': 30,
725
+ },
726
+ 'fetchOrder': {
727
+ 'marginMode': false,
728
+ 'trigger': true,
729
+ 'trailing': false,
730
+ },
731
+ 'fetchOpenOrders': {
732
+ 'marginMode': true,
733
+ 'trigger': true,
734
+ 'trailing': false,
735
+ 'limit': 100,
736
+ },
737
+ 'fetchOrders': undefined,
738
+ 'fetchClosedOrders': {
739
+ 'marginMode': true,
740
+ 'trigger': true,
741
+ 'trailing': false,
742
+ 'limit': 100,
743
+ 'untilDays': 30,
744
+ 'daysBackClosed': undefined,
745
+ 'daysBackCanceled': undefined,
746
+ },
747
+ 'fetchOHLCV': {
748
+ 'limit': 1000,
749
+ },
750
+ },
751
+ 'forDerivatives': {
752
+ 'extends': 'spot',
753
+ 'createOrder': {
754
+ 'marginMode': false,
755
+ 'triggerPriceType': {
756
+ 'last': true,
757
+ 'mark': true,
758
+ 'index': true,
759
+ },
760
+ },
761
+ 'createOrders': {
762
+ 'max': 10,
763
+ },
764
+ 'fetchMyTrades': {
765
+ 'marginMode': false,
766
+ 'untilDays': undefined,
767
+ },
768
+ 'fetchOpenOrders': {
769
+ 'marginMode': false,
770
+ },
771
+ 'fetchClosedOrders': {
772
+ 'marginMode': false,
773
+ 'untilDays': undefined,
774
+ 'limit': 1000,
775
+ },
776
+ 'fetchOHLCV': {
777
+ 'limit': 1999,
778
+ },
779
+ },
780
+ 'swap': {
781
+ 'linear': {
782
+ 'extends': 'forDerivatives',
783
+ },
784
+ 'inverse': {
785
+ 'extends': 'forDerivatives',
786
+ },
787
+ },
788
+ 'future': {
789
+ 'linear': {
790
+ 'extends': 'forDerivatives',
791
+ },
792
+ 'inverse': {
793
+ 'extends': 'forDerivatives',
794
+ },
795
+ },
796
+ },
693
797
  'precisionMode': number.TICK_SIZE,
694
798
  'fees': {
695
799
  'trading': {
@@ -898,7 +1002,7 @@ class gate extends gate$1 {
898
1002
  }
899
1003
  /**
900
1004
  * @method
901
- * @name gate#isUnifiedEnabled
1005
+ * @name gate#loadUnifiedStatus
902
1006
  * @param {object} [params] extra parameters specific to the exchange API endpoint
903
1007
  * @description returns unifiedAccount so the user can check if the unified account is enabled
904
1008
  * @see https://www.gate.io/docs/developers/apiv4/#get-account-detail
@@ -930,6 +1034,7 @@ class gate extends gate$1 {
930
1034
  this.options['unifiedAccount'] = false;
931
1035
  }
932
1036
  }
1037
+ return this.options['unifiedAccount'];
933
1038
  }
934
1039
  async upgradeUnifiedTradeAccount(params = {}) {
935
1040
  return await this.privateUnifiedPutUnifiedMode(params);
@@ -1539,25 +1644,25 @@ class gate extends gate$1 {
1539
1644
  }
1540
1645
  return [request, params];
1541
1646
  }
1542
- spotOrderPrepareRequest(market = undefined, stop = false, params = {}) {
1647
+ spotOrderPrepareRequest(market = undefined, trigger = false, params = {}) {
1543
1648
  /**
1544
1649
  * @ignore
1545
1650
  * @method
1546
1651
  * @name gate#multiOrderSpotPrepareRequest
1547
1652
  * @description Fills request params currency_pair, market and account where applicable for spot order methods like fetchOpenOrders, cancelAllOrders
1548
1653
  * @param {object} market CCXT market
1549
- * @param {bool} stop true if for a stop order
1654
+ * @param {bool} trigger true if for a trigger order
1550
1655
  * @param {object} [params] request parameters
1551
1656
  * @returns the api request object, and the new params object with non-needed parameters removed
1552
1657
  */
1553
- const [marginMode, query] = this.getMarginMode(stop, params);
1658
+ const [marginMode, query] = this.getMarginMode(trigger, params);
1554
1659
  const request = {};
1555
- if (!stop) {
1660
+ if (!trigger) {
1556
1661
  if (market === undefined) {
1557
- throw new errors.ArgumentsRequired(this.id + ' spotOrderPrepareRequest() requires a market argument for non-stop orders');
1662
+ throw new errors.ArgumentsRequired(this.id + ' spotOrderPrepareRequest() requires a market argument for non-trigger orders');
1558
1663
  }
1559
1664
  request['account'] = marginMode;
1560
- request['currency_pair'] = market['id']; // Should always be set for non-stop
1665
+ request['currency_pair'] = market['id']; // Should always be set for non-trigger
1561
1666
  }
1562
1667
  return [request, query];
1563
1668
  }
@@ -1568,7 +1673,7 @@ class gate extends gate$1 {
1568
1673
  * @name gate#multiOrderSpotPrepareRequest
1569
1674
  * @description Fills request params currency_pair, market and account where applicable for spot order methods like fetchOpenOrders, cancelAllOrders
1570
1675
  * @param {object} market CCXT market
1571
- * @param {bool} stop true if for a stop order
1676
+ * @param {bool} trigger true if for a trigger order
1572
1677
  * @param {object} [params] request parameters
1573
1678
  * @returns the api request object, and the new params object with non-needed parameters removed
1574
1679
  */
@@ -1578,7 +1683,7 @@ class gate extends gate$1 {
1578
1683
  };
1579
1684
  if (market !== undefined) {
1580
1685
  if (trigger) {
1581
- // gate spot and margin stop orders use the term market instead of currency_pair, and normal instead of spot. Neither parameter is used when fetching/cancelling a single order. They are used for creating a single stop order, but createOrder does not call this method
1686
+ // gate spot and margin trigger orders use the term market instead of currency_pair, and normal instead of spot. Neither parameter is used when fetching/cancelling a single order. They are used for creating a single trigger order, but createOrder does not call this method
1582
1687
  request['market'] = market['id'];
1583
1688
  }
1584
1689
  else {
@@ -1587,13 +1692,13 @@ class gate extends gate$1 {
1587
1692
  }
1588
1693
  return [request, query];
1589
1694
  }
1590
- getMarginMode(stop, params) {
1695
+ getMarginMode(trigger, params) {
1591
1696
  /**
1592
1697
  * @ignore
1593
1698
  * @method
1594
1699
  * @name gate#getMarginMode
1595
1700
  * @description Gets the margin type for this api call
1596
- * @param {bool} stop True if for a stop order
1701
+ * @param {bool} trigger True if for a trigger order
1597
1702
  * @param {object} [params] Request params
1598
1703
  * @returns The marginMode and the updated request params with marginMode removed, marginMode value is the value that can be read by the "account" property specified in gates api docs
1599
1704
  */
@@ -1609,13 +1714,13 @@ class gate extends gate$1 {
1609
1714
  else if (marginMode === '') {
1610
1715
  marginMode = 'spot';
1611
1716
  }
1612
- if (stop) {
1717
+ if (trigger) {
1613
1718
  if (marginMode === 'spot') {
1614
- // gate spot stop orders use the term normal instead of spot
1719
+ // gate spot trigger orders use the term normal instead of spot
1615
1720
  marginMode = 'normal';
1616
1721
  }
1617
1722
  if (marginMode === 'cross_margin') {
1618
- throw new errors.BadRequest(this.id + ' getMarginMode() does not support stop orders for cross margin');
1723
+ throw new errors.BadRequest(this.id + ' getMarginMode() does not support trigger orders for cross margin');
1619
1724
  }
1620
1725
  }
1621
1726
  let isUnifiedAccount = false;
@@ -3071,7 +3176,7 @@ class gate extends gate$1 {
3071
3176
  let request = {};
3072
3177
  [request, params] = this.prepareRequest(market, undefined, params);
3073
3178
  request['interval'] = this.safeString(this.timeframes, timeframe, timeframe);
3074
- let maxLimit = market['contract'] ? 1999 : 1000;
3179
+ const maxLimit = market['contract'] ? 1999 : 1000;
3075
3180
  limit = (limit === undefined) ? maxLimit : Math.min(limit, maxLimit);
3076
3181
  let until = this.safeInteger(params, 'until');
3077
3182
  if (until !== undefined) {
@@ -3100,7 +3205,6 @@ class gate extends gate$1 {
3100
3205
  }
3101
3206
  let response = undefined;
3102
3207
  if (market['contract']) {
3103
- maxLimit = 1999;
3104
3208
  const isMark = (price === 'mark');
3105
3209
  const isIndex = (price === 'index');
3106
3210
  if (isMark || isIndex) {
@@ -3444,7 +3548,7 @@ class gate extends gate$1 {
3444
3548
  }
3445
3549
  else {
3446
3550
  if (market !== undefined) {
3447
- request['currency_pair'] = market['id']; // Should always be set for non-stop
3551
+ request['currency_pair'] = market['id']; // Should always be set for non-trigger
3448
3552
  }
3449
3553
  [marginMode, params] = this.getMarginMode(false, params);
3450
3554
  request['account'] = marginMode;
@@ -3992,8 +4096,8 @@ class gate extends gate$1 {
3992
4096
  const takeProfitPrice = this.safeValue(params, 'takeProfitPrice');
3993
4097
  const isStopLossOrder = stopLossPrice !== undefined;
3994
4098
  const isTakeProfitOrder = takeProfitPrice !== undefined;
3995
- const isStopOrder = isStopLossOrder || isTakeProfitOrder;
3996
- const nonTriggerOrder = !isStopOrder && (trigger === undefined);
4099
+ const isTpsl = isStopLossOrder || isTakeProfitOrder;
4100
+ const nonTriggerOrder = !isTpsl && (trigger === undefined);
3997
4101
  const orderRequest = this.createOrderRequest(symbol, type, side, amount, price, params);
3998
4102
  let response = undefined;
3999
4103
  if (market['spot'] || market['margin']) {
@@ -4159,7 +4263,7 @@ class gate extends gate$1 {
4159
4263
  const takeProfitPrice = this.safeValue(params, 'takeProfitPrice');
4160
4264
  const isStopLossOrder = stopLossPrice !== undefined;
4161
4265
  const isTakeProfitOrder = takeProfitPrice !== undefined;
4162
- const isStopOrder = isStopLossOrder || isTakeProfitOrder;
4266
+ const isTpsl = isStopLossOrder || isTakeProfitOrder;
4163
4267
  if (isStopLossOrder && isTakeProfitOrder) {
4164
4268
  throw new errors.ExchangeError(this.id + ' createOrder() stopLossPrice and takeProfitPrice cannot both be defined');
4165
4269
  }
@@ -4206,7 +4310,7 @@ class gate extends gate$1 {
4206
4310
  }
4207
4311
  }
4208
4312
  let request = undefined;
4209
- const nonTriggerOrder = !isStopOrder && (trigger === undefined);
4313
+ const nonTriggerOrder = !isTpsl && (trigger === undefined);
4210
4314
  if (nonTriggerOrder) {
4211
4315
  if (contract) {
4212
4316
  // contract order
@@ -4819,7 +4923,7 @@ class gate extends gate$1 {
4819
4923
  }
4820
4924
  fetchOrderRequest(id, symbol = undefined, params = {}) {
4821
4925
  const market = (symbol === undefined) ? undefined : this.market(symbol);
4822
- const stop = this.safeBoolN(params, ['trigger', 'is_stop_order', 'stop'], false);
4926
+ const trigger = this.safeBoolN(params, ['trigger', 'is_stop_order', 'stop'], false);
4823
4927
  params = this.omit(params, ['is_stop_order', 'stop', 'trigger']);
4824
4928
  let clientOrderId = this.safeString2(params, 'text', 'clientOrderId');
4825
4929
  let orderId = id;
@@ -4832,7 +4936,7 @@ class gate extends gate$1 {
4832
4936
  }
4833
4937
  const [type, query] = this.handleMarketTypeAndParams('fetchOrder', market, params);
4834
4938
  const contract = (type === 'swap') || (type === 'future') || (type === 'option');
4835
- const [request, requestParams] = contract ? this.prepareRequest(market, type, query) : this.spotOrderPrepareRequest(market, stop, query);
4939
+ const [request, requestParams] = contract ? this.prepareRequest(market, type, query) : this.spotOrderPrepareRequest(market, trigger, query);
4836
4940
  request['order_id'] = orderId.toString();
4837
4941
  return [request, requestParams];
4838
4942
  }
@@ -4860,11 +4964,11 @@ class gate extends gate$1 {
4860
4964
  const market = (symbol === undefined) ? undefined : this.market(symbol);
4861
4965
  const result = this.handleMarketTypeAndParams('fetchOrder', market, params);
4862
4966
  const type = this.safeString(result, 0);
4863
- const stop = this.safeBoolN(params, ['trigger', 'is_stop_order', 'stop'], false);
4967
+ const trigger = this.safeBoolN(params, ['trigger', 'is_stop_order', 'stop'], false);
4864
4968
  const [request, requestParams] = this.fetchOrderRequest(id, symbol, params);
4865
4969
  let response = undefined;
4866
4970
  if (type === 'spot' || type === 'margin') {
4867
- if (stop) {
4971
+ if (trigger) {
4868
4972
  response = await this.privateSpotGetPriceOrdersOrderId(this.extend(request, requestParams));
4869
4973
  }
4870
4974
  else {
@@ -4872,7 +4976,7 @@ class gate extends gate$1 {
4872
4976
  }
4873
4977
  }
4874
4978
  else if (type === 'swap') {
4875
- if (stop) {
4979
+ if (trigger) {
4876
4980
  response = await this.privateFuturesGetSettlePriceOrdersOrderId(this.extend(request, requestParams));
4877
4981
  }
4878
4982
  else {
@@ -4880,7 +4984,7 @@ class gate extends gate$1 {
4880
4984
  }
4881
4985
  }
4882
4986
  else if (type === 'future') {
4883
- if (stop) {
4987
+ if (trigger) {
4884
4988
  response = await this.privateDeliveryGetSettlePriceOrdersOrderId(this.extend(request, requestParams));
4885
4989
  }
4886
4990
  else {
@@ -4905,7 +5009,7 @@ class gate extends gate$1 {
4905
5009
  * @param {int} [since] the earliest time in ms to fetch open orders for
4906
5010
  * @param {int} [limit] the maximum number of open orders structures to retrieve
4907
5011
  * @param {object} [params] extra parameters specific to the exchange API endpoint
4908
- * @param {bool} [params.stop] true for fetching stop orders
5012
+ * @param {bool} [params.trigger] true for fetching trigger orders
4909
5013
  * @param {string} [params.type] spot, margin, swap or future, if not provided this.options['defaultType'] is used
4910
5014
  * @param {string} [params.marginMode] 'cross' or 'isolated' - marginMode for type='margin', if not provided this.options['defaultMarginMode'] is used
4911
5015
  * @param {bool} [params.unifiedAccount] set to true for fetching unified account orders
@@ -4930,7 +5034,7 @@ class gate extends gate$1 {
4930
5034
  * @param {int} [since] the earliest time in ms to fetch orders for
4931
5035
  * @param {int} [limit] the maximum number of order structures to retrieve
4932
5036
  * @param {object} [params] extra parameters specific to the exchange API endpoint
4933
- * @param {bool} [params.stop] true for fetching stop orders
5037
+ * @param {bool} [params.trigger] true for fetching trigger orders
4934
5038
  * @param {string} [params.type] spot, swap or future, if not provided this.options['defaultType'] is used
4935
5039
  * @param {string} [params.marginMode] 'cross' or 'isolated' - marginMode for margin trading if not provided this.options['defaultMarginMode'] is used
4936
5040
  * @param {boolean} [params.historical] *swap only* true for using historical endpoint
@@ -5132,7 +5236,7 @@ class gate extends gate$1 {
5132
5236
  // }
5133
5237
  // ]
5134
5238
  //
5135
- // spot stop
5239
+ // spot trigger
5136
5240
  //
5137
5241
  // [
5138
5242
  // {
@@ -5228,7 +5332,7 @@ class gate extends gate$1 {
5228
5332
  * @param {string} id Order id
5229
5333
  * @param {string} symbol Unified market symbol
5230
5334
  * @param {object} [params] Parameters specified by the exchange api
5231
- * @param {bool} [params.stop] True if the order to be cancelled is a trigger order
5335
+ * @param {bool} [params.trigger] True if the order to be cancelled is a trigger order
5232
5336
  * @param {bool} [params.unifiedAccount] set to true for canceling unified account orders
5233
5337
  * @returns An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
5234
5338
  */
@@ -5236,14 +5340,14 @@ class gate extends gate$1 {
5236
5340
  await this.loadMarkets();
5237
5341
  await this.loadUnifiedStatus();
5238
5342
  const market = (symbol === undefined) ? undefined : this.market(symbol);
5239
- const stop = this.safeBoolN(params, ['is_stop_order', 'stop', 'trigger'], false);
5343
+ const trigger = this.safeBoolN(params, ['is_stop_order', 'stop', 'trigger'], false);
5240
5344
  params = this.omit(params, ['is_stop_order', 'stop', 'trigger']);
5241
5345
  const [type, query] = this.handleMarketTypeAndParams('cancelOrder', market, params);
5242
- const [request, requestParams] = (type === 'spot' || type === 'margin') ? this.spotOrderPrepareRequest(market, stop, query) : this.prepareRequest(market, type, query);
5346
+ const [request, requestParams] = (type === 'spot' || type === 'margin') ? this.spotOrderPrepareRequest(market, trigger, query) : this.prepareRequest(market, type, query);
5243
5347
  request['order_id'] = id;
5244
5348
  let response = undefined;
5245
5349
  if (type === 'spot' || type === 'margin') {
5246
- if (stop) {
5350
+ if (trigger) {
5247
5351
  response = await this.privateSpotDeletePriceOrdersOrderId(this.extend(request, requestParams));
5248
5352
  }
5249
5353
  else {
@@ -5251,7 +5355,7 @@ class gate extends gate$1 {
5251
5355
  }
5252
5356
  }
5253
5357
  else if (type === 'swap') {
5254
- if (stop) {
5358
+ if (trigger) {
5255
5359
  response = await this.privateFuturesDeleteSettlePriceOrdersOrderId(this.extend(request, requestParams));
5256
5360
  }
5257
5361
  else {
@@ -5259,7 +5363,7 @@ class gate extends gate$1 {
5259
5363
  }
5260
5364
  }
5261
5365
  else if (type === 'future') {
5262
- if (stop) {
5366
+ if (trigger) {
5263
5367
  response = await this.privateDeliveryDeleteSettlePriceOrdersOrderId(this.extend(request, requestParams));
5264
5368
  }
5265
5369
  else {
@@ -5461,13 +5565,13 @@ class gate extends gate$1 {
5461
5565
  await this.loadMarkets();
5462
5566
  await this.loadUnifiedStatus();
5463
5567
  const market = (symbol === undefined) ? undefined : this.market(symbol);
5464
- const stop = this.safeBool2(params, 'stop', 'trigger');
5568
+ const trigger = this.safeBool2(params, 'stop', 'trigger');
5465
5569
  params = this.omit(params, ['stop', 'trigger']);
5466
5570
  const [type, query] = this.handleMarketTypeAndParams('cancelAllOrders', market, params);
5467
- const [request, requestParams] = (type === 'spot') ? this.multiOrderSpotPrepareRequest(market, stop, query) : this.prepareRequest(market, type, query);
5571
+ const [request, requestParams] = (type === 'spot') ? this.multiOrderSpotPrepareRequest(market, trigger, query) : this.prepareRequest(market, type, query);
5468
5572
  let response = undefined;
5469
5573
  if (type === 'spot' || type === 'margin') {
5470
- if (stop) {
5574
+ if (trigger) {
5471
5575
  response = await this.privateSpotDeletePriceOrders(this.extend(request, requestParams));
5472
5576
  }
5473
5577
  else {
@@ -5475,7 +5579,7 @@ class gate extends gate$1 {
5475
5579
  }
5476
5580
  }
5477
5581
  else if (type === 'swap') {
5478
- if (stop) {
5582
+ if (trigger) {
5479
5583
  response = await this.privateFuturesDeleteSettlePriceOrders(this.extend(request, requestParams));
5480
5584
  }
5481
5585
  else {
@@ -5483,7 +5587,7 @@ class gate extends gate$1 {
5483
5587
  }
5484
5588
  }
5485
5589
  else if (type === 'future') {
5486
- if (stop) {
5590
+ if (trigger) {
5487
5591
  response = await this.privateDeliveryDeleteSettlePriceOrders(this.extend(request, requestParams));
5488
5592
  }
5489
5593
  else {
@@ -48,6 +48,8 @@ class hyperliquid extends hyperliquid$1 {
48
48
  'createOrder': true,
49
49
  'createOrders': true,
50
50
  'createReduceOnlyOrder': true,
51
+ 'createStopOrder': true,
52
+ 'createTriggerOrder': true,
51
53
  'editOrder': true,
52
54
  'fetchAccounts': false,
53
55
  'fetchBalance': true,
@@ -200,9 +202,11 @@ class hyperliquid extends hyperliquid$1 {
200
202
  'User or API Wallet ': errors.InvalidOrder,
201
203
  'Order has invalid size': errors.InvalidOrder,
202
204
  'Order price cannot be more than 80% away from the reference price': errors.InvalidOrder,
205
+ 'Order has zero size.': errors.InvalidOrder,
206
+ 'Insufficient spot balance asset': errors.InsufficientFunds,
203
207
  },
204
208
  },
205
- 'precisionMode': number.DECIMAL_PLACES,
209
+ 'precisionMode': number.TICK_SIZE,
206
210
  'commonCurrencies': {},
207
211
  'options': {
208
212
  'defaultType': 'swap',
@@ -349,6 +353,55 @@ class hyperliquid extends hyperliquid$1 {
349
353
  }
350
354
  return this.parseMarkets(result);
351
355
  }
356
+ /**
357
+ * @method
358
+ * @name calculatePricePrecision
359
+ * @description Helper function to calculate the Hyperliquid DECIMAL_PLACES price precision
360
+ * @param {float} price the price to use in the calculation
361
+ * @param {int} amountPrecision the amountPrecision to use in the calculation
362
+ * @param {int} maxDecimals the maxDecimals to use in the calculation
363
+ * @returns {int} The calculated price precision
364
+ */
365
+ calculatePricePrecision(price, amountPrecision, maxDecimals) {
366
+ let pricePrecision = 0;
367
+ const priceStr = this.numberToString(price);
368
+ if (priceStr === undefined) {
369
+ return 0;
370
+ }
371
+ const priceSplitted = priceStr.split('.');
372
+ if (Precise["default"].stringEq(priceStr, '0')) {
373
+ // Significant digits is always 5 in this case
374
+ const significantDigits = 5;
375
+ // Integer digits is always 0 in this case (0 doesn't count)
376
+ const integerDigits = 0;
377
+ // Calculate the price precision
378
+ pricePrecision = Math.min(maxDecimals - amountPrecision, significantDigits - integerDigits);
379
+ }
380
+ else if (Precise["default"].stringGt(priceStr, '0') && Precise["default"].stringLt(priceStr, '1')) {
381
+ // Significant digits, always 5 in this case
382
+ const significantDigits = 5;
383
+ // Get the part after the decimal separator
384
+ const decimalPart = this.safeString(priceSplitted, 1, '');
385
+ // Count the number of leading zeros in the decimal part
386
+ let leadingZeros = 0;
387
+ while ((leadingZeros <= decimalPart.length) && (decimalPart[leadingZeros] === '0')) {
388
+ leadingZeros = leadingZeros + 1;
389
+ }
390
+ // Calculate price precision based on leading zeros and significant digits
391
+ pricePrecision = leadingZeros + significantDigits;
392
+ // Calculate the price precision based on maxDecimals - szDecimals and the calculated price precision from the previous step
393
+ pricePrecision = Math.min(maxDecimals - amountPrecision, pricePrecision);
394
+ }
395
+ else {
396
+ // Count the numbers before the decimal separator
397
+ const integerPart = this.safeString(priceSplitted, 0, '');
398
+ // Get significant digits, take the max() of 5 and the integer digits count
399
+ const significantDigits = Math.max(5, integerPart.length);
400
+ // Calculate price precision based on maxDecimals - szDecimals and significantDigits - integerPart.length
401
+ pricePrecision = Math.min(maxDecimals - amountPrecision, significantDigits - integerPart.length);
402
+ }
403
+ return this.parseToInt(pricePrecision);
404
+ }
352
405
  /**
353
406
  * @method
354
407
  * @name hyperliquid#fetchMarkets
@@ -438,7 +491,11 @@ class hyperliquid extends hyperliquid$1 {
438
491
  const symbol = base + '/' + quote;
439
492
  const innerBaseTokenInfo = this.safeDict(baseTokenInfo, 'spec', baseTokenInfo);
440
493
  // const innerQuoteTokenInfo = this.safeDict (quoteTokenInfo, 'spec', quoteTokenInfo);
441
- const amountPrecision = this.safeInteger(innerBaseTokenInfo, 'szDecimals');
494
+ const amountPrecisionStr = this.safeString(innerBaseTokenInfo, 'szDecimals');
495
+ const amountPrecision = parseInt(amountPrecisionStr);
496
+ const price = this.safeNumber(extraData, 'midPx');
497
+ const pricePrecision = this.calculatePricePrecision(price, amountPrecision, 8);
498
+ const pricePrecisionStr = this.numberToString(pricePrecision);
442
499
  // const quotePrecision = this.parseNumber (this.parsePrecision (this.safeString (innerQuoteTokenInfo, 'szDecimals')));
443
500
  const baseId = this.numberToString(i + 10000);
444
501
  markets.push(this.safeMarketStructure({
@@ -469,8 +526,8 @@ class hyperliquid extends hyperliquid$1 {
469
526
  'strike': undefined,
470
527
  'optionType': undefined,
471
528
  'precision': {
472
- 'amount': amountPrecision,
473
- 'price': 8 - amountPrecision, // MAX_DECIMALS is 8
529
+ 'amount': this.parseNumber(this.parsePrecision(amountPrecisionStr)),
530
+ 'price': this.parseNumber(this.parsePrecision(pricePrecisionStr)),
474
531
  },
475
532
  'limits': {
476
533
  'leverage': {
@@ -534,7 +591,11 @@ class hyperliquid extends hyperliquid$1 {
534
591
  const fees = this.safeDict(this.fees, 'swap', {});
535
592
  const taker = this.safeNumber(fees, 'taker');
536
593
  const maker = this.safeNumber(fees, 'maker');
537
- const amountPrecision = this.safeInteger(market, 'szDecimals');
594
+ const amountPrecisionStr = this.safeString(market, 'szDecimals');
595
+ const amountPrecision = parseInt(amountPrecisionStr);
596
+ const price = this.safeNumber(market, 'markPx', 0);
597
+ const pricePrecision = this.calculatePricePrecision(price, amountPrecision, 6);
598
+ const pricePrecisionStr = this.numberToString(pricePrecision);
538
599
  return this.safeMarketStructure({
539
600
  'id': baseId,
540
601
  'symbol': symbol,
@@ -562,8 +623,8 @@ class hyperliquid extends hyperliquid$1 {
562
623
  'strike': undefined,
563
624
  'optionType': undefined,
564
625
  'precision': {
565
- 'amount': amountPrecision,
566
- 'price': 6 - amountPrecision, // MAX_DECIMALS is 6
626
+ 'amount': this.parseNumber(this.parsePrecision(amountPrecisionStr)),
627
+ 'price': this.parseNumber(this.parsePrecision(pricePrecisionStr)),
567
628
  },
568
629
  'limits': {
569
630
  'leverage': {
@@ -1040,10 +1101,13 @@ class hyperliquid extends hyperliquid$1 {
1040
1101
  }
1041
1102
  priceToPrecision(symbol, price) {
1042
1103
  const market = this.market(symbol);
1043
- // https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/tick-and-lot-size
1044
- const result = this.decimalToPrecision(price, number.ROUND, 5, number.SIGNIFICANT_DIGITS, this.paddingMode);
1045
- const decimalParsedResult = this.decimalToPrecision(result, number.ROUND, market['precision']['price'], this.precisionMode, this.paddingMode);
1046
- return decimalParsedResult;
1104
+ const priceStr = this.numberToString(price);
1105
+ const integerPart = priceStr.split('.')[0];
1106
+ const significantDigits = Math.max(5, integerPart.length);
1107
+ const result = this.decimalToPrecision(price, number.ROUND, significantDigits, number.SIGNIFICANT_DIGITS, this.paddingMode);
1108
+ const maxDecimals = market['spot'] ? 8 : 6;
1109
+ const subtractedValue = maxDecimals - this.precisionFromString(this.safeString(market['precision'], 'amount'));
1110
+ return this.decimalToPrecision(result, number.ROUND, subtractedValue, number.DECIMAL_PLACES, this.paddingMode);
1047
1111
  }
1048
1112
  hashMessage(message) {
1049
1113
  return '0x' + this.hash(message, sha3.keccak_256, 'hex');
@@ -195,10 +195,8 @@ class idex extends idex$1 {
195
195
  // {"code":"INVALID_PARAMETER","message":"invalid value provided for request parameter \"price\": all quantities and prices must be below 100 billion, above 0, need to be provided as strings, and always require 4 decimals ending with 4 zeroes"}
196
196
  //
197
197
  const market = this.market(symbol);
198
- const info = this.safeValue(market, 'info', {});
199
- const quoteAssetPrecision = this.safeInteger(info, 'quoteAssetPrecision');
200
198
  price = this.decimalToPrecision(price, number.ROUND, market['precision']['price'], this.precisionMode);
201
- return this.decimalToPrecision(price, number.TRUNCATE, quoteAssetPrecision, number.DECIMAL_PLACES, number.PAD_WITH_ZERO);
199
+ return this.decimalToPrecision(price, number.TRUNCATE, market['precision']['quote'], number.TICK_SIZE, number.PAD_WITH_ZERO);
202
200
  }
203
201
  /**
204
202
  * @method
@@ -306,6 +304,8 @@ class idex extends idex$1 {
306
304
  'precision': {
307
305
  'amount': basePrecision,
308
306
  'price': this.safeNumber(entry, 'tickSize'),
307
+ 'base': basePrecision,
308
+ 'quote': quotePrecision,
309
309
  },
310
310
  'limits': {
311
311
  'leverage': {