ccxt 4.4.34__py2.py3-none-any.whl → 4.4.36__py2.py3-none-any.whl

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 (67) hide show
  1. ccxt/__init__.py +3 -1
  2. ccxt/abstract/bingx.py +1 -0
  3. ccxt/abstract/bitopro.py +1 -0
  4. ccxt/abstract/bitpanda.py +0 -12
  5. ccxt/abstract/bitrue.py +3 -3
  6. ccxt/abstract/bybit.py +15 -0
  7. ccxt/abstract/defx.py +69 -0
  8. ccxt/abstract/deribit.py +1 -0
  9. ccxt/abstract/gate.py +14 -0
  10. ccxt/abstract/gateio.py +14 -0
  11. ccxt/abstract/okx.py +1 -0
  12. ccxt/abstract/onetrading.py +0 -12
  13. ccxt/abstract/xt.py +5 -5
  14. ccxt/async_support/__init__.py +3 -1
  15. ccxt/async_support/base/exchange.py +1 -1
  16. ccxt/async_support/bingx.py +324 -138
  17. ccxt/async_support/bitfinex2.py +18 -13
  18. ccxt/async_support/bitmex.py +104 -2
  19. ccxt/async_support/bitopro.py +21 -4
  20. ccxt/async_support/bitrue.py +2 -2
  21. ccxt/async_support/bitso.py +2 -1
  22. ccxt/async_support/btcmarkets.py +3 -3
  23. ccxt/async_support/btcturk.py +19 -19
  24. ccxt/async_support/bybit.py +21 -1
  25. ccxt/async_support/defx.py +1981 -0
  26. ccxt/async_support/deribit.py +27 -12
  27. ccxt/async_support/gate.py +156 -39
  28. ccxt/async_support/htx.py +11 -2
  29. ccxt/async_support/hyperliquid.py +68 -11
  30. ccxt/async_support/idex.py +3 -4
  31. ccxt/async_support/kraken.py +97 -90
  32. ccxt/async_support/kucoin.py +1 -1
  33. ccxt/async_support/okx.py +1 -0
  34. ccxt/async_support/onetrading.py +47 -369
  35. ccxt/async_support/xt.py +10 -10
  36. ccxt/base/exchange.py +2 -1
  37. ccxt/bingx.py +324 -138
  38. ccxt/bitfinex2.py +18 -13
  39. ccxt/bitmex.py +104 -2
  40. ccxt/bitopro.py +21 -4
  41. ccxt/bitrue.py +2 -2
  42. ccxt/bitso.py +2 -1
  43. ccxt/btcmarkets.py +3 -3
  44. ccxt/btcturk.py +19 -19
  45. ccxt/bybit.py +21 -1
  46. ccxt/defx.py +1980 -0
  47. ccxt/deribit.py +27 -12
  48. ccxt/gate.py +156 -39
  49. ccxt/htx.py +11 -2
  50. ccxt/hyperliquid.py +68 -11
  51. ccxt/idex.py +3 -4
  52. ccxt/kraken.py +97 -90
  53. ccxt/kucoin.py +1 -1
  54. ccxt/okx.py +1 -0
  55. ccxt/onetrading.py +47 -369
  56. ccxt/pro/__init__.py +3 -1
  57. ccxt/pro/bitrue.py +13 -11
  58. ccxt/pro/defx.py +832 -0
  59. ccxt/pro/probit.py +54 -66
  60. ccxt/test/tests_async.py +44 -3
  61. ccxt/test/tests_sync.py +44 -3
  62. ccxt/xt.py +10 -10
  63. {ccxt-4.4.34.dist-info → ccxt-4.4.36.dist-info}/METADATA +7 -6
  64. {ccxt-4.4.34.dist-info → ccxt-4.4.36.dist-info}/RECORD +67 -63
  65. {ccxt-4.4.34.dist-info → ccxt-4.4.36.dist-info}/LICENSE.txt +0 -0
  66. {ccxt-4.4.34.dist-info → ccxt-4.4.36.dist-info}/WHEEL +0 -0
  67. {ccxt-4.4.34.dist-info → ccxt-4.4.36.dist-info}/top_level.txt +0 -0
ccxt/deribit.py CHANGED
@@ -220,6 +220,7 @@ class deribit(Exchange, ImplicitAPI):
220
220
  'enable_api_key': 1,
221
221
  'get_access_log': 1,
222
222
  'get_account_summary': 1,
223
+ 'get_account_summaries': 1,
223
224
  'get_affiliate_program_info': 1,
224
225
  'get_email_language': 1,
225
226
  'get_new_announcements': 1,
@@ -931,13 +932,20 @@ class deribit(Exchange, ImplicitAPI):
931
932
  result: dict = {
932
933
  'info': balance,
933
934
  }
934
- currencyId = self.safe_string(balance, 'currency')
935
- currencyCode = self.safe_currency_code(currencyId)
936
- account = self.account()
937
- account['free'] = self.safe_string(balance, 'available_funds')
938
- account['used'] = self.safe_string(balance, 'maintenance_margin')
939
- account['total'] = self.safe_string(balance, 'equity')
940
- result[currencyCode] = account
935
+ summaries = []
936
+ if 'summaries' in balance:
937
+ summaries = self.safe_list(balance, 'summaries')
938
+ else:
939
+ summaries = [balance]
940
+ for i in range(0, len(summaries)):
941
+ data = summaries[i]
942
+ currencyId = self.safe_string(data, 'currency')
943
+ currencyCode = self.safe_currency_code(currencyId)
944
+ account = self.account()
945
+ account['free'] = self.safe_string(data, 'available_funds')
946
+ account['used'] = self.safe_string(data, 'maintenance_margin')
947
+ account['total'] = self.safe_string(data, 'equity')
948
+ result[currencyCode] = account
941
949
  return self.safe_balance(result)
942
950
 
943
951
  def fetch_balance(self, params={}) -> Balances:
@@ -945,17 +953,24 @@ class deribit(Exchange, ImplicitAPI):
945
953
  query for balance and get the amount of funds available for trading or funds locked in orders
946
954
 
947
955
  https://docs.deribit.com/#private-get_account_summary
956
+ https://docs.deribit.com/#private-get_account_summaries
948
957
 
949
958
  :param dict [params]: extra parameters specific to the exchange API endpoint
959
+ :param str [params.code]: unified currency code of the currency for the balance, if defined 'privateGetGetAccountSummary' will be used, otherwise 'privateGetGetAccountSummaries' will be used
950
960
  :returns dict: a `balance structure <https://docs.ccxt.com/#/?id=balance-structure>`
951
961
  """
952
962
  self.load_markets()
953
- code = self.code_from_options('fetchBalance', params)
954
- currency = self.currency(code)
963
+ code = self.safe_string(params, 'code')
964
+ params = self.omit(params, 'code')
955
965
  request: dict = {
956
- 'currency': currency['id'],
957
966
  }
958
- response = self.privateGetGetAccountSummary(self.extend(request, params))
967
+ if code is not None:
968
+ request['currency'] = self.currency_id(code)
969
+ response = None
970
+ if code is None:
971
+ response = self.privateGetGetAccountSummaries(params)
972
+ else:
973
+ response = self.privateGetGetAccountSummary(self.extend(request, params))
959
974
  #
960
975
  # {
961
976
  # "jsonrpc": "2.0",
@@ -998,7 +1013,7 @@ class deribit(Exchange, ImplicitAPI):
998
1013
  # "testnet": False
999
1014
  # }
1000
1015
  #
1001
- result = self.safe_value(response, 'result', {})
1016
+ result = self.safe_dict(response, 'result', {})
1002
1017
  return self.parse_balance(result)
1003
1018
 
1004
1019
  def create_deposit_address(self, code: str, params={}):
ccxt/gate.py CHANGED
@@ -239,6 +239,7 @@ class gate(Exchange, ImplicitAPI):
239
239
  '{settle}/contract_stats': 1,
240
240
  '{settle}/index_constituents/{index}': 1,
241
241
  '{settle}/liq_orders': 1,
242
+ '{settle}/risk_limit_tiers': 1,
242
243
  },
243
244
  },
244
245
  'delivery': {
@@ -280,6 +281,7 @@ class gate(Exchange, ImplicitAPI):
280
281
  'withdrawals': {
281
282
  'post': {
282
283
  'withdrawals': 20, # 1r/s cost = 20 / 1 = 20
284
+ 'push': 1,
283
285
  },
284
286
  'delete': {
285
287
  'withdrawals/{withdrawal_id}': 1,
@@ -291,6 +293,7 @@ class gate(Exchange, ImplicitAPI):
291
293
  'withdrawals': 1,
292
294
  'deposits': 1,
293
295
  'sub_account_transfers': 1,
296
+ 'order_status': 1,
294
297
  'withdraw_status': 1,
295
298
  'sub_account_balances': 2.5,
296
299
  'sub_account_margin_balances': 2.5,
@@ -301,6 +304,7 @@ class gate(Exchange, ImplicitAPI):
301
304
  'total_balance': 2.5,
302
305
  'small_balance': 1,
303
306
  'small_balance_history': 1,
307
+ 'push': 1,
304
308
  },
305
309
  'post': {
306
310
  'transfers': 2.5, # 8r/s cost = 20 / 8 = 2.5
@@ -343,11 +347,14 @@ class gate(Exchange, ImplicitAPI):
343
347
  'risk_units': 20 / 15,
344
348
  'unified_mode': 20 / 15,
345
349
  'loan_margin_tiers': 20 / 15,
350
+ 'leverage/user_currency_config': 20 / 15,
351
+ 'leverage/user_currency_setting': 20 / 15,
346
352
  },
347
353
  'post': {
348
354
  'account_mode': 20 / 15,
349
355
  'loans': 200 / 15, # 15r/10s cost = 20 / 1.5 = 13.33
350
356
  'portfolio_calculator': 20 / 15,
357
+ 'leverage/user_currency_setting': 20 / 15,
351
358
  },
352
359
  'put': {
353
360
  'unified_mode': 20 / 15,
@@ -527,9 +534,13 @@ class gate(Exchange, ImplicitAPI):
527
534
  'orders': 20 / 15,
528
535
  'orders/{order_id}': 20 / 15,
529
536
  'my_trades': 20 / 15,
537
+ 'mmp': 20 / 15,
530
538
  },
531
539
  'post': {
532
540
  'orders': 20 / 15,
541
+ 'countdown_cancel_all': 20 / 15,
542
+ 'mmp': 20 / 15,
543
+ 'mmp/reset': 20 / 15,
533
544
  },
534
545
  'delete': {
535
546
  'orders': 20 / 15,
@@ -573,6 +584,7 @@ class gate(Exchange, ImplicitAPI):
573
584
  'multi_collateral/currencies': 20 / 15,
574
585
  'multi_collateral/ltv': 20 / 15,
575
586
  'multi_collateral/fixed_rate': 20 / 15,
587
+ 'multi_collateral/current_rate': 20 / 15,
576
588
  },
577
589
  'post': {
578
590
  'collateral/orders': 20 / 15,
@@ -586,8 +598,10 @@ class gate(Exchange, ImplicitAPI):
586
598
  'account': {
587
599
  'get': {
588
600
  'detail': 20 / 15,
601
+ 'rate_limit': 20 / 15,
589
602
  'stp_groups': 20 / 15,
590
603
  'stp_groups/{stp_id}/users': 20 / 15,
604
+ 'stp_groups/debit_fee': 20 / 15,
591
605
  },
592
606
  'post': {
593
607
  'stp_groups': 20 / 15,
@@ -708,6 +722,110 @@ class gate(Exchange, ImplicitAPI):
708
722
  },
709
723
  },
710
724
  },
725
+ 'features': {
726
+ 'spot': {
727
+ 'sandbox': True,
728
+ 'createOrder': {
729
+ 'marginMode': True,
730
+ 'triggerPrice': True,
731
+ 'triggerDirection': True, # todo: implementation edit needed
732
+ 'triggerPriceType': None,
733
+ 'stopLossPrice': True,
734
+ 'takeProfitPrice': True,
735
+ 'attachedStopLossTakeProfit': None,
736
+ 'timeInForce': {
737
+ 'GTC': True,
738
+ 'IOC': True,
739
+ 'FOK': True,
740
+ 'PO': True,
741
+ 'GTD': False,
742
+ },
743
+ 'hedged': False,
744
+ 'trailing': False,
745
+ # exchange-specific features
746
+ 'iceberg': True,
747
+ 'selfTradePrevention': True,
748
+ },
749
+ 'createOrders': {
750
+ 'max': 40, # NOTE! max 10 per symbol
751
+ },
752
+ 'fetchMyTrades': {
753
+ 'marginMode': True,
754
+ 'limit': 1000,
755
+ 'daysBack': None,
756
+ 'untilDays': 30,
757
+ },
758
+ 'fetchOrder': {
759
+ 'marginMode': False,
760
+ 'trigger': True,
761
+ 'trailing': False,
762
+ },
763
+ 'fetchOpenOrders': {
764
+ 'marginMode': True,
765
+ 'trigger': True,
766
+ 'trailing': False,
767
+ 'limit': 100,
768
+ },
769
+ 'fetchOrders': None,
770
+ 'fetchClosedOrders': {
771
+ 'marginMode': True,
772
+ 'trigger': True,
773
+ 'trailing': False,
774
+ 'limit': 100,
775
+ 'untilDays': 30,
776
+ 'daysBackClosed': None,
777
+ 'daysBackCanceled': None,
778
+ },
779
+ 'fetchOHLCV': {
780
+ 'limit': 1000,
781
+ },
782
+ },
783
+ 'forDerivatives': {
784
+ 'extends': 'spot',
785
+ 'createOrder': {
786
+ 'marginMode': False,
787
+ 'triggerPriceType': {
788
+ 'last': True,
789
+ 'mark': True,
790
+ 'index': True,
791
+ },
792
+ },
793
+ 'createOrders': {
794
+ 'max': 10,
795
+ },
796
+ 'fetchMyTrades': {
797
+ 'marginMode': False,
798
+ 'untilDays': None,
799
+ },
800
+ 'fetchOpenOrders': {
801
+ 'marginMode': False,
802
+ },
803
+ 'fetchClosedOrders': {
804
+ 'marginMode': False,
805
+ 'untilDays': None,
806
+ 'limit': 1000,
807
+ },
808
+ 'fetchOHLCV': {
809
+ 'limit': 1999,
810
+ },
811
+ },
812
+ 'swap': {
813
+ 'linear': {
814
+ 'extends': 'forDerivatives',
815
+ },
816
+ 'inverse': {
817
+ 'extends': 'forDerivatives',
818
+ },
819
+ },
820
+ 'future': {
821
+ 'linear': {
822
+ 'extends': 'forDerivatives',
823
+ },
824
+ 'inverse': {
825
+ 'extends': 'forDerivatives',
826
+ },
827
+ },
828
+ },
711
829
  'precisionMode': TICK_SIZE,
712
830
  'fees': {
713
831
  'trading': {
@@ -1532,22 +1650,22 @@ class gate(Exchange, ImplicitAPI):
1532
1650
  request['settle'] = settle
1533
1651
  return [request, params]
1534
1652
 
1535
- def spot_order_prepare_request(self, market=None, stop=False, params={}):
1653
+ def spot_order_prepare_request(self, market=None, trigger=False, params={}):
1536
1654
  """
1537
1655
  @ignore
1538
1656
  Fills request params currency_pair, market and account where applicable for spot order methods like fetchOpenOrders, cancelAllOrders
1539
1657
  :param dict market: CCXT market
1540
- :param bool stop: True if for a stop order
1658
+ :param bool trigger: True if for a trigger order
1541
1659
  :param dict [params]: request parameters
1542
1660
  :returns: the api request object, and the new params object with non-needed parameters removed
1543
1661
  """
1544
- marginMode, query = self.get_margin_mode(stop, params)
1662
+ marginMode, query = self.get_margin_mode(trigger, params)
1545
1663
  request: dict = {}
1546
- if not stop:
1664
+ if not trigger:
1547
1665
  if market is None:
1548
- raise ArgumentsRequired(self.id + ' spotOrderPrepareRequest() requires a market argument for non-stop orders')
1666
+ raise ArgumentsRequired(self.id + ' spotOrderPrepareRequest() requires a market argument for non-trigger orders')
1549
1667
  request['account'] = marginMode
1550
- request['currency_pair'] = market['id'] # Should always be set for non-stop
1668
+ request['currency_pair'] = market['id'] # Should always be set for non-trigger
1551
1669
  return [request, query]
1552
1670
 
1553
1671
  def multi_order_spot_prepare_request(self, market=None, trigger=False, params={}):
@@ -1555,7 +1673,7 @@ class gate(Exchange, ImplicitAPI):
1555
1673
  @ignore
1556
1674
  Fills request params currency_pair, market and account where applicable for spot order methods like fetchOpenOrders, cancelAllOrders
1557
1675
  :param dict market: CCXT market
1558
- :param bool stop: True if for a stop order
1676
+ :param bool trigger: True if for a trigger order
1559
1677
  :param dict [params]: request parameters
1560
1678
  :returns: the api request object, and the new params object with non-needed parameters removed
1561
1679
  """
@@ -1565,17 +1683,17 @@ class gate(Exchange, ImplicitAPI):
1565
1683
  }
1566
1684
  if market is not None:
1567
1685
  if trigger:
1568
- # 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 self 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 self method
1569
1687
  request['market'] = market['id']
1570
1688
  else:
1571
1689
  request['currency_pair'] = market['id']
1572
1690
  return [request, query]
1573
1691
 
1574
- def get_margin_mode(self, stop, params):
1692
+ def get_margin_mode(self, trigger, params):
1575
1693
  """
1576
1694
  @ignore
1577
1695
  Gets the margin type for self api call
1578
- :param bool stop: True if for a stop order
1696
+ :param bool trigger: True if for a trigger order
1579
1697
  :param dict [params]: Request params
1580
1698
  :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
1581
1699
  """
@@ -1588,12 +1706,12 @@ class gate(Exchange, ImplicitAPI):
1588
1706
  marginMode = 'margin'
1589
1707
  elif marginMode == '':
1590
1708
  marginMode = 'spot'
1591
- if stop:
1709
+ if trigger:
1592
1710
  if marginMode == 'spot':
1593
- # gate spot stop orders use the term normal instead of spot
1711
+ # gate spot trigger orders use the term normal instead of spot
1594
1712
  marginMode = 'normal'
1595
1713
  if marginMode == 'cross_margin':
1596
- raise BadRequest(self.id + ' getMarginMode() does not support stop orders for cross margin')
1714
+ raise BadRequest(self.id + ' getMarginMode() does not support trigger orders for cross margin')
1597
1715
  isUnifiedAccount = False
1598
1716
  isUnifiedAccount, params = self.handle_option_and_params(params, 'getMarginMode', 'unifiedAccount')
1599
1717
  if isUnifiedAccount:
@@ -2989,7 +3107,6 @@ class gate(Exchange, ImplicitAPI):
2989
3107
  request['limit'] = limit
2990
3108
  response = None
2991
3109
  if market['contract']:
2992
- maxLimit = 1999
2993
3110
  isMark = (price == 'mark')
2994
3111
  isIndex = (price == 'index')
2995
3112
  if isMark or isIndex:
@@ -3306,7 +3423,7 @@ class gate(Exchange, ImplicitAPI):
3306
3423
  params = self.omit(params, 'order_id')
3307
3424
  else:
3308
3425
  if market is not None:
3309
- request['currency_pair'] = market['id'] # Should always be set for non-stop
3426
+ request['currency_pair'] = market['id'] # Should always be set for non-trigger
3310
3427
  marginMode, params = self.get_margin_mode(False, params)
3311
3428
  request['account'] = marginMode
3312
3429
  if limit is not None:
@@ -3825,8 +3942,8 @@ class gate(Exchange, ImplicitAPI):
3825
3942
  takeProfitPrice = self.safe_value(params, 'takeProfitPrice')
3826
3943
  isStopLossOrder = stopLossPrice is not None
3827
3944
  isTakeProfitOrder = takeProfitPrice is not None
3828
- isStopOrder = isStopLossOrder or isTakeProfitOrder
3829
- nonTriggerOrder = not isStopOrder and (trigger is None)
3945
+ isTpsl = isStopLossOrder or isTakeProfitOrder
3946
+ nonTriggerOrder = not isTpsl and (trigger is None)
3830
3947
  orderRequest = self.create_order_request(symbol, type, side, amount, price, params)
3831
3948
  response = None
3832
3949
  if market['spot'] or market['margin']:
@@ -3975,7 +4092,7 @@ class gate(Exchange, ImplicitAPI):
3975
4092
  takeProfitPrice = self.safe_value(params, 'takeProfitPrice')
3976
4093
  isStopLossOrder = stopLossPrice is not None
3977
4094
  isTakeProfitOrder = takeProfitPrice is not None
3978
- isStopOrder = isStopLossOrder or isTakeProfitOrder
4095
+ isTpsl = isStopLossOrder or isTakeProfitOrder
3979
4096
  if isStopLossOrder and isTakeProfitOrder:
3980
4097
  raise ExchangeError(self.id + ' createOrder() stopLossPrice and takeProfitPrice cannot both be defined')
3981
4098
  reduceOnly = self.safe_value(params, 'reduceOnly')
@@ -4011,7 +4128,7 @@ class gate(Exchange, ImplicitAPI):
4011
4128
  signedAmount = Precise.string_neg(amountToPrecision) if (side == 'sell') else amountToPrecision
4012
4129
  amount = int(signedAmount)
4013
4130
  request = None
4014
- nonTriggerOrder = not isStopOrder and (trigger is None)
4131
+ nonTriggerOrder = not isTpsl and (trigger is None)
4015
4132
  if nonTriggerOrder:
4016
4133
  if contract:
4017
4134
  # contract order
@@ -4561,7 +4678,7 @@ class gate(Exchange, ImplicitAPI):
4561
4678
 
4562
4679
  def fetch_order_request(self, id: str, symbol: Str = None, params={}):
4563
4680
  market = None if (symbol is None) else self.market(symbol)
4564
- stop = self.safe_bool_n(params, ['trigger', 'is_stop_order', 'stop'], False)
4681
+ trigger = self.safe_bool_n(params, ['trigger', 'is_stop_order', 'stop'], False)
4565
4682
  params = self.omit(params, ['is_stop_order', 'stop', 'trigger'])
4566
4683
  clientOrderId = self.safe_string_2(params, 'text', 'clientOrderId')
4567
4684
  orderId = id
@@ -4572,7 +4689,7 @@ class gate(Exchange, ImplicitAPI):
4572
4689
  orderId = clientOrderId
4573
4690
  type, query = self.handle_market_type_and_params('fetchOrder', market, params)
4574
4691
  contract = (type == 'swap') or (type == 'future') or (type == 'option')
4575
- request, requestParams = self.prepare_request(market, type, query) if contract else self.spot_order_prepare_request(market, stop, query)
4692
+ request, requestParams = self.prepare_request(market, type, query) if contract else self.spot_order_prepare_request(market, trigger, query)
4576
4693
  request['order_id'] = str(orderId)
4577
4694
  return [request, requestParams]
4578
4695
 
@@ -4600,21 +4717,21 @@ class gate(Exchange, ImplicitAPI):
4600
4717
  market = None if (symbol is None) else self.market(symbol)
4601
4718
  result = self.handle_market_type_and_params('fetchOrder', market, params)
4602
4719
  type = self.safe_string(result, 0)
4603
- stop = self.safe_bool_n(params, ['trigger', 'is_stop_order', 'stop'], False)
4720
+ trigger = self.safe_bool_n(params, ['trigger', 'is_stop_order', 'stop'], False)
4604
4721
  request, requestParams = self.fetch_order_request(id, symbol, params)
4605
4722
  response = None
4606
4723
  if type == 'spot' or type == 'margin':
4607
- if stop:
4724
+ if trigger:
4608
4725
  response = self.privateSpotGetPriceOrdersOrderId(self.extend(request, requestParams))
4609
4726
  else:
4610
4727
  response = self.privateSpotGetOrdersOrderId(self.extend(request, requestParams))
4611
4728
  elif type == 'swap':
4612
- if stop:
4729
+ if trigger:
4613
4730
  response = self.privateFuturesGetSettlePriceOrdersOrderId(self.extend(request, requestParams))
4614
4731
  else:
4615
4732
  response = self.privateFuturesGetSettleOrdersOrderId(self.extend(request, requestParams))
4616
4733
  elif type == 'future':
4617
- if stop:
4734
+ if trigger:
4618
4735
  response = self.privateDeliveryGetSettlePriceOrdersOrderId(self.extend(request, requestParams))
4619
4736
  else:
4620
4737
  response = self.privateDeliveryGetSettleOrdersOrderId(self.extend(request, requestParams))
@@ -4635,7 +4752,7 @@ class gate(Exchange, ImplicitAPI):
4635
4752
  :param int [since]: the earliest time in ms to fetch open orders for
4636
4753
  :param int [limit]: the maximum number of open orders structures to retrieve
4637
4754
  :param dict [params]: extra parameters specific to the exchange API endpoint
4638
- :param bool [params.stop]: True for fetching stop orders
4755
+ :param bool [params.trigger]: True for fetching trigger orders
4639
4756
  :param str [params.type]: spot, margin, swap or future, if not provided self.options['defaultType'] is used
4640
4757
  :param str [params.marginMode]: 'cross' or 'isolated' - marginMode for type='margin', if not provided self.options['defaultMarginMode'] is used
4641
4758
  :param bool [params.unifiedAccount]: set to True for fetching unified account orders
@@ -4660,7 +4777,7 @@ class gate(Exchange, ImplicitAPI):
4660
4777
  :param int [since]: the earliest time in ms to fetch orders for
4661
4778
  :param int [limit]: the maximum number of order structures to retrieve
4662
4779
  :param dict [params]: extra parameters specific to the exchange API endpoint
4663
- :param bool [params.stop]: True for fetching stop orders
4780
+ :param bool [params.trigger]: True for fetching trigger orders
4664
4781
  :param str [params.type]: spot, swap or future, if not provided self.options['defaultType'] is used
4665
4782
  :param str [params.marginMode]: 'cross' or 'isolated' - marginMode for margin trading if not provided self.options['defaultMarginMode'] is used
4666
4783
  :param boolean [params.historical]: *swap only* True for using historical endpoint
@@ -4834,7 +4951,7 @@ class gate(Exchange, ImplicitAPI):
4834
4951
  # }
4835
4952
  # ]
4836
4953
  #
4837
- # spot stop
4954
+ # spot trigger
4838
4955
  #
4839
4956
  # [
4840
4957
  # {
@@ -4929,31 +5046,31 @@ class gate(Exchange, ImplicitAPI):
4929
5046
  :param str id: Order id
4930
5047
  :param str symbol: Unified market symbol
4931
5048
  :param dict [params]: Parameters specified by the exchange api
4932
- :param bool [params.stop]: True if the order to be cancelled is a trigger order
5049
+ :param bool [params.trigger]: True if the order to be cancelled is a trigger order
4933
5050
  :param bool [params.unifiedAccount]: set to True for canceling unified account orders
4934
5051
  :returns: An `order structure <https://docs.ccxt.com/#/?id=order-structure>`
4935
5052
  """
4936
5053
  self.load_markets()
4937
5054
  self.load_unified_status()
4938
5055
  market = None if (symbol is None) else self.market(symbol)
4939
- stop = self.safe_bool_n(params, ['is_stop_order', 'stop', 'trigger'], False)
5056
+ trigger = self.safe_bool_n(params, ['is_stop_order', 'stop', 'trigger'], False)
4940
5057
  params = self.omit(params, ['is_stop_order', 'stop', 'trigger'])
4941
5058
  type, query = self.handle_market_type_and_params('cancelOrder', market, params)
4942
- request, requestParams = self.spot_order_prepare_request(market, stop, query) if (type == 'spot' or type == 'margin') else self.prepare_request(market, type, query)
5059
+ request, requestParams = self.spot_order_prepare_request(market, trigger, query) if (type == 'spot' or type == 'margin') else self.prepare_request(market, type, query)
4943
5060
  request['order_id'] = id
4944
5061
  response = None
4945
5062
  if type == 'spot' or type == 'margin':
4946
- if stop:
5063
+ if trigger:
4947
5064
  response = self.privateSpotDeletePriceOrdersOrderId(self.extend(request, requestParams))
4948
5065
  else:
4949
5066
  response = self.privateSpotDeleteOrdersOrderId(self.extend(request, requestParams))
4950
5067
  elif type == 'swap':
4951
- if stop:
5068
+ if trigger:
4952
5069
  response = self.privateFuturesDeleteSettlePriceOrdersOrderId(self.extend(request, requestParams))
4953
5070
  else:
4954
5071
  response = self.privateFuturesDeleteSettleOrdersOrderId(self.extend(request, requestParams))
4955
5072
  elif type == 'future':
4956
- if stop:
5073
+ if trigger:
4957
5074
  response = self.privateDeliveryDeleteSettlePriceOrdersOrderId(self.extend(request, requestParams))
4958
5075
  else:
4959
5076
  response = self.privateDeliveryDeleteSettleOrdersOrderId(self.extend(request, requestParams))
@@ -5143,23 +5260,23 @@ class gate(Exchange, ImplicitAPI):
5143
5260
  self.load_markets()
5144
5261
  self.load_unified_status()
5145
5262
  market = None if (symbol is None) else self.market(symbol)
5146
- stop = self.safe_bool_2(params, 'stop', 'trigger')
5263
+ trigger = self.safe_bool_2(params, 'stop', 'trigger')
5147
5264
  params = self.omit(params, ['stop', 'trigger'])
5148
5265
  type, query = self.handle_market_type_and_params('cancelAllOrders', market, params)
5149
- request, requestParams = self.multi_order_spot_prepare_request(market, stop, query) if (type == 'spot') else self.prepare_request(market, type, query)
5266
+ request, requestParams = self.multi_order_spot_prepare_request(market, trigger, query) if (type == 'spot') else self.prepare_request(market, type, query)
5150
5267
  response = None
5151
5268
  if type == 'spot' or type == 'margin':
5152
- if stop:
5269
+ if trigger:
5153
5270
  response = self.privateSpotDeletePriceOrders(self.extend(request, requestParams))
5154
5271
  else:
5155
5272
  response = self.privateSpotDeleteOrders(self.extend(request, requestParams))
5156
5273
  elif type == 'swap':
5157
- if stop:
5274
+ if trigger:
5158
5275
  response = self.privateFuturesDeleteSettlePriceOrders(self.extend(request, requestParams))
5159
5276
  else:
5160
5277
  response = self.privateFuturesDeleteSettleOrders(self.extend(request, requestParams))
5161
5278
  elif type == 'future':
5162
- if stop:
5279
+ if trigger:
5163
5280
  response = self.privateDeliveryDeleteSettlePriceOrders(self.extend(request, requestParams))
5164
5281
  else:
5165
5282
  response = self.privateDeliveryDeleteSettleOrders(self.extend(request, requestParams))
ccxt/htx.py CHANGED
@@ -5091,17 +5091,23 @@ class htx(Exchange, ImplicitAPI):
5091
5091
  params = self.omit(params, ['clientOrderId'])
5092
5092
  if type == 'limit' or type == 'ioc' or type == 'fok' or type == 'post_only':
5093
5093
  request['price'] = self.price_to_precision(symbol, price)
5094
+ reduceOnly = self.safe_bool_2(params, 'reduceOnly', 'reduce_only', False)
5094
5095
  if not isStopLossTriggerOrder and not isTakeProfitTriggerOrder:
5095
- reduceOnly = self.safe_value_2(params, 'reduceOnly', 'reduce_only', False)
5096
5096
  if reduceOnly:
5097
5097
  request['reduce_only'] = 1
5098
5098
  request['lever_rate'] = self.safe_integer_n(params, ['leverRate', 'lever_rate', 'leverage'], 1)
5099
5099
  if not isTrailingPercentOrder:
5100
5100
  request['order_price_type'] = type
5101
+ hedged = self.safe_bool(params, 'hedged', False)
5102
+ if hedged:
5103
+ if reduceOnly:
5104
+ request['offset'] = 'close'
5105
+ else:
5106
+ request['offset'] = 'open'
5101
5107
  broker = self.safe_value(self.options, 'broker', {})
5102
5108
  brokerId = self.safe_string(broker, 'id')
5103
5109
  request['channel_code'] = brokerId
5104
- params = self.omit(params, ['reduceOnly', 'triggerPrice', 'stopPrice', 'stopLossPrice', 'takeProfitPrice', 'triggerType', 'leverRate', 'timeInForce', 'leverage', 'trailingPercent', 'trailingTriggerPrice'])
5110
+ params = self.omit(params, ['reduceOnly', 'triggerPrice', 'stopPrice', 'stopLossPrice', 'takeProfitPrice', 'triggerType', 'leverRate', 'timeInForce', 'leverage', 'trailingPercent', 'trailingTriggerPrice', 'hedged'])
5105
5111
  return self.extend(request, params)
5106
5112
 
5107
5113
  def create_order(self, symbol: str, type: OrderType, side: OrderSide, amount: float, price: Num = None, params={}):
@@ -5115,6 +5121,8 @@ class htx(Exchange, ImplicitAPI):
5115
5121
  https://huobiapi.github.io/docs/usdt_swap/v1/en/#cross-place-trigger-order # usdt-m swap cross trigger
5116
5122
  https://huobiapi.github.io/docs/usdt_swap/v1/en/#isolated-place-an-order # usdt-m swap isolated
5117
5123
  https://huobiapi.github.io/docs/usdt_swap/v1/en/#isolated-place-trigger-order # usdt-m swap isolated trigger
5124
+ https://huobiapi.github.io/docs/usdt_swap/v1/en/#isolated-set-a-take-profit-and-stop-loss-order-for-an-existing-position
5125
+ https://huobiapi.github.io/docs/usdt_swap/v1/en/#cross-set-a-take-profit-and-stop-loss-order-for-an-existing-position
5118
5126
  https://huobiapi.github.io/docs/dm/v1/en/#place-an-order # coin-m futures
5119
5127
  https://huobiapi.github.io/docs/dm/v1/en/#place-trigger-order # coin-m futures contract trigger
5120
5128
 
@@ -5136,6 +5144,7 @@ class htx(Exchange, ImplicitAPI):
5136
5144
  :param float [params.cost]: *spot market buy only* the quote quantity that can be used alternative for the amount
5137
5145
  :param float [params.trailingPercent]: *contract only* the percent to trail away from the current market price
5138
5146
  :param float [params.trailingTriggerPrice]: *contract only* the price to trigger a trailing order, default uses the price argument
5147
+ :param bool [params.hedged]: *contract only* True for hedged mode, False for one way mode, default is False
5139
5148
  :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
5140
5149
  """
5141
5150
  self.load_markets()