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