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
@@ -6,7 +6,7 @@
6
6
  from ccxt.async_support.base.exchange import Exchange
7
7
  from ccxt.abstract.coinex import ImplicitAPI
8
8
  import asyncio
9
- from ccxt.base.types import Balances, Currencies, Currency, Int, Leverage, Leverages, MarginModification, Market, Num, Order, OrderRequest, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, TradingFeeInterface, TradingFees, Transaction, TransferEntry
9
+ from ccxt.base.types import Balances, Currencies, Currency, Int, Leverage, Leverages, MarginModification, Market, Num, Order, 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
@@ -103,7 +103,9 @@ class coinex(Exchange, ImplicitAPI):
103
103
  'fetchOrder': True,
104
104
  'fetchOrderBook': True,
105
105
  'fetchPosition': True,
106
+ 'fetchPositionHistory': True,
106
107
  'fetchPositions': True,
108
+ 'fetchPositionsHistory': False,
107
109
  'fetchPositionsRisk': False,
108
110
  'fetchPremiumIndexOHLCV': False,
109
111
  'fetchTicker': True,
@@ -1116,14 +1118,13 @@ class coinex(Exchange, ImplicitAPI):
1116
1118
  #
1117
1119
  # Spot and Swap fetchTrades(public)
1118
1120
  #
1119
- # {
1120
- # "id": 2611511379,
1121
- # "type": "buy",
1122
- # "price": "192.63",
1123
- # "amount": "0.02266931",
1124
- # "date": 1638990110,
1125
- # "date_ms": 1638990110518
1126
- # },
1121
+ # {
1122
+ # "amount": "0.00049432",
1123
+ # "created_at": 1713849825667,
1124
+ # "deal_id": 4137517302,
1125
+ # "price": "66251",
1126
+ # "side": "buy"
1127
+ # }
1127
1128
  #
1128
1129
  # Spot and Margin fetchMyTrades(private)
1129
1130
  #
@@ -1177,8 +1178,8 @@ class coinex(Exchange, ImplicitAPI):
1177
1178
  #
1178
1179
  timestamp = self.safe_timestamp_2(trade, 'create_time', 'time')
1179
1180
  if timestamp is None:
1180
- timestamp = self.safe_integer(trade, 'date_ms')
1181
- tradeId = self.safe_string(trade, 'id')
1181
+ timestamp = self.safe_integer(trade, 'created_at')
1182
+ tradeId = self.safe_string_2(trade, 'id', 'deal_id')
1182
1183
  orderId = self.safe_string(trade, 'order_id')
1183
1184
  priceString = self.safe_string(trade, 'price')
1184
1185
  amountString = self.safe_string(trade, 'amount')
@@ -1210,9 +1211,9 @@ class coinex(Exchange, ImplicitAPI):
1210
1211
  elif rawSide == 2:
1211
1212
  side = 'buy'
1212
1213
  if side is None:
1213
- side = self.safe_string(trade, 'type')
1214
+ side = self.safe_string_2(trade, 'type', 'side')
1214
1215
  else:
1215
- side = self.safe_string(trade, 'type')
1216
+ side = self.safe_string_2(trade, 'type', 'side')
1216
1217
  return self.safe_trade({
1217
1218
  'info': trade,
1218
1219
  'timestamp': timestamp,
@@ -1231,9 +1232,9 @@ class coinex(Exchange, ImplicitAPI):
1231
1232
 
1232
1233
  async def fetch_trades(self, symbol: str, since: Int = None, limit: Int = None, params={}) -> List[Trade]:
1233
1234
  """
1234
- get the list of most recent trades for a particular symbol
1235
- :see: https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot001_market005_market_deals
1236
- :see: https://viabtc.github.io/coinex_api_en_doc/futures/#docsfutures001_http011_market_deals
1235
+ get the list of the most recent trades for a particular symbol
1236
+ :see: https://docs.coinex.com/api/v2/spot/market/http/list-market-deals
1237
+ :see: https://docs.coinex.com/api/v2/futures/market/http/list-market-deals
1237
1238
  :param str symbol: unified symbol of the market to fetch trades for
1238
1239
  :param int [since]: timestamp in ms of the earliest trade to fetch
1239
1240
  :param int [limit]: the maximum amount of trades to fetch
@@ -1250,26 +1251,25 @@ class coinex(Exchange, ImplicitAPI):
1250
1251
  request['limit'] = limit
1251
1252
  response = None
1252
1253
  if market['swap']:
1253
- response = await self.v1PerpetualPublicGetMarketDeals(self.extend(request, params))
1254
+ response = await self.v2PublicGetFuturesDeals(self.extend(request, params))
1254
1255
  else:
1255
- response = await self.v1PublicGetMarketDeals(self.extend(request, params))
1256
+ response = await self.v2PublicGetSpotDeals(self.extend(request, params))
1256
1257
  #
1257
1258
  # Spot and Swap
1258
1259
  #
1259
- # {
1260
- # "code": 0,
1261
- # "data": [
1262
- # {
1263
- # "id": 2611511379,
1264
- # "type": "buy",
1265
- # "price": "192.63",
1266
- # "amount": "0.02266931",
1267
- # "date": 1638990110,
1268
- # "date_ms": 1638990110518
1269
- # },
1270
- # ],
1271
- # "message": "OK"
1272
- # }
1260
+ # {
1261
+ # "code": 0,
1262
+ # "data": [
1263
+ # {
1264
+ # "amount": "0.00049432",
1265
+ # "created_at": 1713849825667,
1266
+ # "deal_id": 4137517302,
1267
+ # "price": "66251",
1268
+ # "side": "buy"
1269
+ # },
1270
+ # ],
1271
+ # "message": "OK"
1272
+ # }
1273
1273
  #
1274
1274
  return self.parse_trades(response['data'], market, since, limit)
1275
1275
 
@@ -1418,31 +1418,31 @@ class coinex(Exchange, ImplicitAPI):
1418
1418
 
1419
1419
  def parse_ohlcv(self, ohlcv, market: Market = None) -> list:
1420
1420
  #
1421
- # [
1422
- # 1591484400,
1423
- # "0.02505349",
1424
- # "0.02506988",
1425
- # "0.02507000",
1426
- # "0.02505304",
1427
- # "343.19716223",
1428
- # "8.6021323866383196",
1429
- # "ETHBTC"
1430
- # ]
1421
+ # {
1422
+ # "close": "66999.95",
1423
+ # "created_at": 1713934620000,
1424
+ # "high": "66999.95",
1425
+ # "low": "66988.53",
1426
+ # "market": "BTCUSDT",
1427
+ # "open": "66988.53",
1428
+ # "value": "0.1572393", # base volume
1429
+ # "volume": "10533.2501364336" # quote volume
1430
+ # }
1431
1431
  #
1432
1432
  return [
1433
- self.safe_timestamp(ohlcv, 0),
1434
- self.safe_number(ohlcv, 1),
1435
- self.safe_number(ohlcv, 3),
1436
- self.safe_number(ohlcv, 4),
1437
- self.safe_number(ohlcv, 2),
1438
- self.safe_number(ohlcv, 5),
1433
+ self.safe_integer(ohlcv, 'created_at'),
1434
+ self.safe_number(ohlcv, 'open'),
1435
+ self.safe_number(ohlcv, 'high'),
1436
+ self.safe_number(ohlcv, 'low'),
1437
+ self.safe_number(ohlcv, 'close'),
1438
+ self.safe_number(ohlcv, 'value'),
1439
1439
  ]
1440
1440
 
1441
1441
  async def fetch_ohlcv(self, symbol: str, timeframe='1m', since: Int = None, limit: Int = None, params={}) -> List[list]:
1442
1442
  """
1443
1443
  fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
1444
- :see: https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot001_market006_market_kline
1445
- :see: https://viabtc.github.io/coinex_api_en_doc/futures/#docsfutures001_http012_market_kline
1444
+ :see: https://docs.coinex.com/api/v2/spot/market/http/list-market-kline
1445
+ :see: https://docs.coinex.com/api/v2/futures/market/http/list-market-kline
1446
1446
  :param str symbol: unified symbol of the market to fetch OHLCV data for
1447
1447
  :param str timeframe: the length of time each candle represents
1448
1448
  :param int [since]: timestamp in ms of the earliest candle to fetch
@@ -1454,36 +1454,31 @@ class coinex(Exchange, ImplicitAPI):
1454
1454
  market = self.market(symbol)
1455
1455
  request = {
1456
1456
  'market': market['id'],
1457
- 'type': self.safe_string(self.timeframes, timeframe, timeframe),
1457
+ 'period': self.safe_string(self.timeframes, timeframe, timeframe),
1458
1458
  }
1459
1459
  if limit is not None:
1460
1460
  request['limit'] = limit
1461
1461
  response = None
1462
1462
  if market['swap']:
1463
- response = await self.v1PerpetualPublicGetMarketKline(self.extend(request, params))
1463
+ response = await self.v2PublicGetFuturesKline(self.extend(request, params))
1464
1464
  else:
1465
- response = await self.v1PublicGetMarketKline(self.extend(request, params))
1465
+ response = await self.v2PublicGetSpotKline(self.extend(request, params))
1466
1466
  #
1467
- # Spot
1468
- #
1469
- # {
1470
- # "code": 0,
1471
- # "data": [
1472
- # [1591484400, "0.02505349", "0.02506988", "0.02507000", "0.02505304", "343.19716223", "8.6021323866383196", "ETHBTC"],
1473
- # [1591484700, "0.02506990", "0.02508109", "0.02508109", "0.02506979", "91.59841581", "2.2972047780447000", "ETHBTC"],
1474
- # [1591485000, "0.02508106", "0.02507996", "0.02508106", "0.02507500", "65.15307697", "1.6340597822306000", "ETHBTC"],
1475
- # ],
1476
- # "message": "OK"
1477
- # }
1478
- #
1479
- # Swap
1467
+ # Spot and Swap
1480
1468
  #
1481
1469
  # {
1482
1470
  # "code": 0,
1483
1471
  # "data": [
1484
- # [1650569400, "41524.64", "41489.31", "41564.61", "41480.58", "29.7060", "1233907.099562"],
1485
- # [1650569700, "41489.31", "41438.29", "41489.31", "41391.87", "42.4115", "1756154.189061"],
1486
- # [1650570000, "41438.29", "41482.21", "41485.05", "41427.31", "22.2892", "924000.317861"]
1472
+ # {
1473
+ # "close": "66999.95",
1474
+ # "created_at": 1713934620000,
1475
+ # "high": "66999.95",
1476
+ # "low": "66988.53",
1477
+ # "market": "BTCUSDT",
1478
+ # "open": "66988.53",
1479
+ # "value": "0.1572393",
1480
+ # "volume": "10533.2501364336"
1481
+ # },
1487
1482
  # ],
1488
1483
  # "message": "OK"
1489
1484
  # }
@@ -3521,7 +3516,7 @@ class coinex(Exchange, ImplicitAPI):
3521
3516
  # "side": 2,
3522
3517
  # "stop_loss_price": "0.00000000000000000000",
3523
3518
  # "stop_loss_type": 0,
3524
- # "sys": 0,
3519
+ # "sy s": 0,
3525
3520
  # "take_profit_price": "0.00000000000000000000",
3526
3521
  # "take_profit_type": 0,
3527
3522
  # "taker_fee": "0.00000000000000000000",
@@ -3600,7 +3595,7 @@ class coinex(Exchange, ImplicitAPI):
3600
3595
  # "side": 2,
3601
3596
  # "stop_loss_price": "0.00000000000000000000",
3602
3597
  # "stop_loss_type": 0,
3603
- # "sys": 0,
3598
+ # "s ys": 0,
3604
3599
  # "take_profit_price": "0.00000000000000000000",
3605
3600
  # "take_profit_type": 0,
3606
3601
  # "taker_fee": "0.00000000000000000000",
@@ -3617,6 +3612,8 @@ class coinex(Exchange, ImplicitAPI):
3617
3612
  return self.parse_position(data[0], market)
3618
3613
 
3619
3614
  def parse_position(self, position, market: Market = None):
3615
+ #
3616
+ # fetchPosition
3620
3617
  #
3621
3618
  # {
3622
3619
  # "adl_sort": 3396,
@@ -3660,7 +3657,7 @@ class coinex(Exchange, ImplicitAPI):
3660
3657
  # "side": 2,
3661
3658
  # "stop_loss_price": "0.00000000000000000000",
3662
3659
  # "stop_loss_type": 0,
3663
- # "sys": 0,
3660
+ # "s ys": 0,
3664
3661
  # "take_profit_price": "0.00000000000000000000",
3665
3662
  # "take_profit_type": 0,
3666
3663
  # "taker_fee": "0.00000000000000000000",
@@ -3670,6 +3667,40 @@ class coinex(Exchange, ImplicitAPI):
3670
3667
  # "user_id": 3620173
3671
3668
  # }
3672
3669
  #
3670
+ #
3671
+ # fetchPositionHistory
3672
+ #
3673
+ # {
3674
+ # amount_max: '10',
3675
+ # amount_max_margin: '2.03466666666666666666',
3676
+ # bkr_price: '0',
3677
+ # create_time: '1711150526.2581',
3678
+ # deal_all: '12.591',
3679
+ # deal_asset_fee: '0',
3680
+ # fee_asset: '',
3681
+ # finish_type: '5',
3682
+ # first_price: '0.6104',
3683
+ # latest_price: '0.6487',
3684
+ # leverage: '3',
3685
+ # liq_amount: '0',
3686
+ # liq_price: '0',
3687
+ # liq_profit: '0',
3688
+ # mainten_margin: '0.01',
3689
+ # market: 'XRPUSDT',
3690
+ # market_type: '1',
3691
+ # open_price: '0.6104',
3692
+ # open_val_max: '6.104',
3693
+ # position_id: '297371462',
3694
+ # profit_real: '0.35702107169',
3695
+ # settle_price: '0.6104',
3696
+ # settle_val: '0',
3697
+ # side: '2',
3698
+ # s ys: "0",
3699
+ # type: '2',
3700
+ # update_time: '1711391446.133233',
3701
+ # user_id: '3685860'
3702
+ # }
3703
+ #
3673
3704
  marketId = self.safe_string(position, 'market')
3674
3705
  market = self.safe_market(marketId, market, None, 'swap')
3675
3706
  symbol = market['symbol']
@@ -3685,7 +3716,7 @@ class coinex(Exchange, ImplicitAPI):
3685
3716
  timestamp = self.safe_timestamp(position, 'update_time')
3686
3717
  maintenanceMargin = self.safe_string(position, 'mainten_margin_amount')
3687
3718
  maintenanceMarginPercentage = self.safe_string(position, 'mainten_margin')
3688
- collateral = self.safe_string(position, 'margin_amount')
3719
+ collateral = self.safe_string_2(position, 'margin_amount', 'amount_max_margin')
3689
3720
  leverage = self.safe_string(position, 'leverage')
3690
3721
  notional = self.safe_string(position, 'open_val')
3691
3722
  initialMargin = Precise.string_div(notional, leverage)
@@ -3895,7 +3926,7 @@ class coinex(Exchange, ImplicitAPI):
3895
3926
  # "side": 2,
3896
3927
  # "stop_loss_price": "0.00000000000000000000",
3897
3928
  # "stop_loss_type": 0,
3898
- # "sys": 0,
3929
+ # "s ys": 0,
3899
3930
  # "take_profit_price": "0.00000000000000000000",
3900
3931
  # "take_profit_type": 0,
3901
3932
  # "taker_fee": "0.00000000000000000000",
@@ -3960,7 +3991,7 @@ class coinex(Exchange, ImplicitAPI):
3960
3991
  # "side": 2,
3961
3992
  # "stop_loss_price": "0.00000000000000000000",
3962
3993
  # "stop_loss_type": 0,
3963
- # "sys": 0,
3994
+ # "sy s": 0,
3964
3995
  # "take_profit_price": "0.00000000000000000000",
3965
3996
  # "take_profit_type": 0,
3966
3997
  # "taker_fee": "0.00000000000000000000",
@@ -4004,7 +4035,7 @@ class coinex(Exchange, ImplicitAPI):
4004
4035
  'datetime': self.iso8601(timestamp),
4005
4036
  }
4006
4037
 
4007
- async def add_margin(self, symbol: str, amount, params={}) -> MarginModification:
4038
+ async def add_margin(self, symbol: str, amount: float, params={}) -> MarginModification:
4008
4039
  """
4009
4040
  add margin
4010
4041
  :see: https://viabtc.github.io/coinex_api_en_doc/futures/#docsfutures001_http032_adjust_position_margin
@@ -4015,7 +4046,7 @@ class coinex(Exchange, ImplicitAPI):
4015
4046
  """
4016
4047
  return await self.modify_margin_helper(symbol, amount, 1, params)
4017
4048
 
4018
- async def reduce_margin(self, symbol: str, amount, params={}) -> MarginModification:
4049
+ async def reduce_margin(self, symbol: str, amount: float, params={}) -> MarginModification:
4019
4050
  """
4020
4051
  remove margin from a position
4021
4052
  :see: https://viabtc.github.io/coinex_api_en_doc/futures/#docsfutures001_http032_adjust_position_margin
@@ -4205,7 +4236,6 @@ class coinex(Exchange, ImplicitAPI):
4205
4236
 
4206
4237
  async def fetch_funding_rates(self, symbols: Strings = None, params={}):
4207
4238
  """
4208
- * @method
4209
4239
  fetch the current funding rates
4210
4240
  :see: https://viabtc.github.io/coinex_api_en_doc/futures/#docsfutures001_http009_market_ticker_all
4211
4241
  :param str[] symbols: unified market symbols
@@ -4268,7 +4298,7 @@ class coinex(Exchange, ImplicitAPI):
4268
4298
  result.append(self.parse_funding_rate(ticker, marketInner))
4269
4299
  return self.filter_by_array(result, 'symbol', symbols)
4270
4300
 
4271
- async def withdraw(self, code: str, amount: float, address, tag=None, params={}):
4301
+ async def withdraw(self, code: str, amount: float, address: str, tag=None, params={}):
4272
4302
  """
4273
4303
  make a withdrawal
4274
4304
  :see: https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot002_account015_submit_withdraw
@@ -5255,6 +5285,77 @@ class coinex(Exchange, ImplicitAPI):
5255
5285
  'shortLeverage': leverageValue,
5256
5286
  }
5257
5287
 
5288
+ async def fetch_position_history(self, symbol: str, since: Int = None, limit: Int = None, params={}) -> Position:
5289
+ """
5290
+ fetches historical positions
5291
+ :see: https://viabtc.github.io/coinex_api_en_doc/futures/#docsfutures001_http033-0_finished_position
5292
+ :param str symbol: unified contract symbol
5293
+ :param int [since]: not used by coinex fetchPositionHistory
5294
+ :param int [limit]: the maximum amount of records to fetch, default=1000
5295
+ :param dict params: extra parameters specific to the exchange api endpoint
5296
+ *
5297
+ * EXCHANGE SPECIFIC PARAMETERS
5298
+ :param int [params.side]: 0: all 1: sell, 2: buy
5299
+ :returns dict[]: a list of `position structures <https://docs.ccxt.com/#/?id=position-structure>`
5300
+ """
5301
+ await self.load_markets()
5302
+ market = self.market(symbol)
5303
+ if limit is None:
5304
+ limit = 1000
5305
+ request = {
5306
+ 'market': market['id'],
5307
+ 'side': 0,
5308
+ 'limit': limit,
5309
+ }
5310
+ response = await self.v1PerpetualPrivateGetPositionFinished(self.extend(request, params))
5311
+ #
5312
+ # {
5313
+ # code: '0',
5314
+ # data: {
5315
+ # limit: '1000',
5316
+ # offset: '0',
5317
+ # records: [
5318
+ # {
5319
+ # amount_max: '10',
5320
+ # amount_max_margin: '2.03466666666666666666',
5321
+ # bkr_price: '0',
5322
+ # create_time: '1711150526.2581',
5323
+ # deal_all: '12.591',
5324
+ # deal_asset_fee: '0',
5325
+ # fee_asset: '',
5326
+ # finish_type: '5',
5327
+ # first_price: '0.6104',
5328
+ # latest_price: '0.6487',
5329
+ # leverage: '3',
5330
+ # liq_amount: '0',
5331
+ # liq_price: '0',
5332
+ # liq_profit: '0',
5333
+ # mainten_margin: '0.01',
5334
+ # market: 'XRPUSDT',
5335
+ # market_type: '1',
5336
+ # open_price: '0.6104',
5337
+ # open_val_max: '6.104',
5338
+ # position_id: '297371462',
5339
+ # profit_real: '0.35702107169',
5340
+ # settle_price: '0.6104',
5341
+ # settle_val: '0',
5342
+ # side: '2',
5343
+ # sy s: '0',
5344
+ # type: '2',
5345
+ # update_time: '1711391446.133233',
5346
+ # user_id: '3685860'
5347
+ # },
5348
+ # ...
5349
+ # ]
5350
+ # },
5351
+ # message: 'OK'
5352
+ # }
5353
+ #
5354
+ data = self.safe_dict(response, 'data')
5355
+ records = self.safe_list(data, 'records')
5356
+ positions = self.parse_positions(records)
5357
+ return self.filter_by_symbol_since_limit(positions, symbol, since, limit)
5358
+
5258
5359
  def handle_margin_mode_and_params(self, methodName, params={}, defaultValue=None):
5259
5360
  """
5260
5361
  * @ignore
@@ -103,7 +103,11 @@ class coinlist(Exchange, ImplicitAPI):
103
103
  'fetchOrders': True,
104
104
  'fetchOrderTrades': True,
105
105
  'fetchPosition': False,
106
+ 'fetchPositionHistory': False,
107
+ 'fetchPositionMode': False,
106
108
  'fetchPositions': False,
109
+ 'fetchPositionsForSymbol': False,
110
+ 'fetchPositionsHistory': False,
107
111
  'fetchPositionsRisk': False,
108
112
  'fetchPremiumIndexOHLCV': False,
109
113
  'fetchStatus': False,
@@ -1865,7 +1869,7 @@ class coinlist(Exchange, ImplicitAPI):
1865
1869
  # coinlist returns both internal transfers and blockchain transactions
1866
1870
  return self.parse_transactions(response, currency, since, limit)
1867
1871
 
1868
- async def withdraw(self, code: str, amount: float, address, tag=None, params={}):
1872
+ async def withdraw(self, code: str, amount: float, address: str, tag=None, params={}):
1869
1873
  """
1870
1874
  request a withdrawal from CoinList wallet.(Disabled by default. Contact CoinList to apply for an exception.)
1871
1875
  :see: https://trade-docs.coinlist.co/?javascript--nodejs#request-withdrawal-from-wallet
@@ -65,8 +65,11 @@ class coinmate(Exchange, ImplicitAPI):
65
65
  'fetchOrderBook': True,
66
66
  'fetchOrders': True,
67
67
  'fetchPosition': False,
68
+ 'fetchPositionHistory': False,
68
69
  'fetchPositionMode': False,
69
70
  'fetchPositions': False,
71
+ 'fetchPositionsForSymbol': False,
72
+ 'fetchPositionsHistory': False,
70
73
  'fetchPositionsRisk': False,
71
74
  'fetchPremiumIndexOHLCV': False,
72
75
  'fetchTicker': True,
@@ -584,7 +587,7 @@ class coinmate(Exchange, ImplicitAPI):
584
587
  },
585
588
  }
586
589
 
587
- async def withdraw(self, code: str, amount: float, address, tag=None, params={}):
590
+ async def withdraw(self, code: str, amount: float, address: str, tag=None, params={}):
588
591
  """
589
592
  make a withdrawal
590
593
  :see: https://coinmate.docs.apiary.io/#reference/bitcoin-withdrawal-and-deposit/withdraw-bitcoins/post
@@ -72,8 +72,11 @@ class coinone(Exchange, ImplicitAPI):
72
72
  'fetchOrder': True,
73
73
  'fetchOrderBook': True,
74
74
  'fetchPosition': False,
75
+ 'fetchPositionHistory': False,
75
76
  'fetchPositionMode': False,
76
77
  'fetchPositions': False,
78
+ 'fetchPositionsForSymbol': False,
79
+ 'fetchPositionsHistory': False,
77
80
  'fetchPositionsRisk': False,
78
81
  'fetchPremiumIndexOHLCV': False,
79
82
  'fetchTicker': True,
@@ -108,7 +108,11 @@ class coinsph(Exchange, ImplicitAPI):
108
108
  'fetchOrders': False,
109
109
  'fetchOrderTrades': True,
110
110
  'fetchPosition': False,
111
+ 'fetchPositionHistory': False,
112
+ 'fetchPositionMode': False,
111
113
  'fetchPositions': False,
114
+ 'fetchPositionsForSymbol': False,
115
+ 'fetchPositionsHistory': False,
112
116
  'fetchPositionsRisk': False,
113
117
  'fetchPremiumIndexOHLCV': False,
114
118
  'fetchStatus': True,
@@ -1497,7 +1501,7 @@ class coinsph(Exchange, ImplicitAPI):
1497
1501
  'tierBased': None,
1498
1502
  }
1499
1503
 
1500
- async def withdraw(self, code: str, amount: float, address, tag=None, params={}):
1504
+ async def withdraw(self, code: str, amount: float, address: str, tag=None, params={}):
1501
1505
  """
1502
1506
  make a withdrawal to coins_ph account
1503
1507
  :see: https://coins-docs.github.io/rest-api/#withdrawuser_data
@@ -60,8 +60,11 @@ class coinspot(Exchange, ImplicitAPI):
60
60
  'fetchOpenInterestHistory': False,
61
61
  'fetchOrderBook': True,
62
62
  'fetchPosition': False,
63
+ 'fetchPositionHistory': False,
63
64
  'fetchPositionMode': False,
64
65
  'fetchPositions': False,
66
+ 'fetchPositionsForSymbol': False,
67
+ 'fetchPositionsHistory': False,
65
68
  'fetchPositionsRisk': False,
66
69
  'fetchPremiumIndexOHLCV': False,
67
70
  'fetchTicker': True,
@@ -6,7 +6,7 @@
6
6
  from ccxt.async_support.base.exchange import Exchange
7
7
  from ccxt.abstract.cryptocom import ImplicitAPI
8
8
  import hashlib
9
- from ccxt.base.types import Account, Balances, Currency, Int, Market, Num, Order, OrderBook, OrderRequest, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, Transaction
9
+ from ccxt.base.types import Account, Balances, Currency, Int, Market, Num, Order, OrderBook, OrderRequest, CancellationRequest, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, Transaction
10
10
  from typing import List
11
11
  from ccxt.base.errors import ExchangeError
12
12
  from ccxt.base.errors import AuthenticationError
@@ -47,6 +47,7 @@ class cryptocom(Exchange, ImplicitAPI):
47
47
  'cancelAllOrders': True,
48
48
  'cancelOrder': True,
49
49
  'cancelOrders': True,
50
+ 'cancelOrdersForSymbols': True,
50
51
  'closeAllPositions': False,
51
52
  'closePosition': True,
52
53
  'createMarketBuyOrderWithCost': False,
@@ -94,8 +95,10 @@ class cryptocom(Exchange, ImplicitAPI):
94
95
  'fetchOrderBook': True,
95
96
  'fetchOrders': True,
96
97
  'fetchPosition': True,
98
+ 'fetchPositionHistory': False,
97
99
  'fetchPositionMode': False,
98
100
  'fetchPositions': True,
101
+ 'fetchPositionsHistory': False,
99
102
  'fetchPremiumIndexOHLCV': False,
100
103
  'fetchSettlementHistory': True,
101
104
  'fetchStatus': False,
@@ -1353,6 +1356,34 @@ class cryptocom(Exchange, ImplicitAPI):
1353
1356
  result = self.safe_list(response, 'result', [])
1354
1357
  return self.parse_orders(result, market, None, None, params)
1355
1358
 
1359
+ async def cancel_orders_for_symbols(self, orders: List[CancellationRequest], params={}):
1360
+ """
1361
+ cancel multiple orders for multiple symbols
1362
+ :see: https://exchange-docs.crypto.com/exchange/v1/rest-ws/index.html#private-cancel-order-list-list
1363
+ :param CancellationRequest[] orders: each order should contain the parameters required by cancelOrder namely id and symbol
1364
+ :param dict [params]: extra parameters specific to the exchange API endpoint
1365
+ :returns dict: an list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
1366
+ """
1367
+ await self.load_markets()
1368
+ orderRequests = []
1369
+ for i in range(0, len(orders)):
1370
+ order = orders[i]
1371
+ id = self.safe_string(order, 'id')
1372
+ symbol = self.safe_string(order, 'symbol')
1373
+ market = self.market(symbol)
1374
+ orderItem = {
1375
+ 'instrument_name': market['id'],
1376
+ 'order_id': str(id),
1377
+ }
1378
+ orderRequests.append(orderItem)
1379
+ request = {
1380
+ 'contingency_type': 'LIST',
1381
+ 'order_list': orderRequests,
1382
+ }
1383
+ response = await self.v1PrivatePostPrivateCancelOrderList(self.extend(request, params))
1384
+ result = self.safe_list(response, 'result', [])
1385
+ return self.parse_orders(result, None, None, None, params)
1386
+
1356
1387
  async def fetch_open_orders(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}) -> List[Order]:
1357
1388
  """
1358
1389
  fetch all unfilled currently open orders
@@ -1487,7 +1518,7 @@ class cryptocom(Exchange, ImplicitAPI):
1487
1518
  address = addressString
1488
1519
  return [address, tag]
1489
1520
 
1490
- async def withdraw(self, code: str, amount: float, address, tag=None, params={}):
1521
+ async def withdraw(self, code: str, amount: float, address: str, tag=None, params={}):
1491
1522
  """
1492
1523
  make a withdrawal
1493
1524
  :see: https://exchange-docs.crypto.com/exchange/v1/rest-ws/index.html#private-create-withdrawal
@@ -2480,7 +2480,7 @@ class delta(Exchange, ImplicitAPI):
2480
2480
  'previousFundingDatetime': None,
2481
2481
  }
2482
2482
 
2483
- async def add_margin(self, symbol: str, amount, params={}) -> MarginModification:
2483
+ async def add_margin(self, symbol: str, amount: float, params={}) -> MarginModification:
2484
2484
  """
2485
2485
  add margin
2486
2486
  :see: https://docs.delta.exchange/#add-remove-position-margin
@@ -2491,7 +2491,7 @@ class delta(Exchange, ImplicitAPI):
2491
2491
  """
2492
2492
  return await self.modify_margin_helper(symbol, amount, 'add', params)
2493
2493
 
2494
- async def reduce_margin(self, symbol: str, amount, params={}) -> MarginModification:
2494
+ async def reduce_margin(self, symbol: str, amount: float, params={}) -> MarginModification:
2495
2495
  """
2496
2496
  remove margin from a position
2497
2497
  :see: https://docs.delta.exchange/#add-remove-position-margin
@@ -2749,7 +2749,7 @@ class deribit(Exchange, ImplicitAPI):
2749
2749
  }
2750
2750
  return self.safe_string(statuses, status, status)
2751
2751
 
2752
- async def withdraw(self, code: str, amount: float, address, tag=None, params={}):
2752
+ async def withdraw(self, code: str, amount: float, address: str, tag=None, params={}):
2753
2753
  """
2754
2754
  make a withdrawal
2755
2755
  :see: https://docs.deribit.com/#private-withdraw
@@ -2755,7 +2755,7 @@ class digifinex(Exchange, ImplicitAPI):
2755
2755
  #
2756
2756
  return self.parse_transfer(response, currency)
2757
2757
 
2758
- async def withdraw(self, code: str, amount: float, address, tag=None, params={}):
2758
+ async def withdraw(self, code: str, amount: float, address: str, tag=None, params={}):
2759
2759
  """
2760
2760
  make a withdrawal
2761
2761
  :param str code: unified currency code
@@ -3735,7 +3735,7 @@ class digifinex(Exchange, ImplicitAPI):
3735
3735
  depositWithdrawFees[code] = self.assign_default_deposit_withdraw_fees(depositWithdrawFees[code], currency)
3736
3736
  return depositWithdrawFees
3737
3737
 
3738
- async def add_margin(self, symbol: str, amount, params={}) -> MarginModification:
3738
+ async def add_margin(self, symbol: str, amount: float, params={}) -> MarginModification:
3739
3739
  """
3740
3740
  add margin to a position
3741
3741
  :see: https://docs.digifinex.com/en-ww/swap/v2/rest.html#positionmargin
@@ -3749,7 +3749,7 @@ class digifinex(Exchange, ImplicitAPI):
3749
3749
  self.check_required_argument('addMargin', side, 'side', ['long', 'short'])
3750
3750
  return await self.modify_margin_helper(symbol, amount, 1, params)
3751
3751
 
3752
- async def reduce_margin(self, symbol: str, amount, params={}) -> MarginModification:
3752
+ async def reduce_margin(self, symbol: str, amount: float, params={}) -> MarginModification:
3753
3753
  """
3754
3754
  remove margin from a position
3755
3755
  :see: https://docs.digifinex.com/en-ww/swap/v2/rest.html#positionmargin