ccxt 4.3.5__py2.py3-none-any.whl → 4.3.7__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.

Potentially problematic release.


This version of ccxt might be problematic. Click here for more details.

Files changed (189) hide show
  1. ccxt/__init__.py +1 -1
  2. ccxt/abstract/binance.py +1 -0
  3. ccxt/abstract/binancecoinm.py +1 -0
  4. ccxt/abstract/binanceus.py +1 -0
  5. ccxt/abstract/binanceusdm.py +1 -0
  6. ccxt/abstract/bingx.py +1 -0
  7. ccxt/abstract/coinbase.py +5 -0
  8. ccxt/abstract/woo.py +1 -0
  9. ccxt/ace.py +5 -0
  10. ccxt/alpaca.py +6 -0
  11. ccxt/ascendex.py +2 -2
  12. ccxt/async_support/__init__.py +1 -1
  13. ccxt/async_support/ace.py +5 -0
  14. ccxt/async_support/alpaca.py +6 -0
  15. ccxt/async_support/ascendex.py +2 -2
  16. ccxt/async_support/base/exchange.py +30 -1
  17. ccxt/async_support/bigone.py +1 -1
  18. ccxt/async_support/binance.py +7 -3
  19. ccxt/async_support/bingx.py +43 -1
  20. ccxt/async_support/bitbank.py +4 -1
  21. ccxt/async_support/bitfinex.py +1 -1
  22. ccxt/async_support/bitfinex2.py +1 -1
  23. ccxt/async_support/bitflyer.py +1 -1
  24. ccxt/async_support/bitget.py +70 -4
  25. ccxt/async_support/bithumb.py +5 -1
  26. ccxt/async_support/bitmart.py +1 -1
  27. ccxt/async_support/bitmex.py +25 -1
  28. ccxt/async_support/bitopro.py +6 -1
  29. ccxt/async_support/bitrue.py +1 -1
  30. ccxt/async_support/bitso.py +4 -1
  31. ccxt/async_support/bitstamp.py +4 -1
  32. ccxt/async_support/bitteam.py +4 -0
  33. ccxt/async_support/bitvavo.py +4 -1
  34. ccxt/async_support/bl3p.py +3 -0
  35. ccxt/async_support/blockchaincom.py +1 -1
  36. ccxt/async_support/btcalpha.py +3 -0
  37. ccxt/async_support/btcbox.py +3 -0
  38. ccxt/async_support/btcmarkets.py +4 -1
  39. ccxt/async_support/btcturk.py +3 -0
  40. ccxt/async_support/bybit.py +196 -14
  41. ccxt/async_support/cex.py +6 -0
  42. ccxt/async_support/coinbase.py +98 -22
  43. ccxt/async_support/coinbaseinternational.py +3 -1
  44. ccxt/async_support/coinbasepro.py +7 -1
  45. ccxt/async_support/coincheck.py +3 -0
  46. ccxt/async_support/coinex.py +180 -79
  47. ccxt/async_support/coinlist.py +5 -1
  48. ccxt/async_support/coinmate.py +4 -1
  49. ccxt/async_support/coinone.py +3 -0
  50. ccxt/async_support/coinsph.py +5 -1
  51. ccxt/async_support/coinspot.py +3 -0
  52. ccxt/async_support/cryptocom.py +33 -2
  53. ccxt/async_support/delta.py +2 -2
  54. ccxt/async_support/deribit.py +1 -1
  55. ccxt/async_support/digifinex.py +3 -3
  56. ccxt/async_support/exmo.py +8 -3
  57. ccxt/async_support/gate.py +112 -24
  58. ccxt/async_support/gemini.py +1 -1
  59. ccxt/async_support/hitbtc.py +7 -6
  60. ccxt/async_support/hollaex.py +1 -1
  61. ccxt/async_support/htx.py +29 -1
  62. ccxt/async_support/huobijp.py +1 -1
  63. ccxt/async_support/hyperliquid.py +39 -2
  64. ccxt/async_support/idex.py +4 -1
  65. ccxt/async_support/independentreserve.py +3 -0
  66. ccxt/async_support/indodax.py +4 -1
  67. ccxt/async_support/kraken.py +28 -1
  68. ccxt/async_support/krakenfutures.py +26 -0
  69. ccxt/async_support/kucoin.py +3 -1
  70. ccxt/async_support/kucoinfutures.py +5 -3
  71. ccxt/async_support/kuna.py +1 -1
  72. ccxt/async_support/latoken.py +6 -0
  73. ccxt/async_support/lbank.py +1 -1
  74. ccxt/async_support/luno.py +3 -0
  75. ccxt/async_support/lykke.py +6 -1
  76. ccxt/async_support/mercado.py +4 -1
  77. ccxt/async_support/mexc.py +110 -4
  78. ccxt/async_support/ndax.py +5 -1
  79. ccxt/async_support/novadax.py +5 -1
  80. ccxt/async_support/okcoin.py +1 -1
  81. ccxt/async_support/okx.py +183 -4
  82. ccxt/async_support/onetrading.py +4 -1
  83. ccxt/async_support/p2b.py +3 -0
  84. ccxt/async_support/phemex.py +1 -1
  85. ccxt/async_support/poloniex.py +1 -1
  86. ccxt/async_support/probit.py +4 -1
  87. ccxt/async_support/timex.py +3 -0
  88. ccxt/async_support/tokocrypto.py +1 -1
  89. ccxt/async_support/tradeogre.py +3 -0
  90. ccxt/async_support/upbit.py +1 -1
  91. ccxt/async_support/wavesexchange.py +4 -1
  92. ccxt/async_support/wazirx.py +3 -0
  93. ccxt/async_support/whitebit.py +38 -1
  94. ccxt/async_support/woo.py +30 -1
  95. ccxt/async_support/yobit.py +4 -1
  96. ccxt/async_support/zaif.py +1 -1
  97. ccxt/async_support/zonda.py +1 -1
  98. ccxt/base/exchange.py +30 -1
  99. ccxt/bigone.py +1 -1
  100. ccxt/binance.py +7 -3
  101. ccxt/bingx.py +43 -1
  102. ccxt/bitbank.py +4 -1
  103. ccxt/bitfinex.py +1 -1
  104. ccxt/bitfinex2.py +1 -1
  105. ccxt/bitflyer.py +1 -1
  106. ccxt/bitget.py +70 -4
  107. ccxt/bithumb.py +5 -1
  108. ccxt/bitmart.py +1 -1
  109. ccxt/bitmex.py +25 -1
  110. ccxt/bitopro.py +6 -1
  111. ccxt/bitrue.py +1 -1
  112. ccxt/bitso.py +4 -1
  113. ccxt/bitstamp.py +4 -1
  114. ccxt/bitteam.py +4 -0
  115. ccxt/bitvavo.py +4 -1
  116. ccxt/bl3p.py +3 -0
  117. ccxt/blockchaincom.py +1 -1
  118. ccxt/btcalpha.py +3 -0
  119. ccxt/btcbox.py +3 -0
  120. ccxt/btcmarkets.py +4 -1
  121. ccxt/btcturk.py +3 -0
  122. ccxt/bybit.py +196 -14
  123. ccxt/cex.py +6 -0
  124. ccxt/coinbase.py +98 -22
  125. ccxt/coinbaseinternational.py +3 -1
  126. ccxt/coinbasepro.py +7 -1
  127. ccxt/coincheck.py +3 -0
  128. ccxt/coinex.py +180 -79
  129. ccxt/coinlist.py +5 -1
  130. ccxt/coinmate.py +4 -1
  131. ccxt/coinone.py +3 -0
  132. ccxt/coinsph.py +5 -1
  133. ccxt/coinspot.py +3 -0
  134. ccxt/cryptocom.py +33 -2
  135. ccxt/delta.py +2 -2
  136. ccxt/deribit.py +1 -1
  137. ccxt/digifinex.py +3 -3
  138. ccxt/exmo.py +8 -3
  139. ccxt/gate.py +112 -24
  140. ccxt/gemini.py +1 -1
  141. ccxt/hitbtc.py +7 -6
  142. ccxt/hollaex.py +1 -1
  143. ccxt/htx.py +29 -1
  144. ccxt/huobijp.py +1 -1
  145. ccxt/hyperliquid.py +39 -2
  146. ccxt/idex.py +4 -1
  147. ccxt/independentreserve.py +3 -0
  148. ccxt/indodax.py +4 -1
  149. ccxt/kraken.py +28 -1
  150. ccxt/krakenfutures.py +26 -0
  151. ccxt/kucoin.py +3 -1
  152. ccxt/kucoinfutures.py +5 -3
  153. ccxt/kuna.py +1 -1
  154. ccxt/latoken.py +6 -0
  155. ccxt/lbank.py +1 -1
  156. ccxt/luno.py +3 -0
  157. ccxt/lykke.py +6 -1
  158. ccxt/mercado.py +4 -1
  159. ccxt/mexc.py +110 -4
  160. ccxt/ndax.py +5 -1
  161. ccxt/novadax.py +5 -1
  162. ccxt/okcoin.py +1 -1
  163. ccxt/okx.py +183 -4
  164. ccxt/onetrading.py +4 -1
  165. ccxt/p2b.py +3 -0
  166. ccxt/phemex.py +1 -1
  167. ccxt/poloniex.py +1 -1
  168. ccxt/pro/__init__.py +1 -1
  169. ccxt/pro/bitget.py +1 -1
  170. ccxt/pro/bybit.py +1 -1
  171. ccxt/pro/coinbase.py +28 -28
  172. ccxt/probit.py +4 -1
  173. ccxt/test/test_async.py +2 -0
  174. ccxt/test/test_sync.py +2 -0
  175. ccxt/timex.py +3 -0
  176. ccxt/tokocrypto.py +1 -1
  177. ccxt/tradeogre.py +3 -0
  178. ccxt/upbit.py +1 -1
  179. ccxt/wavesexchange.py +4 -1
  180. ccxt/wazirx.py +3 -0
  181. ccxt/whitebit.py +38 -1
  182. ccxt/woo.py +30 -1
  183. ccxt/yobit.py +4 -1
  184. ccxt/zaif.py +1 -1
  185. ccxt/zonda.py +1 -1
  186. {ccxt-4.3.5.dist-info → ccxt-4.3.7.dist-info}/METADATA +4 -4
  187. {ccxt-4.3.5.dist-info → ccxt-4.3.7.dist-info}/RECORD +189 -189
  188. {ccxt-4.3.5.dist-info → ccxt-4.3.7.dist-info}/WHEEL +0 -0
  189. {ccxt-4.3.5.dist-info → ccxt-4.3.7.dist-info}/top_level.txt +0 -0
ccxt/exmo.py CHANGED
@@ -74,7 +74,12 @@ class exmo(Exchange, ImplicitAPI):
74
74
  'fetchOrderBook': True,
75
75
  'fetchOrderBooks': True,
76
76
  'fetchOrderTrades': True,
77
+ 'fetchPosition': False,
78
+ 'fetchPositionHistory': False,
77
79
  'fetchPositionMode': False,
80
+ 'fetchPositions': False,
81
+ 'fetchPositionsHistory': False,
82
+ 'fetchPositionsRisk': False,
78
83
  'fetchPremiumIndexOHLCV': False,
79
84
  'fetchTicker': True,
80
85
  'fetchTickers': True,
@@ -282,7 +287,7 @@ class exmo(Exchange, ImplicitAPI):
282
287
  'datetime': None,
283
288
  }
284
289
 
285
- def reduce_margin(self, symbol: str, amount, params={}) -> MarginModification:
290
+ def reduce_margin(self, symbol: str, amount: float, params={}) -> MarginModification:
286
291
  """
287
292
  remove margin from a position
288
293
  :see: https://documenter.getpostman.com/view/10287440/SzYXWKPi#eebf9f25-0289-4946-9482-89872c738449
@@ -293,7 +298,7 @@ class exmo(Exchange, ImplicitAPI):
293
298
  """
294
299
  return self.modify_margin_helper(symbol, amount, 'reduce', params)
295
300
 
296
- def add_margin(self, symbol: str, amount, params={}) -> MarginModification:
301
+ def add_margin(self, symbol: str, amount: float, params={}) -> MarginModification:
297
302
  """
298
303
  add margin
299
304
  :see: https://documenter.getpostman.com/view/10287440/SzYXWKPi#143ef808-79ca-4e49-9e79-a60ea4d8c0e3
@@ -1980,7 +1985,7 @@ class exmo(Exchange, ImplicitAPI):
1980
1985
  return self.markets[symbols[0]]
1981
1986
  return None
1982
1987
 
1983
- def withdraw(self, code: str, amount: float, address, tag=None, params={}):
1988
+ def withdraw(self, code: str, amount: float, address: str, tag=None, params={}):
1984
1989
  """
1985
1990
  make a withdrawal
1986
1991
  :see: https://documenter.getpostman.com/view/10287440/SzYXWKPi#3ab9c34d-ad58-4f87-9c57-2e2ea88a8325
ccxt/gate.py CHANGED
@@ -6,7 +6,7 @@
6
6
  from ccxt.base.exchange import Exchange
7
7
  from ccxt.abstract.gate import ImplicitAPI
8
8
  import hashlib
9
- from ccxt.base.types import Balances, Currencies, Currency, FundingHistory, Greeks, Int, Leverage, Leverages, MarginModification, Market, MarketInterface, Num, Option, OptionChain, Order, OrderBook, OrderRequest, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, TradingFeeInterface, TradingFees, Transaction, TransferEntry
9
+ from ccxt.base.types import Balances, Currencies, Currency, FundingHistory, Greeks, Int, Leverage, Leverages, MarginModification, Market, MarketInterface, Num, Option, OptionChain, Order, OrderBook, OrderRequest, OrderSide, OrderType, Position, Str, Strings, Ticker, Tickers, Trade, TradingFeeInterface, TradingFees, Transaction, TransferEntry
10
10
  from typing import List
11
11
  from ccxt.base.errors import ExchangeError
12
12
  from ccxt.base.errors import AuthenticationError
@@ -156,8 +156,10 @@ class gate(Exchange, ImplicitAPI):
156
156
  'fetchOrder': True,
157
157
  'fetchOrderBook': True,
158
158
  'fetchPosition': True,
159
+ 'fetchPositionHistory': 'emulated',
159
160
  'fetchPositionMode': False,
160
161
  'fetchPositions': True,
162
+ 'fetchPositionsHistory': True,
161
163
  'fetchPremiumIndexOHLCV': False,
162
164
  'fetchSettlementHistory': True,
163
165
  'fetchTicker': True,
@@ -672,7 +674,6 @@ class gate(Exchange, ImplicitAPI):
672
674
  'option': 'options',
673
675
  'options': 'options',
674
676
  },
675
- 'defaultType': 'spot',
676
677
  'swap': {
677
678
  'fetchMarkets': {
678
679
  'settlementCurrencies': ['usdt', 'btc'],
@@ -3391,7 +3392,7 @@ class gate(Exchange, ImplicitAPI):
3391
3392
  response = self.privateWalletGetWithdrawals(self.extend(request, params))
3392
3393
  return self.parse_transactions(response, currency)
3393
3394
 
3394
- def withdraw(self, code: str, amount: float, address, tag=None, params={}):
3395
+ def withdraw(self, code: str, amount: float, address: str, tag=None, params={}):
3395
3396
  """
3396
3397
  make a withdrawal
3397
3398
  :see: https://www.gate.io/docs/developers/apiv4/en/#withdraw
@@ -4946,37 +4947,61 @@ class gate(Exchange, ImplicitAPI):
4946
4947
  # "pending_orders": 0
4947
4948
  # }
4948
4949
  #
4950
+ # fetchPositionsHistory(swap and future)
4951
+ #
4952
+ # {
4953
+ # "contract": "SLERF_USDT", # Futures contract
4954
+ # "text": "web", # Text of close order
4955
+ # "long_price": "0.766306", # When 'side' is 'long,' it indicates the opening average price; when 'side' is 'short,' it indicates the closing average price.
4956
+ # "pnl": "-23.41702352", # PNL
4957
+ # "pnl_pnl": "-22.7187", # Position P/L
4958
+ # "pnl_fee": "-0.06527125", # Transaction Fees
4959
+ # "pnl_fund": "-0.63305227", # Funding Fees
4960
+ # "accum_size": "100",
4961
+ # "time": 1711279263, # Position close time
4962
+ # "short_price": "0.539119", # When 'side' is 'long,' it indicates the opening average price; when 'side' is 'short,' it indicates the closing average price
4963
+ # "side": "long", # Position side, long or short
4964
+ # "max_size": "100", # Max Trade Size
4965
+ # "first_open_time": 1711037985 # First Open Time
4966
+ # }
4967
+ #
4949
4968
  contract = self.safe_string(position, 'contract')
4950
4969
  market = self.safe_market(contract, market, '_', 'contract')
4951
- size = self.safe_string(position, 'size')
4952
- side = None
4953
- if Precise.string_gt(size, '0'):
4954
- side = 'long'
4955
- elif Precise.string_lt(size, '0'):
4956
- side = 'short'
4970
+ size = self.safe_string_2(position, 'size', 'accum_size')
4971
+ side = self.safe_string(position, 'side')
4972
+ if side is None:
4973
+ if Precise.string_gt(size, '0'):
4974
+ side = 'long'
4975
+ elif Precise.string_lt(size, '0'):
4976
+ side = 'short'
4957
4977
  maintenanceRate = self.safe_string(position, 'maintenance_rate')
4958
4978
  notional = self.safe_string(position, 'value')
4959
4979
  leverage = self.safe_string(position, 'leverage')
4960
4980
  marginMode = None
4961
- if leverage == '0':
4962
- marginMode = 'cross'
4963
- else:
4964
- marginMode = 'isolated'
4965
- unrealisedPnl = self.safe_string(position, 'unrealised_pnl')
4981
+ if leverage is not None:
4982
+ if leverage == '0':
4983
+ marginMode = 'cross'
4984
+ else:
4985
+ marginMode = 'isolated'
4966
4986
  # Initial Position Margin = ( Position Value / Leverage ) + Close Position Fee
4967
4987
  # *The default leverage under the full position is the highest leverage in the market.
4968
4988
  # *Trading fee is charged Fee Rate(0.075%).
4969
- takerFee = '0.00075'
4970
- feePaid = Precise.string_mul(takerFee, notional)
4971
- initialMarginString = Precise.string_add(Precise.string_div(notional, leverage), feePaid)
4972
- timestamp = self.safe_timestamp(position, 'open_time')
4989
+ feePaid = self.safe_string(position, 'pnl_fee')
4990
+ initialMarginString = None
4991
+ if feePaid is None:
4992
+ takerFee = '0.00075'
4993
+ feePaid = Precise.string_mul(takerFee, notional)
4994
+ initialMarginString = Precise.string_add(Precise.string_div(notional, leverage), feePaid)
4995
+ timestamp = self.safe_timestamp_2(position, 'open_time', 'first_open_time')
4996
+ if timestamp == 0:
4997
+ timestamp = None
4973
4998
  return self.safe_position({
4974
4999
  'info': position,
4975
5000
  'id': None,
4976
5001
  'symbol': self.safe_string(market, 'symbol'),
4977
5002
  'timestamp': timestamp,
4978
5003
  'datetime': self.iso8601(timestamp),
4979
- 'lastUpdateTimestamp': self.safe_timestamp(position, 'update_time'),
5004
+ 'lastUpdateTimestamp': self.safe_timestamp_2(position, 'update_time', 'time'),
4980
5005
  'initialMargin': self.parse_number(initialMarginString),
4981
5006
  'initialMarginPercentage': self.parse_number(Precise.string_div(initialMarginString, notional)),
4982
5007
  'maintenanceMargin': self.parse_number(Precise.string_mul(maintenanceRate, notional)),
@@ -4984,11 +5009,10 @@ class gate(Exchange, ImplicitAPI):
4984
5009
  'entryPrice': self.safe_number(position, 'entry_price'),
4985
5010
  'notional': self.parse_number(notional),
4986
5011
  'leverage': self.safe_number(position, 'leverage'),
4987
- 'unrealizedPnl': self.parse_number(unrealisedPnl),
4988
- 'realizedPnl': self.safe_number(position, 'realised_pnl'),
5012
+ 'unrealizedPnl': self.safe_number(position, 'unrealised_pnl'),
5013
+ 'realizedPnl': self.safe_number_2(position, 'realised_pnl', 'pnl'),
4989
5014
  'contracts': self.parse_number(Precise.string_abs(size)),
4990
5015
  'contractSize': self.safe_number(market, 'contractSize'),
4991
- # 'realisedPnl': position['realised_pnl'],
4992
5016
  'marginRatio': None,
4993
5017
  'liquidationPrice': self.safe_number(position, 'liq_price'),
4994
5018
  'markPrice': self.safe_number(position, 'mark_price'),
@@ -5697,7 +5721,7 @@ class gate(Exchange, ImplicitAPI):
5697
5721
  'datetime': None,
5698
5722
  }
5699
5723
 
5700
- def reduce_margin(self, symbol: str, amount, params={}) -> MarginModification:
5724
+ def reduce_margin(self, symbol: str, amount: float, params={}) -> MarginModification:
5701
5725
  """
5702
5726
  remove margin from a position
5703
5727
  :see: https://www.gate.io/docs/developers/apiv4/en/#update-position-margin
@@ -5709,7 +5733,7 @@ class gate(Exchange, ImplicitAPI):
5709
5733
  """
5710
5734
  return self.modify_margin_helper(symbol, -amount, params)
5711
5735
 
5712
- def add_margin(self, symbol: str, amount, params={}) -> MarginModification:
5736
+ def add_margin(self, symbol: str, amount: float, params={}) -> MarginModification:
5713
5737
  """
5714
5738
  add margin
5715
5739
  :see: https://www.gate.io/docs/developers/apiv4/en/#update-position-margin
@@ -6868,6 +6892,70 @@ class gate(Exchange, ImplicitAPI):
6868
6892
  'quoteVolume': None,
6869
6893
  }
6870
6894
 
6895
+ def fetch_positions_history(self, symbols: Strings = None, since: Int = None, limit: Int = None, params={}) -> List[Position]:
6896
+ """
6897
+ fetches historical positions
6898
+ :see: https://www.gate.io/docs/developers/apiv4/#list-position-close-history
6899
+ :see: https://www.gate.io/docs/developers/apiv4/#list-position-close-history-2
6900
+ :param str[] symbols: unified conract symbols, must all have the same settle currency and the same market type
6901
+ :param int [since]: the earliest time in ms to fetch positions for
6902
+ :param int [limit]: the maximum amount of records to fetch, default=1000
6903
+ :param dict params: extra parameters specific to the exchange api endpoint
6904
+ :param int [params.until]: the latest time in ms to fetch positions for
6905
+ *
6906
+ * EXCHANGE SPECIFIC PARAMETERS
6907
+ :param int offset: list offset, starting from 0
6908
+ :param str side: long or short
6909
+ :param str pnl: query profit or loss
6910
+ :returns dict[]: a list of `position structures <https://docs.ccxt.com/#/?id=position-structure>`
6911
+ """
6912
+ self.load_markets()
6913
+ market = None
6914
+ if symbols is not None:
6915
+ symbolsLength = len(symbols)
6916
+ if symbolsLength == 1:
6917
+ market = self.market(symbols[0])
6918
+ marketType = None
6919
+ marketType, params = self.handle_market_type_and_params('fetchPositionsHistory', market, params, 'swap')
6920
+ until = self.safe_integer(params, 'until')
6921
+ params = self.omit(params, 'until')
6922
+ request = {}
6923
+ request, params = self.prepare_request(market, marketType, params)
6924
+ if limit is not None:
6925
+ request['limit'] = limit
6926
+ if since is not None:
6927
+ request['from'] = self.parse_to_int(since / 1000)
6928
+ if until is not None:
6929
+ request['to'] = self.parse_to_int(until / 1000)
6930
+ response = None
6931
+ if marketType == 'swap':
6932
+ response = self.privateFuturesGetSettlePositionClose(self.extend(request, params))
6933
+ elif marketType == 'future':
6934
+ response = self.privateDeliveryGetSettlePositionClose(self.extend(request, params))
6935
+ else:
6936
+ raise NotSupported(self.id + ' fetchPositionsHistory() does not support markets of type ' + marketType)
6937
+ #
6938
+ # [
6939
+ # {
6940
+ # "contract": "SLERF_USDT",
6941
+ # "text": "web",
6942
+ # "long_price": "0.766306",
6943
+ # "pnl": "-23.41702352",
6944
+ # "pnl_pnl": "-22.7187",
6945
+ # "pnl_fee": "-0.06527125",
6946
+ # "pnl_fund": "-0.63305227",
6947
+ # "accum_size": "100",
6948
+ # "time": 1711279263,
6949
+ # "short_price": "0.539119",
6950
+ # "side": "long",
6951
+ # "max_size": "100",
6952
+ # "first_open_time": 1711037985
6953
+ # },
6954
+ # ...
6955
+ # ]
6956
+ #
6957
+ return self.parse_positions(response, symbols, params)
6958
+
6871
6959
  def handle_errors(self, code, reason, url, method, headers, body, response, requestHeaders, requestBody):
6872
6960
  if response is None:
6873
6961
  return None
ccxt/gemini.py CHANGED
@@ -1522,7 +1522,7 @@ class gemini(Exchange, ImplicitAPI):
1522
1522
  response = self.privatePostV1Mytrades(self.extend(request, params))
1523
1523
  return self.parse_trades(response, market, since, limit)
1524
1524
 
1525
- def withdraw(self, code: str, amount: float, address, tag=None, params={}):
1525
+ def withdraw(self, code: str, amount: float, address: str, tag=None, params={}):
1526
1526
  """
1527
1527
  make a withdrawal
1528
1528
  :see: https://docs.gemini.com/rest-api/#withdraw-crypto-funds
ccxt/hitbtc.py CHANGED
@@ -2491,7 +2491,7 @@ class hitbtc(Exchange, ImplicitAPI):
2491
2491
  'info': response,
2492
2492
  }
2493
2493
 
2494
- def withdraw(self, code: str, amount: float, address, tag=None, params={}):
2494
+ def withdraw(self, code: str, amount: float, address: str, tag=None, params={}):
2495
2495
  """
2496
2496
  make a withdrawal
2497
2497
  :see: https://api.hitbtc.com/#withdraw-crypto
@@ -3008,8 +3008,9 @@ class hitbtc(Exchange, ImplicitAPI):
3008
3008
  if market['swap']:
3009
3009
  if leverage is None:
3010
3010
  raise ArgumentsRequired(self.id + ' modifyMarginHelper() requires a leverage parameter for swap markets')
3011
- if amount != 0:
3012
- amount = self.amount_to_precision(symbol, amount)
3011
+ stringAmount = self.number_to_string(amount)
3012
+ if stringAmount != '0':
3013
+ amount = self.amount_to_precision(symbol, stringAmount)
3013
3014
  else:
3014
3015
  amount = '0'
3015
3016
  request = {
@@ -3091,7 +3092,7 @@ class hitbtc(Exchange, ImplicitAPI):
3091
3092
  'datetime': datetime,
3092
3093
  }
3093
3094
 
3094
- def reduce_margin(self, symbol: str, amount, params={}) -> MarginModification:
3095
+ def reduce_margin(self, symbol: str, amount: float, params={}) -> MarginModification:
3095
3096
  """
3096
3097
  remove margin from a position
3097
3098
  :see: https://api.hitbtc.com/#create-update-margin-account-2
@@ -3103,11 +3104,11 @@ class hitbtc(Exchange, ImplicitAPI):
3103
3104
  :param bool [params.margin]: True for reducing spot-margin
3104
3105
  :returns dict: a `margin structure <https://docs.ccxt.com/#/?id=reduce-margin-structure>`
3105
3106
  """
3106
- if amount != 0:
3107
+ if self.number_to_string(amount) != '0':
3107
3108
  raise BadRequest(self.id + ' reduceMargin() on hitbtc requires the amount to be 0 and that will remove the entire margin amount')
3108
3109
  return self.modify_margin_helper(symbol, amount, 'reduce', params)
3109
3110
 
3110
- def add_margin(self, symbol: str, amount, params={}) -> MarginModification:
3111
+ def add_margin(self, symbol: str, amount: float, params={}) -> MarginModification:
3111
3112
  """
3112
3113
  add margin
3113
3114
  :see: https://api.hitbtc.com/#create-update-margin-account-2
ccxt/hollaex.py CHANGED
@@ -1609,7 +1609,7 @@ class hollaex(Exchange, ImplicitAPI):
1609
1609
  'fee': fee,
1610
1610
  }
1611
1611
 
1612
- def withdraw(self, code: str, amount: float, address, tag=None, params={}):
1612
+ def withdraw(self, code: str, amount: float, address: str, tag=None, params={}):
1613
1613
  """
1614
1614
  make a withdrawal
1615
1615
  :see: https://apidocs.hollaex.com/#withdrawal
ccxt/htx.py CHANGED
@@ -53,6 +53,7 @@ class htx(Exchange, ImplicitAPI):
53
53
  'borrowCrossMargin': True,
54
54
  'borrowIsolatedMargin': True,
55
55
  'cancelAllOrders': True,
56
+ 'cancelAllOrdersAfter': True,
56
57
  'cancelOrder': True,
57
58
  'cancelOrders': True,
58
59
  'createDepositAddress': None,
@@ -119,7 +120,9 @@ class htx(Exchange, ImplicitAPI):
119
120
  'fetchOrders': True,
120
121
  'fetchOrderTrades': True,
121
122
  'fetchPosition': True,
123
+ 'fetchPositionHistory': 'emulated',
122
124
  'fetchPositions': True,
125
+ 'fetchPositionsHistory': False,
123
126
  'fetchPositionsRisk': False,
124
127
  'fetchPremiumIndexOHLCV': True,
125
128
  'fetchSettlementHistory': True,
@@ -5628,6 +5631,31 @@ class htx(Exchange, ImplicitAPI):
5628
5631
  #
5629
5632
  return response
5630
5633
 
5634
+ def cancel_all_orders_after(self, timeout: Int, params={}):
5635
+ """
5636
+ dead man's switch, cancel all orders after the given timeout
5637
+ :see: https://huobiapi.github.io/docs/spot/v1/en/#dead-man-s-switch
5638
+ :param number timeout: time in milliseconds, 0 represents cancel the timer
5639
+ :param dict [params]: extra parameters specific to the exchange API endpoint
5640
+ :returns dict: the api result
5641
+ """
5642
+ self.load_markets()
5643
+ request: dict = {
5644
+ 'timeout': self.parse_to_int(timeout / 1000) if (timeout > 0) else 0,
5645
+ }
5646
+ response = self.v2PrivatePostAlgoOrdersCancelAllAfter(self.extend(request, params))
5647
+ #
5648
+ # {
5649
+ # "code": 200,
5650
+ # "message": "success",
5651
+ # "data": {
5652
+ # "currentTime": 1630491627230,
5653
+ # "triggerTime": 1630491637230
5654
+ # }
5655
+ # }
5656
+ #
5657
+ return response
5658
+
5631
5659
  def parse_deposit_address(self, depositAddress, currency: Currency = None):
5632
5660
  #
5633
5661
  # {
@@ -5949,7 +5977,7 @@ class htx(Exchange, ImplicitAPI):
5949
5977
  }
5950
5978
  return self.safe_string(statuses, status, status)
5951
5979
 
5952
- def withdraw(self, code: str, amount: float, address, tag=None, params={}):
5980
+ def withdraw(self, code: str, amount: float, address: str, tag=None, params={}):
5953
5981
  """
5954
5982
  make a withdrawal
5955
5983
  :param str code: unified currency code
ccxt/huobijp.py CHANGED
@@ -1696,7 +1696,7 @@ class huobijp(Exchange, ImplicitAPI):
1696
1696
  }
1697
1697
  return self.safe_string(statuses, status, status)
1698
1698
 
1699
- def withdraw(self, code: str, amount: float, address, tag=None, params={}):
1699
+ def withdraw(self, code: str, amount: float, address: str, tag=None, params={}):
1700
1700
  """
1701
1701
  make a withdrawal
1702
1702
  :param str code: unified currency code
ccxt/hyperliquid.py CHANGED
@@ -42,6 +42,7 @@ class hyperliquid(Exchange, ImplicitAPI):
42
42
  'borrowCrossMargin': False,
43
43
  'borrowIsolatedMargin': False,
44
44
  'cancelAllOrders': False,
45
+ 'cancelAllOrdersAfter': True,
45
46
  'cancelOrder': True,
46
47
  'cancelOrders': True,
47
48
  'cancelOrdersForSymbols': True,
@@ -1302,6 +1303,42 @@ class hyperliquid(Exchange, ImplicitAPI):
1302
1303
  #
1303
1304
  return response
1304
1305
 
1306
+ def cancel_all_orders_after(self, timeout: Int, params={}):
1307
+ """
1308
+ dead man's switch, cancel all orders after the given timeout
1309
+ :param number timeout: time in milliseconds, 0 represents cancel the timer
1310
+ :param dict [params]: extra parameters specific to the exchange API endpoint
1311
+ :param str [params.vaultAddress]: the vault address
1312
+ :returns dict: the api result
1313
+ """
1314
+ self.check_required_credentials()
1315
+ self.load_markets()
1316
+ params = self.omit(params, ['clientOrderId', 'client_id'])
1317
+ nonce = self.milliseconds()
1318
+ request = {
1319
+ 'nonce': nonce,
1320
+ # 'vaultAddress': vaultAddress,
1321
+ }
1322
+ cancelAction = {
1323
+ 'type': 'scheduleCancel',
1324
+ 'time': nonce + timeout,
1325
+ }
1326
+ vaultAddress = self.format_vault_address(self.safe_string(params, 'vaultAddress'))
1327
+ signature = self.sign_l1_action(cancelAction, nonce, vaultAddress)
1328
+ request['action'] = cancelAction
1329
+ request['signature'] = signature
1330
+ if vaultAddress is not None:
1331
+ params = self.omit(params, 'vaultAddress')
1332
+ request['vaultAddress'] = vaultAddress
1333
+ response = self.privatePostExchange(self.extend(request, params))
1334
+ #
1335
+ # {
1336
+ # "status":"err",
1337
+ # "response":"Cannot set scheduled cancel time until enough volume traded. Required: $1000000. Traded: $373.47205."
1338
+ # }
1339
+ #
1340
+ return response
1341
+
1305
1342
  def edit_order(self, id: str, symbol: str, type: str, side: str, amount: Num = None, price: Num = None, params={}):
1306
1343
  """
1307
1344
  edit a trade order
@@ -2089,7 +2126,7 @@ class hyperliquid(Exchange, ImplicitAPI):
2089
2126
  #
2090
2127
  return response
2091
2128
 
2092
- def add_margin(self, symbol: str, amount, params={}) -> MarginModification:
2129
+ def add_margin(self, symbol: str, amount: float, params={}) -> MarginModification:
2093
2130
  """
2094
2131
  add margin
2095
2132
  :see: https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/exchange-endpoint#update-isolated-margin
@@ -2100,7 +2137,7 @@ class hyperliquid(Exchange, ImplicitAPI):
2100
2137
  """
2101
2138
  return self.modify_margin_helper(symbol, amount, 'add', params)
2102
2139
 
2103
- def reduce_margin(self, symbol: str, amount, params={}) -> MarginModification:
2140
+ def reduce_margin(self, symbol: str, amount: float, params={}) -> MarginModification:
2104
2141
  """
2105
2142
  :see: https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/exchange-endpoint#update-isolated-margin
2106
2143
  remove margin from a position
ccxt/idex.py CHANGED
@@ -88,8 +88,11 @@ class idex(Exchange, ImplicitAPI):
88
88
  'fetchOrderBook': True,
89
89
  'fetchOrders': False,
90
90
  'fetchPosition': False,
91
+ 'fetchPositionHistory': False,
91
92
  'fetchPositionMode': False,
92
93
  'fetchPositions': False,
94
+ 'fetchPositionsForSymbol': False,
95
+ 'fetchPositionsHistory': False,
93
96
  'fetchPositionsRisk': False,
94
97
  'fetchPremiumIndexOHLCV': False,
95
98
  'fetchStatus': True,
@@ -1287,7 +1290,7 @@ class idex(Exchange, ImplicitAPI):
1287
1290
  response = self.privatePostOrders(request)
1288
1291
  return self.parse_order(response, market)
1289
1292
 
1290
- def withdraw(self, code: str, amount: float, address, tag=None, params={}):
1293
+ def withdraw(self, code: str, amount: float, address: str, tag=None, params={}):
1291
1294
  """
1292
1295
  make a withdrawal
1293
1296
  :see: https://api-docs-v3.idex.io/#withdraw-funds
@@ -64,8 +64,11 @@ class independentreserve(Exchange, ImplicitAPI):
64
64
  'fetchOrder': True,
65
65
  'fetchOrderBook': True,
66
66
  'fetchPosition': False,
67
+ 'fetchPositionHistory': False,
67
68
  'fetchPositionMode': False,
68
69
  'fetchPositions': False,
70
+ 'fetchPositionsForSymbol': False,
71
+ 'fetchPositionsHistory': False,
69
72
  'fetchPositionsRisk': False,
70
73
  'fetchPremiumIndexOHLCV': False,
71
74
  'fetchTicker': True,
ccxt/indodax.py CHANGED
@@ -78,8 +78,11 @@ class indodax(Exchange, ImplicitAPI):
78
78
  'fetchOrderBook': True,
79
79
  'fetchOrders': False,
80
80
  'fetchPosition': False,
81
+ 'fetchPositionHistory': False,
81
82
  'fetchPositionMode': False,
82
83
  'fetchPositions': False,
84
+ 'fetchPositionsForSymbol': False,
85
+ 'fetchPositionsHistory': False,
83
86
  'fetchPositionsRisk': False,
84
87
  'fetchPremiumIndexOHLCV': False,
85
88
  'fetchTicker': True,
@@ -951,7 +954,7 @@ class indodax(Exchange, ImplicitAPI):
951
954
  transactions = self.array_concat(withdraws, deposits)
952
955
  return self.parse_transactions(transactions, currency, since, limit)
953
956
 
954
- def withdraw(self, code: str, amount: float, address, tag=None, params={}):
957
+ def withdraw(self, code: str, amount: float, address: str, tag=None, params={}):
955
958
  """
956
959
  make a withdrawal
957
960
  :see: https://github.com/btcid/indodax-official-api-docs/blob/master/Private-RestAPI.md#withdraw-coin-endpoints
ccxt/kraken.py CHANGED
@@ -54,6 +54,7 @@ class kraken(Exchange, ImplicitAPI):
54
54
  'option': False,
55
55
  'addMargin': False,
56
56
  'cancelAllOrders': True,
57
+ 'cancelAllOrdersAfter': True,
57
58
  'cancelOrder': True,
58
59
  'cancelOrders': True,
59
60
  'createDepositAddress': True,
@@ -2006,6 +2007,32 @@ class kraken(Exchange, ImplicitAPI):
2006
2007
  self.load_markets()
2007
2008
  return self.privatePostCancelAll(params)
2008
2009
 
2010
+ def cancel_all_orders_after(self, timeout: Int, params={}):
2011
+ """
2012
+ dead man's switch, cancel all orders after the given timeout
2013
+ :see: https://docs.kraken.com/rest/#tag/Spot-Trading/operation/cancelAllOrdersAfter
2014
+ :param number timeout: time in milliseconds, 0 represents cancel the timer
2015
+ :param dict [params]: extra parameters specific to the exchange API endpoint
2016
+ :returns dict: the api result
2017
+ """
2018
+ if timeout > 86400000:
2019
+ raise BadRequest(self.id + 'cancelAllOrdersAfter timeout should be less than 86400000 milliseconds')
2020
+ self.load_markets()
2021
+ request: dict = {
2022
+ 'timeout': (self.parse_to_int(timeout / 1000)) if (timeout > 0) else 0,
2023
+ }
2024
+ response = self.privatePostCancelAllOrdersAfter(self.extend(request, params))
2025
+ #
2026
+ # {
2027
+ # "error": [],
2028
+ # "result": {
2029
+ # "currentTime": "2023-03-24T17:41:56Z",
2030
+ # "triggerTime": "2023-03-24T17:42:56Z"
2031
+ # }
2032
+ # }
2033
+ #
2034
+ return response
2035
+
2009
2036
  def fetch_open_orders(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}) -> List[Order]:
2010
2037
  """
2011
2038
  fetch all unfilled currently open orders
@@ -2495,7 +2522,7 @@ class kraken(Exchange, ImplicitAPI):
2495
2522
  'info': depositAddress,
2496
2523
  }
2497
2524
 
2498
- def withdraw(self, code: str, amount: float, address, tag=None, params={}):
2525
+ def withdraw(self, code: str, amount: float, address: str, tag=None, params={}):
2499
2526
  """
2500
2527
  make a withdrawal
2501
2528
  :see: https://docs.kraken.com/rest/#tag/Funding/operation/withdrawFunds
ccxt/krakenfutures.py CHANGED
@@ -46,6 +46,7 @@ class krakenfutures(Exchange, ImplicitAPI):
46
46
  'future': True,
47
47
  'option': False,
48
48
  'cancelAllOrders': True,
49
+ 'cancelAllOrdersAfter': True,
49
50
  'cancelOrder': True,
50
51
  'cancelOrders': True,
51
52
  'createMarketOrder': False,
@@ -1207,6 +1208,31 @@ class krakenfutures(Exchange, ImplicitAPI):
1207
1208
  response = self.privatePostCancelallorders(self.extend(request, params))
1208
1209
  return response
1209
1210
 
1211
+ def cancel_all_orders_after(self, timeout: Int, params={}):
1212
+ """
1213
+ dead man's switch, cancel all orders after the given timeout
1214
+ :see: https://docs.futures.kraken.com/#http-api-trading-v3-api-order-management-dead-man-39-s-switch
1215
+ :param number timeout: time in milliseconds, 0 represents cancel the timer
1216
+ :param dict [params]: extra parameters specific to the exchange API endpoint
1217
+ :returns dict: the api result
1218
+ """
1219
+ self.load_markets()
1220
+ request: dict = {
1221
+ 'timeout': (self.parse_to_int(timeout / 1000)) if (timeout > 0) else 0,
1222
+ }
1223
+ response = self.privatePostCancelallordersafter(self.extend(request, params))
1224
+ #
1225
+ # {
1226
+ # "result": "success",
1227
+ # "serverTime": "2018-06-19T16:51:23.839Z",
1228
+ # "status": {
1229
+ # "currentTime": "2018-06-19T16:51:23.839Z",
1230
+ # "triggerTime": "0"
1231
+ # }
1232
+ # }
1233
+ #
1234
+ return response
1235
+
1210
1236
  def fetch_open_orders(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}) -> List[Order]:
1211
1237
  """
1212
1238
  :see: https://docs.futures.kraken.com/#http-api-trading-v3-api-order-management-get-open-orders
ccxt/kucoin.py CHANGED
@@ -107,7 +107,9 @@ class kucoin(Exchange, ImplicitAPI):
107
107
  'fetchOrderBooks': False,
108
108
  'fetchOrdersByStatus': True,
109
109
  'fetchOrderTrades': True,
110
+ 'fetchPositionHistory': False,
110
111
  'fetchPositionMode': False,
112
+ 'fetchPositionsHistory': False,
111
113
  'fetchPremiumIndexOHLCV': False,
112
114
  'fetchStatus': True,
113
115
  'fetchTicker': True,
@@ -3003,7 +3005,7 @@ class kucoin(Exchange, ImplicitAPI):
3003
3005
  'tierBased': True,
3004
3006
  }
3005
3007
 
3006
- def withdraw(self, code: str, amount: float, address, tag=None, params={}):
3008
+ def withdraw(self, code: str, amount: float, address: str, tag=None, params={}):
3007
3009
  """
3008
3010
  make a withdrawal
3009
3011
  :see: https://www.kucoin.com/docs/rest/funding/withdrawals/apply-withdraw
ccxt/kucoinfutures.py CHANGED
@@ -91,8 +91,10 @@ class kucoinfutures(kucoin, ImplicitAPI):
91
91
  'fetchOrder': True,
92
92
  'fetchOrderBook': True,
93
93
  'fetchPosition': True,
94
+ 'fetchPositionHistory': False,
94
95
  'fetchPositionMode': False,
95
96
  'fetchPositions': True,
97
+ 'fetchPositionsHistory': False,
96
98
  'fetchPremiumIndexOHLCV': False,
97
99
  'fetchStatus': True,
98
100
  'fetchTicker': True,
@@ -1425,7 +1427,7 @@ class kucoinfutures(kucoin, ImplicitAPI):
1425
1427
  #
1426
1428
  return self.safe_value(response, 'data')
1427
1429
 
1428
- def add_margin(self, symbol: str, amount, params={}) -> MarginModification:
1430
+ def add_margin(self, symbol: str, amount: float, params={}) -> MarginModification:
1429
1431
  """
1430
1432
  add margin
1431
1433
  :see: https://www.kucoin.com/docs/rest/futures-trading/positions/add-margin-manually
@@ -2093,8 +2095,8 @@ class kucoinfutures(kucoin, ImplicitAPI):
2093
2095
  # symbol(str) [optional] Symbol of the contract
2094
2096
  # side(str) [optional] buy or sell
2095
2097
  # type(str) [optional] limit, market, limit_stop or market_stop
2096
- # startAt(long) [optional] Start time(milisecond)
2097
- # endAt(long) [optional] End time(milisecond)
2098
+ # startAt(long) [optional] Start time(millisecond)
2099
+ # endAt(long) [optional] End time(millisecond)
2098
2100
  }
2099
2101
  market = None
2100
2102
  if symbol is not None: