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
@@ -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
- async def add_margin(self, symbol: str, amount, params={}) -> MarginModification:
1430
+ async 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:
@@ -1340,7 +1340,7 @@ class kuna(Exchange, ImplicitAPI):
1340
1340
  data = self.safe_list(response, 'data')
1341
1341
  return self.parse_trades(data, market, since, limit)
1342
1342
 
1343
- async def withdraw(self, code: str, amount: float, address, tag=None, params={}):
1343
+ async def withdraw(self, code: str, amount: float, address: str, tag=None, params={}):
1344
1344
  """
1345
1345
  make a withdrawal
1346
1346
  :see: https://docs.kuna.io/docs/create-a-withdraw
@@ -69,7 +69,13 @@ class latoken(Exchange, ImplicitAPI):
69
69
  'fetchOrder': True,
70
70
  'fetchOrderBook': True,
71
71
  'fetchOrders': True,
72
+ 'fetchPosition': False,
73
+ 'fetchPositionHistory': False,
72
74
  'fetchPositionMode': False,
75
+ 'fetchPositions': False,
76
+ 'fetchPositionsForSymbol': False,
77
+ 'fetchPositionsHistory': False,
78
+ 'fetchPositionsRisk': False,
73
79
  'fetchTicker': True,
74
80
  'fetchTickers': True,
75
81
  'fetchTime': True,
@@ -1909,7 +1909,7 @@ class lbank(Exchange, ImplicitAPI):
1909
1909
  'info': response,
1910
1910
  }
1911
1911
 
1912
- async def withdraw(self, code: str, amount: float, address, tag=None, params={}) -> Transaction:
1912
+ async def withdraw(self, code: str, amount: float, address: str, tag=None, params={}) -> Transaction:
1913
1913
  """
1914
1914
  make a withdrawal
1915
1915
  :see: https://www.lbank.com/en-US/docs/index.html#withdrawal
@@ -64,8 +64,11 @@ class luno(Exchange, ImplicitAPI):
64
64
  'fetchOrderBook': True,
65
65
  'fetchOrders': 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,
@@ -70,8 +70,13 @@ class lykke(Exchange, ImplicitAPI):
70
70
  'fetchOrderBook': True,
71
71
  'fetchOrders': False,
72
72
  'fetchOrderTrades': False,
73
+ 'fetchPosition': False,
74
+ 'fetchPositionHistory': False,
73
75
  'fetchPositionMode': False,
74
76
  'fetchPositions': False,
77
+ 'fetchPositionsForSymbol': False,
78
+ 'fetchPositionsHistory': False,
79
+ 'fetchPositionsRisk': False,
75
80
  'fetchPremiumIndexOHLCV': False,
76
81
  'fetchTicker': True,
77
82
  'fetchTickers': True,
@@ -1192,7 +1197,7 @@ class lykke(Exchange, ImplicitAPI):
1192
1197
  currency = self.currency(code)
1193
1198
  return self.parse_transactions(payload, currency, since, limit)
1194
1199
 
1195
- async def withdraw(self, code: str, amount: float, address, tag=None, params={}):
1200
+ async def withdraw(self, code: str, amount: float, address: str, tag=None, params={}):
1196
1201
  """
1197
1202
  make a withdrawal
1198
1203
  :see: https://lykkecity.github.io/Trading-API/#withdrawal
@@ -67,8 +67,11 @@ class mercado(Exchange, ImplicitAPI):
67
67
  'fetchOrderBook': True,
68
68
  'fetchOrders': True,
69
69
  'fetchPosition': False,
70
+ 'fetchPositionHistory': False,
70
71
  'fetchPositionMode': False,
71
72
  'fetchPositions': False,
73
+ 'fetchPositionsForSymbol': False,
74
+ 'fetchPositionsHistory': False,
72
75
  'fetchPositionsRisk': False,
73
76
  'fetchPremiumIndexOHLCV': False,
74
77
  'fetchTicker': True,
@@ -594,7 +597,7 @@ class mercado(Exchange, ImplicitAPI):
594
597
  order = self.safe_dict(responseData, 'order')
595
598
  return self.parse_order(order, market)
596
599
 
597
- async def withdraw(self, code: str, amount: float, address, tag=None, params={}):
600
+ async def withdraw(self, code: str, amount: float, address: str, tag=None, params={}):
598
601
  """
599
602
  make a withdrawal
600
603
  :param str code: unified currency code
@@ -6,7 +6,7 @@
6
6
  from ccxt.async_support.base.exchange import Exchange
7
7
  from ccxt.abstract.mexc import ImplicitAPI
8
8
  import hashlib
9
- from ccxt.base.types import Account, Balances, Currencies, Currency, IndexType, Int, Leverage, MarginModification, Market, Num, Order, OrderBook, OrderRequest, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, TradingFees, Transaction, TransferEntry
9
+ from ccxt.base.types import Account, Balances, Currencies, Currency, IndexType, Int, Leverage, MarginModification, Market, Num, Order, OrderBook, OrderRequest, OrderSide, OrderType, Position, Str, Strings, Ticker, Tickers, Trade, 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
@@ -104,8 +104,10 @@ class mexc(Exchange, ImplicitAPI):
104
104
  'fetchOrders': True,
105
105
  'fetchOrderTrades': True,
106
106
  'fetchPosition': True,
107
+ 'fetchPositionHistory': 'emulated',
107
108
  'fetchPositionMode': True,
108
109
  'fetchPositions': True,
110
+ 'fetchPositionsHistory': True,
109
111
  'fetchPositionsRisk': None,
110
112
  'fetchPremiumIndexOHLCV': False,
111
113
  'fetchStatus': True,
@@ -3779,7 +3781,7 @@ class mexc(Exchange, ImplicitAPI):
3779
3781
  # }
3780
3782
  return response
3781
3783
 
3782
- async def reduce_margin(self, symbol: str, amount, params={}) -> MarginModification:
3784
+ async def reduce_margin(self, symbol: str, amount: float, params={}) -> MarginModification:
3783
3785
  """
3784
3786
  remove margin from a position
3785
3787
  :param str symbol: unified market symbol
@@ -3789,7 +3791,7 @@ class mexc(Exchange, ImplicitAPI):
3789
3791
  """
3790
3792
  return await self.modify_margin_helper(symbol, amount, 'SUB', params)
3791
3793
 
3792
- async def add_margin(self, symbol: str, amount, params={}) -> MarginModification:
3794
+ async def add_margin(self, symbol: str, amount: float, params={}) -> MarginModification:
3793
3795
  """
3794
3796
  add margin
3795
3797
  :param str symbol: unified market symbol
@@ -4557,6 +4559,8 @@ class mexc(Exchange, ImplicitAPI):
4557
4559
  return self.parse_positions(data, symbols)
4558
4560
 
4559
4561
  def parse_position(self, position, market: Market = None):
4562
+ #
4563
+ # fetchPositions
4560
4564
  #
4561
4565
  # {
4562
4566
  # "positionId": 1394650,
@@ -4581,6 +4585,40 @@ class mexc(Exchange, ImplicitAPI):
4581
4585
  # "autoAddIm": False
4582
4586
  # }
4583
4587
  #
4588
+ # fetchPositionsHistory
4589
+ #
4590
+ # {
4591
+ # positionId: '390281084',
4592
+ # symbol: 'RVN_USDT',
4593
+ # positionType: '1',
4594
+ # openType: '2',
4595
+ # state: '3',
4596
+ # holdVol: '0',
4597
+ # frozenVol: '0',
4598
+ # closeVol: '1141',
4599
+ # holdAvgPrice: '0.03491',
4600
+ # holdAvgPriceFullyScale: '0.03491',
4601
+ # openAvgPrice: '0.03491',
4602
+ # openAvgPriceFullyScale: '0.03491',
4603
+ # closeAvgPrice: '0.03494',
4604
+ # liquidatePrice: '0.03433',
4605
+ # oim: '0',
4606
+ # im: '0',
4607
+ # holdFee: '0',
4608
+ # realised: '0.1829',
4609
+ # leverage: '50',
4610
+ # createTime: '1711512408000',
4611
+ # updateTime: '1711512553000',
4612
+ # autoAddIm: False,
4613
+ # version: '4',
4614
+ # profitRatio: '0.0227',
4615
+ # newOpenAvgPrice: '0.03491',
4616
+ # newCloseAvgPrice: '0.03494',
4617
+ # closeProfitLoss: '0.3423',
4618
+ # fee: '0.1593977',
4619
+ # positionShowStatus: 'CLOSED'
4620
+ # }
4621
+ #
4584
4622
  market = self.safe_market(self.safe_string(position, 'symbol'), market)
4585
4623
  symbol = market['symbol']
4586
4624
  contracts = self.safe_string(position, 'holdVol')
@@ -4853,7 +4891,7 @@ class mexc(Exchange, ImplicitAPI):
4853
4891
  }
4854
4892
  return self.safe_string(statuses, status, status)
4855
4893
 
4856
- async def withdraw(self, code: str, amount: float, address, tag=None, params={}):
4894
+ async def withdraw(self, code: str, amount: float, address: str, tag=None, params={}):
4857
4895
  """
4858
4896
  make a withdrawal
4859
4897
  :see: https://mexcdevelop.github.io/apidocs/spot_v3_en/#withdraw
@@ -5180,6 +5218,74 @@ class mexc(Exchange, ImplicitAPI):
5180
5218
  marginMode = 'isolated'
5181
5219
  return [marginMode, params]
5182
5220
 
5221
+ async def fetch_positions_history(self, symbols: Strings = None, since: Int = None, limit: Int = None, params={}) -> List[Position]:
5222
+ """
5223
+ fetches historical positions
5224
+ :see: https://mexcdevelop.github.io/apidocs/contract_v1_en/#get-the-user-s-history-position-information
5225
+ :param str[] [symbols]: unified contract symbols
5226
+ :param int [since]: not used by mexc fetchPositionsHistory
5227
+ :param int [limit]: the maximum amount of candles to fetch, default=1000
5228
+ :param dict params: extra parameters specific to the exchange api endpoint
5229
+ *
5230
+ * EXCHANGE SPECIFIC PARAMETERS
5231
+ :param int type: position type,1: long, 2: short
5232
+ :param int page_num: current page number, default is 1
5233
+ :returns dict[]: a list of `position structures <https://docs.ccxt.com/#/?id=position-structure>`
5234
+ """
5235
+ await self.load_markets()
5236
+ request = {}
5237
+ if symbols is not None:
5238
+ symbolsLength = len(symbols)
5239
+ if symbolsLength == 1:
5240
+ market = self.market(symbols[0])
5241
+ request['symbol'] = market['id']
5242
+ if limit is not None:
5243
+ request['page_size'] = limit
5244
+ response = await self.contractPrivateGetPositionListHistoryPositions(self.extend(request, params))
5245
+ #
5246
+ # {
5247
+ # success: True,
5248
+ # code: '0',
5249
+ # data: [
5250
+ # {
5251
+ # positionId: '390281084',
5252
+ # symbol: 'RVN_USDT',
5253
+ # positionType: '1',
5254
+ # openType: '2',
5255
+ # state: '3',
5256
+ # holdVol: '0',
5257
+ # frozenVol: '0',
5258
+ # closeVol: '1141',
5259
+ # holdAvgPrice: '0.03491',
5260
+ # holdAvgPriceFullyScale: '0.03491',
5261
+ # openAvgPrice: '0.03491',
5262
+ # openAvgPriceFullyScale: '0.03491',
5263
+ # closeAvgPrice: '0.03494',
5264
+ # liquidatePrice: '0.03433',
5265
+ # oim: '0',
5266
+ # im: '0',
5267
+ # holdFee: '0',
5268
+ # realised: '0.1829',
5269
+ # leverage: '50',
5270
+ # createTime: '1711512408000',
5271
+ # updateTime: '1711512553000',
5272
+ # autoAddIm: False,
5273
+ # version: '4',
5274
+ # profitRatio: '0.0227',
5275
+ # newOpenAvgPrice: '0.03491',
5276
+ # newCloseAvgPrice: '0.03494',
5277
+ # closeProfitLoss: '0.3423',
5278
+ # fee: '0.1593977',
5279
+ # positionShowStatus: 'CLOSED'
5280
+ # },
5281
+ # ...
5282
+ # ]
5283
+ # }
5284
+ #
5285
+ data = self.safe_list(response, 'data')
5286
+ positions = self.parse_positions(data, symbols, params)
5287
+ return self.filter_by_since_limit(positions, since, limit)
5288
+
5183
5289
  def sign(self, path, api='public', method='GET', params={}, headers=None, body=None):
5184
5290
  section = self.safe_string(api, 0)
5185
5291
  access = self.safe_string(api, 1)
@@ -76,7 +76,11 @@ class ndax(Exchange, ImplicitAPI):
76
76
  'fetchOrders': True,
77
77
  'fetchOrderTrades': True,
78
78
  'fetchPosition': False,
79
+ 'fetchPositionHistory': False,
80
+ 'fetchPositionMode': False,
79
81
  'fetchPositions': False,
82
+ 'fetchPositionsForSymbol': False,
83
+ 'fetchPositionsHistory': False,
80
84
  'fetchPositionsRisk': False,
81
85
  'fetchPremiumIndexOHLCV': False,
82
86
  'fetchTicker': True,
@@ -2191,7 +2195,7 @@ class ndax(Exchange, ImplicitAPI):
2191
2195
  'network': None,
2192
2196
  }
2193
2197
 
2194
- async def withdraw(self, code: str, amount: float, address, tag=None, params={}):
2198
+ async def withdraw(self, code: str, amount: float, address: str, tag=None, params={}):
2195
2199
  """
2196
2200
  make a withdrawal
2197
2201
  :param str code: unified currency code
@@ -89,7 +89,11 @@ class novadax(Exchange, ImplicitAPI):
89
89
  'fetchOrders': True,
90
90
  'fetchOrderTrades': True,
91
91
  'fetchPosition': False,
92
+ 'fetchPositionHistory': False,
93
+ 'fetchPositionMode': False,
92
94
  'fetchPositions': False,
95
+ 'fetchPositionsForSymbol': False,
96
+ 'fetchPositionsHistory': False,
93
97
  'fetchPositionsRisk': False,
94
98
  'fetchPremiumIndexOHLCV': False,
95
99
  'fetchTicker': True,
@@ -1154,7 +1158,7 @@ class novadax(Exchange, ImplicitAPI):
1154
1158
  }
1155
1159
  return self.safe_string(statuses, status, 'failed')
1156
1160
 
1157
- async def withdraw(self, code: str, amount: float, address, tag=None, params={}):
1161
+ async def withdraw(self, code: str, amount: float, address: str, tag=None, params={}):
1158
1162
  """
1159
1163
  make a withdrawal
1160
1164
  :see: https://doc.novadax.com/en-US/#send-cryptocurrencies
@@ -2309,7 +2309,7 @@ class okcoin(Exchange, ImplicitAPI):
2309
2309
  }
2310
2310
  return self.safe_string(statuses, status, status)
2311
2311
 
2312
- async def withdraw(self, code: str, amount: float, address, tag=None, params={}):
2312
+ async def withdraw(self, code: str, amount: float, address: str, tag=None, params={}):
2313
2313
  """
2314
2314
  :see: https://www.okcoin.com/docs-v5/en/#rest-api-funding-withdrawal
2315
2315
  make a withdrawal
ccxt/async_support/okx.py CHANGED
@@ -7,7 +7,7 @@ from ccxt.async_support.base.exchange import Exchange
7
7
  from ccxt.abstract.okx import ImplicitAPI
8
8
  import asyncio
9
9
  import hashlib
10
- from ccxt.base.types import Account, Balances, Conversion, Currencies, Currency, Greeks, Int, Leverage, MarginModification, Market, MarketInterface, Num, Option, OptionChain, Order, OrderBook, OrderRequest, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, TradingFeeInterface, Transaction, TransferEntry
10
+ from ccxt.base.types import Account, Balances, Conversion, Currencies, Currency, Greeks, Int, Leverage, MarginModification, Market, MarketInterface, Num, Option, OptionChain, Order, OrderBook, OrderRequest, CancellationRequest, OrderSide, OrderType, Position, Str, Strings, Ticker, Tickers, Trade, TradingFeeInterface, Transaction, TransferEntry
11
11
  from typing import List
12
12
  from typing import Any
13
13
  from ccxt.base.errors import ExchangeError
@@ -55,8 +55,10 @@ class okx(Exchange, ImplicitAPI):
55
55
  'option': True,
56
56
  'addMargin': True,
57
57
  'cancelAllOrders': False,
58
+ 'cancelAllOrdersAfter': True,
58
59
  'cancelOrder': True,
59
60
  'cancelOrders': True,
61
+ 'cancelOrdersForSymbols': True,
60
62
  'closeAllPositions': False,
61
63
  'closePosition': True,
62
64
  'createConvertTrade': True,
@@ -133,8 +135,10 @@ class okx(Exchange, ImplicitAPI):
133
135
  'fetchOrderTrades': True,
134
136
  'fetchPermissions': None,
135
137
  'fetchPosition': True,
138
+ 'fetchPositionHistory': 'emulated',
136
139
  'fetchPositions': True,
137
140
  'fetchPositionsForSymbol': True,
141
+ 'fetchPositionsHistory': True,
138
142
  'fetchPositionsRisk': False,
139
143
  'fetchPremiumIndexOHLCV': False,
140
144
  'fetchSettlementHistory': True,
@@ -3084,6 +3088,107 @@ class okx(Exchange, ImplicitAPI):
3084
3088
  ordersData = self.safe_list(response, 'data', [])
3085
3089
  return self.parse_orders(ordersData, market, None, None, params)
3086
3090
 
3091
+ async def cancel_orders_for_symbols(self, orders: List[CancellationRequest], params={}):
3092
+ """
3093
+ cancel multiple orders for multiple symbols
3094
+ :see: https://www.okx.com/docs-v5/en/#order-book-trading-trade-post-cancel-multiple-orders
3095
+ :see: https://www.okx.com/docs-v5/en/#order-book-trading-algo-trading-post-cancel-algo-order
3096
+ :param CancellationRequest[] orders: each order should contain the parameters required by cancelOrder namely id and symbol
3097
+ :param dict [params]: extra parameters specific to the exchange API endpoint
3098
+ :param boolean [params.trigger]: whether the order is a stop/trigger order
3099
+ :param boolean [params.trailing]: set to True if you want to cancel trailing orders
3100
+ :returns dict: an list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
3101
+ """
3102
+ await self.load_markets()
3103
+ request = []
3104
+ options = self.safe_dict(self.options, 'cancelOrders', {})
3105
+ defaultMethod = self.safe_string(options, 'method', 'privatePostTradeCancelBatchOrders')
3106
+ method = self.safe_string(params, 'method', defaultMethod)
3107
+ stop = self.safe_bool_2(params, 'stop', 'trigger')
3108
+ trailing = self.safe_bool(params, 'trailing', False)
3109
+ isStopOrTrailing = stop or trailing
3110
+ if isStopOrTrailing:
3111
+ method = 'privatePostTradeCancelAlgos'
3112
+ for i in range(0, len(orders)):
3113
+ order = orders[i]
3114
+ id = self.safe_string(order, 'id')
3115
+ clientOrderId = self.safe_string_2(order, 'clOrdId', 'clientOrderId')
3116
+ symbol = self.safe_string(order, 'symbol')
3117
+ market = self.market(symbol)
3118
+ idKey = 'ordId'
3119
+ if isStopOrTrailing:
3120
+ idKey = 'algoId'
3121
+ elif clientOrderId is not None:
3122
+ idKey = 'clOrdId'
3123
+ requestItem = {
3124
+ 'instId': market['id'],
3125
+ }
3126
+ requestItem[idKey] = clientOrderId if (clientOrderId is not None) else id
3127
+ request.append(requestItem)
3128
+ response = None
3129
+ if method == 'privatePostTradeCancelAlgos':
3130
+ response = await self.privatePostTradeCancelAlgos(request) # * dont self.extend with params, otherwise ARRAY will be turned into OBJECT
3131
+ else:
3132
+ response = await self.privatePostTradeCancelBatchOrders(request) # * dont self.extend with params, otherwise ARRAY will be turned into OBJECT
3133
+ #
3134
+ # {
3135
+ # "code": "0",
3136
+ # "data": [
3137
+ # {
3138
+ # "clOrdId": "e123456789ec4dBC1123456ba123b45e",
3139
+ # "ordId": "405071912345641543",
3140
+ # "sCode": "0",
3141
+ # "sMsg": ""
3142
+ # },
3143
+ # ...
3144
+ # ],
3145
+ # "msg": ""
3146
+ # }
3147
+ #
3148
+ # Algo order
3149
+ #
3150
+ # {
3151
+ # "code": "0",
3152
+ # "data": [
3153
+ # {
3154
+ # "algoId": "431375349042380800",
3155
+ # "sCode": "0",
3156
+ # "sMsg": ""
3157
+ # }
3158
+ # ],
3159
+ # "msg": ""
3160
+ # }
3161
+ #
3162
+ ordersData = self.safe_list(response, 'data', [])
3163
+ return self.parse_orders(ordersData, None, None, None, params)
3164
+
3165
+ async def cancel_all_orders_after(self, timeout: Int, params={}):
3166
+ """
3167
+ dead man's switch, cancel all orders after the given timeout
3168
+ :see: https://www.okx.com/docs-v5/en/#order-book-trading-trade-post-cancel-all-after
3169
+ :param number timeout: time in milliseconds, 0 represents cancel the timer
3170
+ :param dict [params]: extra parameters specific to the exchange API endpoint
3171
+ :returns dict: the api result
3172
+ """
3173
+ await self.load_markets()
3174
+ request: dict = {
3175
+ 'timeOut': self.parse_to_int(timeout / 1000) if (timeout > 0) else 0,
3176
+ }
3177
+ response = await self.privatePostTradeCancelAllAfter(self.extend(request, params))
3178
+ #
3179
+ # {
3180
+ # "code":"0",
3181
+ # "msg":"",
3182
+ # "data":[
3183
+ # {
3184
+ # "triggerTime":"1587971460",
3185
+ # "ts":"1587971400"
3186
+ # }
3187
+ # ]
3188
+ # }
3189
+ #
3190
+ return response
3191
+
3087
3192
  def parse_order_status(self, status):
3088
3193
  statuses = {
3089
3194
  'canceled': 'canceled',
@@ -4398,7 +4503,7 @@ class okx(Exchange, ImplicitAPI):
4398
4503
  raise InvalidAddress(self.id + ' fetchDepositAddress() cannot find ' + network + ' deposit address for ' + code)
4399
4504
  return result
4400
4505
 
4401
- async def withdraw(self, code: str, amount: float, address, tag=None, params={}):
4506
+ async def withdraw(self, code: str, amount: float, address: str, tag=None, params={}):
4402
4507
  """
4403
4508
  make a withdrawal
4404
4509
  :see: https://www.okx.com/docs-v5/en/#funding-account-rest-api-withdrawal
@@ -6122,7 +6227,7 @@ class okx(Exchange, ImplicitAPI):
6122
6227
  'datetime': self.iso8601(timestamp),
6123
6228
  }
6124
6229
 
6125
- async def reduce_margin(self, symbol: str, amount, params={}) -> MarginModification:
6230
+ async def reduce_margin(self, symbol: str, amount: float, params={}) -> MarginModification:
6126
6231
  """
6127
6232
  remove margin from a position
6128
6233
  :see: https://www.okx.com/docs-v5/en/#trading-account-rest-api-increase-decrease-margin
@@ -6133,7 +6238,7 @@ class okx(Exchange, ImplicitAPI):
6133
6238
  """
6134
6239
  return await self.modify_margin_helper(symbol, amount, 'reduce', params)
6135
6240
 
6136
- async def add_margin(self, symbol: str, amount, params={}) -> MarginModification:
6241
+ async def add_margin(self, symbol: str, amount: float, params={}) -> MarginModification:
6137
6242
  """
6138
6243
  add margin
6139
6244
  :see: https://www.okx.com/docs-v5/en/#trading-account-rest-api-increase-decrease-margin
@@ -7550,3 +7655,77 @@ class okx(Exchange, ImplicitAPI):
7550
7655
  data = self.safe_list(response, 'data')
7551
7656
  modifications = self.parse_margin_modifications(data)
7552
7657
  return self.filter_by_symbol_since_limit(modifications, symbol, since, limit)
7658
+
7659
+ async def fetch_positions_history(self, symbols: Strings = None, since: Int = None, limit: Int = None, params={}) -> List[Position]:
7660
+ """
7661
+ fetches historical positions
7662
+ :see: https://www.okx.com/docs-v5/en/#trading-account-rest-api-get-positions-history
7663
+ :param str [symbols]: unified market symbols
7664
+ :param int [since]: timestamp in ms of the earliest position to fetch
7665
+ :param int [limit]: the maximum amount of records to fetch, default=100, max=100
7666
+ :param dict params: extra parameters specific to the exchange api endpoint
7667
+ :param str [params.marginMode]: "cross" or "isolated"
7668
+ *
7669
+ * EXCHANGE SPECIFIC PARAMETERS
7670
+ :param str [params.instType]: margin, swap, futures or option
7671
+ :param str [params.type]: the type of latest close position 1: close position partially, 2:close all, 3:liquidation, 4:partial liquidation; 5:adl, is it is the latest type if there are several types for the same position
7672
+ :param str [params.posId]: position id, there is attribute expiration, the posid will be expired if it is more than 30 days after the last full close position, then position will use new posid
7673
+ :param str [params.before]: timestamp in ms of the earliest position to fetch based on the last update time of the position
7674
+ :param str [params.after]: timestamp in ms of the latest position to fetch based on the last update time of the position
7675
+ :returns dict[]: a list of `position structures <https://docs.ccxt.com/#/?id=position-structure>`
7676
+ """
7677
+ await self.load_markets()
7678
+ marginMode = self.safe_string(params, 'marginMode')
7679
+ instType = self.safe_string_upper(params, 'instType')
7680
+ params = self.omit(params, ['until', 'marginMode', 'instType'])
7681
+ if limit is None:
7682
+ limit = 100
7683
+ request = {
7684
+ 'limit': limit,
7685
+ }
7686
+ if symbols is not None:
7687
+ symbolsLength = len(symbols)
7688
+ if symbolsLength == 1:
7689
+ market = self.market(symbols[0])
7690
+ request['instId'] = market['id']
7691
+ if marginMode is not None:
7692
+ request['mgnMode'] = marginMode
7693
+ if instType is not None:
7694
+ request['instType'] = instType
7695
+ response = await self.privateGetAccountPositionsHistory(self.extend(request, params))
7696
+ #
7697
+ # {
7698
+ # code: '0',
7699
+ # data: [
7700
+ # {
7701
+ # cTime: '1708735940395',
7702
+ # ccy: 'USDT',
7703
+ # closeAvgPx: '0.6330444444444444',
7704
+ # closeTotalPos: '27',
7705
+ # direction: 'long',
7706
+ # fee: '-1.69566',
7707
+ # fundingFee: '-11.870404179341788',
7708
+ # instId: 'XRP-USDT-SWAP',
7709
+ # instType: 'SWAP',
7710
+ # lever: '3.0',
7711
+ # liqPenalty: '0',
7712
+ # mgnMode: 'cross',
7713
+ # openAvgPx: '0.623',
7714
+ # openMaxPos: '15',
7715
+ # pnl: '27.11999999999988',
7716
+ # pnlRatio: '0.0241732402722634',
7717
+ # posId: '681423155054862336',
7718
+ # realizedPnl: '13.553935820658092',
7719
+ # triggerPx: '',
7720
+ # type: '2',
7721
+ # uTime: '1711088748170',
7722
+ # uly: 'XRP-USDT'
7723
+ # },
7724
+ # ...
7725
+ # ],
7726
+ # msg: ''
7727
+ # }
7728
+ #
7729
+ data = self.safe_list(response, 'data')
7730
+ positions = self.parse_positions(data, symbols, params)
7731
+ return self.filter_by_since_limit(positions, since, limit)
@@ -86,8 +86,11 @@ class onetrading(Exchange, ImplicitAPI):
86
86
  'fetchOrders': False,
87
87
  'fetchOrderTrades': True,
88
88
  'fetchPosition': False,
89
+ 'fetchPositionHistory': False,
89
90
  'fetchPositionMode': False,
90
91
  'fetchPositions': False,
92
+ 'fetchPositionsForSymbol': False,
93
+ 'fetchPositionsHistory': False,
91
94
  'fetchPositionsRisk': False,
92
95
  'fetchPremiumIndexOHLCV': False,
93
96
  'fetchTicker': True,
@@ -1179,7 +1182,7 @@ class onetrading(Exchange, ImplicitAPI):
1179
1182
  withdrawalHistory = self.safe_list(response, 'withdrawal_history', [])
1180
1183
  return self.parse_transactions(withdrawalHistory, currency, since, limit, {'type': 'withdrawal'})
1181
1184
 
1182
- async def withdraw(self, code: str, amount: float, address, tag=None, params={}):
1185
+ async def withdraw(self, code: str, amount: float, address: str, tag=None, params={}):
1183
1186
  """
1184
1187
  make a withdrawal
1185
1188
  :param str code: unified currency code
ccxt/async_support/p2b.py CHANGED
@@ -85,8 +85,11 @@ class p2b(Exchange, ImplicitAPI):
85
85
  'fetchOrderTrades': True,
86
86
  'fetchPermissions': False,
87
87
  'fetchPosition': False,
88
+ 'fetchPositionHistory': False,
89
+ 'fetchPositionMode': False,
88
90
  'fetchPositions': False,
89
91
  'fetchPositionsForSymbol': False,
92
+ 'fetchPositionsHistory': False,
90
93
  'fetchPositionsRisk': False,
91
94
  'fetchPremiumIndexOHLCV': False,
92
95
  'fetchTicker': True,
@@ -4319,7 +4319,7 @@ class phemex(Exchange, ImplicitAPI):
4319
4319
  sorted = self.sort_by(result, 'timestamp')
4320
4320
  return self.filter_by_symbol_since_limit(sorted, symbol, since, limit)
4321
4321
 
4322
- async def withdraw(self, code: str, amount: float, address, tag=None, params={}):
4322
+ async def withdraw(self, code: str, amount: float, address: str, tag=None, params={}):
4323
4323
  """
4324
4324
  make a withdrawal
4325
4325
  :see: https://phemex-docs.github.io/#create-withdraw-request
@@ -1787,7 +1787,7 @@ class poloniex(Exchange, ImplicitAPI):
1787
1787
  'status': None,
1788
1788
  }
1789
1789
 
1790
- async def withdraw(self, code: str, amount: float, address, tag=None, params={}):
1790
+ async def withdraw(self, code: str, amount: float, address: str, tag=None, params={}):
1791
1791
  """
1792
1792
  make a withdrawal
1793
1793
  :see: https://docs.poloniex.com/#authenticated-endpoints-wallets-withdraw-currency