ccxt 4.4.39__py2.py3-none-any.whl → 4.4.41__py2.py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (137) hide show
  1. ccxt/__init__.py +1 -1
  2. ccxt/abstract/bitmart.py +2 -0
  3. ccxt/abstract/okx.py +5 -0
  4. ccxt/ascendex.py +9 -9
  5. ccxt/async_support/__init__.py +1 -1
  6. ccxt/async_support/ascendex.py +9 -9
  7. ccxt/async_support/base/exchange.py +10 -3
  8. ccxt/async_support/base/ws/aiohttp_client.py +2 -2
  9. ccxt/async_support/binance.py +37 -41
  10. ccxt/async_support/bingx.py +4 -3
  11. ccxt/async_support/bit2c.py +0 -1
  12. ccxt/async_support/bitbank.py +0 -1
  13. ccxt/async_support/bitbns.py +0 -1
  14. ccxt/async_support/bitfinex.py +16 -17
  15. ccxt/async_support/bitfinex1.py +0 -1
  16. ccxt/async_support/bitflyer.py +0 -1
  17. ccxt/async_support/bitget.py +2 -2
  18. ccxt/async_support/bithumb.py +0 -1
  19. ccxt/async_support/bitmart.py +246 -6
  20. ccxt/async_support/bitmex.py +5 -6
  21. ccxt/async_support/bitopro.py +4 -5
  22. ccxt/async_support/bitrue.py +5 -7
  23. ccxt/async_support/bitso.py +1 -2
  24. ccxt/async_support/bitstamp.py +1 -2
  25. ccxt/async_support/bitteam.py +1 -3
  26. ccxt/async_support/bitvavo.py +2 -4
  27. ccxt/async_support/blockchaincom.py +5 -5
  28. ccxt/async_support/blofin.py +10 -10
  29. ccxt/async_support/btcalpha.py +0 -1
  30. ccxt/async_support/btcbox.py +0 -1
  31. ccxt/async_support/btcmarkets.py +1 -3
  32. ccxt/async_support/bybit.py +10 -11
  33. ccxt/async_support/cex.py +1 -1
  34. ccxt/async_support/coinbase.py +77 -1
  35. ccxt/async_support/coinbaseexchange.py +1 -1
  36. ccxt/async_support/coinbaseinternational.py +62 -0
  37. ccxt/async_support/coincatch.py +1 -1
  38. ccxt/async_support/coinex.py +9 -9
  39. ccxt/async_support/coinlist.py +1 -1
  40. ccxt/async_support/coinmetro.py +1 -1
  41. ccxt/async_support/cryptocom.py +91 -2
  42. ccxt/async_support/currencycom.py +1 -1
  43. ccxt/async_support/defx.py +1 -2
  44. ccxt/async_support/delta.py +1 -1
  45. ccxt/async_support/digifinex.py +1 -1
  46. ccxt/async_support/exmo.py +62 -6
  47. ccxt/async_support/gate.py +2 -2
  48. ccxt/async_support/hashkey.py +3 -5
  49. ccxt/async_support/htx.py +2 -2
  50. ccxt/async_support/hyperliquid.py +61 -2
  51. ccxt/async_support/kraken.py +124 -26
  52. ccxt/async_support/kucoin.py +29 -25
  53. ccxt/async_support/luno.py +1 -1
  54. ccxt/async_support/mexc.py +137 -1
  55. ccxt/async_support/ndax.py +1 -1
  56. ccxt/async_support/okcoin.py +18 -18
  57. ccxt/async_support/okx.py +27 -22
  58. ccxt/async_support/phemex.py +12 -8
  59. ccxt/async_support/poloniex.py +1 -1
  60. ccxt/async_support/poloniexfutures.py +6 -6
  61. ccxt/async_support/vertex.py +11 -11
  62. ccxt/async_support/woo.py +33 -33
  63. ccxt/async_support/woofipro.py +24 -24
  64. ccxt/async_support/xt.py +29 -27
  65. ccxt/async_support/zonda.py +1 -1
  66. ccxt/base/exchange.py +31 -19
  67. ccxt/base/types.py +10 -0
  68. ccxt/binance.py +37 -41
  69. ccxt/bingx.py +4 -3
  70. ccxt/bit2c.py +0 -1
  71. ccxt/bitbank.py +0 -1
  72. ccxt/bitbns.py +0 -1
  73. ccxt/bitfinex.py +16 -17
  74. ccxt/bitfinex1.py +0 -1
  75. ccxt/bitflyer.py +0 -1
  76. ccxt/bitget.py +2 -2
  77. ccxt/bithumb.py +0 -1
  78. ccxt/bitmart.py +246 -6
  79. ccxt/bitmex.py +5 -6
  80. ccxt/bitopro.py +4 -5
  81. ccxt/bitrue.py +5 -7
  82. ccxt/bitso.py +1 -2
  83. ccxt/bitstamp.py +1 -2
  84. ccxt/bitteam.py +1 -3
  85. ccxt/bitvavo.py +2 -4
  86. ccxt/blockchaincom.py +5 -5
  87. ccxt/blofin.py +10 -10
  88. ccxt/btcalpha.py +0 -1
  89. ccxt/btcbox.py +0 -1
  90. ccxt/btcmarkets.py +1 -3
  91. ccxt/bybit.py +10 -11
  92. ccxt/cex.py +1 -1
  93. ccxt/coinbase.py +77 -1
  94. ccxt/coinbaseexchange.py +1 -1
  95. ccxt/coinbaseinternational.py +62 -0
  96. ccxt/coincatch.py +1 -1
  97. ccxt/coinex.py +9 -9
  98. ccxt/coinlist.py +1 -1
  99. ccxt/coinmetro.py +1 -1
  100. ccxt/cryptocom.py +91 -2
  101. ccxt/currencycom.py +1 -1
  102. ccxt/defx.py +1 -2
  103. ccxt/delta.py +1 -1
  104. ccxt/digifinex.py +1 -1
  105. ccxt/exmo.py +62 -6
  106. ccxt/gate.py +2 -2
  107. ccxt/hashkey.py +3 -5
  108. ccxt/htx.py +2 -2
  109. ccxt/hyperliquid.py +61 -2
  110. ccxt/kraken.py +124 -26
  111. ccxt/kucoin.py +29 -25
  112. ccxt/luno.py +1 -1
  113. ccxt/mexc.py +137 -1
  114. ccxt/ndax.py +1 -1
  115. ccxt/okcoin.py +18 -18
  116. ccxt/okx.py +27 -22
  117. ccxt/phemex.py +12 -8
  118. ccxt/poloniex.py +1 -1
  119. ccxt/poloniexfutures.py +6 -6
  120. ccxt/pro/__init__.py +1 -1
  121. ccxt/pro/bitget.py +1 -1
  122. ccxt/pro/bybit.py +12 -1
  123. ccxt/pro/coinex.py +2 -2
  124. ccxt/pro/gate.py +6 -6
  125. ccxt/pro/kucoin.py +3 -3
  126. ccxt/pro/okx.py +11 -11
  127. ccxt/pro/upbit.py +2 -2
  128. ccxt/vertex.py +11 -11
  129. ccxt/woo.py +33 -33
  130. ccxt/woofipro.py +24 -24
  131. ccxt/xt.py +29 -27
  132. ccxt/zonda.py +1 -1
  133. {ccxt-4.4.39.dist-info → ccxt-4.4.41.dist-info}/METADATA +4 -4
  134. {ccxt-4.4.39.dist-info → ccxt-4.4.41.dist-info}/RECORD +137 -137
  135. {ccxt-4.4.39.dist-info → ccxt-4.4.41.dist-info}/LICENSE.txt +0 -0
  136. {ccxt-4.4.39.dist-info → ccxt-4.4.41.dist-info}/WHEEL +0 -0
  137. {ccxt-4.4.39.dist-info → ccxt-4.4.41.dist-info}/top_level.txt +0 -0
ccxt/exmo.py CHANGED
@@ -43,6 +43,9 @@ class exmo(Exchange, ImplicitAPI):
43
43
  'cancelOrder': True,
44
44
  'cancelOrders': False,
45
45
  'createDepositAddress': False,
46
+ 'createMarketBuyOrder': True,
47
+ 'createMarketBuyOrderWithCost': True,
48
+ 'createMarketOrderWithCost': True,
46
49
  'createOrder': True,
47
50
  'createStopLimitOrder': True,
48
51
  'createStopMarketOrder': True,
@@ -1352,6 +1355,52 @@ class exmo(Exchange, ImplicitAPI):
1352
1355
  result = self.array_concat(result, trades)
1353
1356
  return self.filter_by_since_limit(result, since, limit)
1354
1357
 
1358
+ def create_market_order_with_cost(self, symbol: str, side: OrderSide, cost: float, params={}):
1359
+ """
1360
+ create a market order by providing the symbol, side and cost
1361
+
1362
+ https://documenter.getpostman.com/view/10287440/SzYXWKPi#80daa469-ec59-4d0a-b229-6a311d8dd1cd
1363
+
1364
+ :param str symbol: unified symbol of the market to create an order in
1365
+ :param str side: 'buy' or 'sell'
1366
+ :param float cost: how much you want to trade in units of the quote currency
1367
+ :param dict [params]: extra parameters specific to the exchange API endpoint
1368
+ :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
1369
+ """
1370
+ self.load_markets()
1371
+ params = self.extend(params, {'cost': cost})
1372
+ return self.create_order(symbol, 'market', side, cost, None, params)
1373
+
1374
+ def create_market_buy_order_with_cost(self, symbol: str, cost: float, params={}):
1375
+ """
1376
+ create a market buy order by providing the symbol and cost
1377
+
1378
+ https://documenter.getpostman.com/view/10287440/SzYXWKPi#80daa469-ec59-4d0a-b229-6a311d8dd1cd
1379
+
1380
+ :param str symbol: unified symbol of the market to create an order in
1381
+ :param float cost: how much you want to trade in units of the quote currency
1382
+ :param dict [params]: extra parameters specific to the exchange API endpoint
1383
+ :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
1384
+ """
1385
+ self.load_markets()
1386
+ params = self.extend(params, {'cost': cost})
1387
+ return self.create_order(symbol, 'market', 'buy', cost, None, params)
1388
+
1389
+ def create_market_sell_order_with_cost(self, symbol: str, cost: float, params={}):
1390
+ """
1391
+ create a market sell order by providing the symbol and cost
1392
+
1393
+ https://documenter.getpostman.com/view/10287440/SzYXWKPi#80daa469-ec59-4d0a-b229-6a311d8dd1cd
1394
+
1395
+ :param str symbol: unified symbol of the market to create an order in
1396
+ :param float cost: how much you want to trade in units of the quote currency
1397
+ :param dict [params]: extra parameters specific to the exchange API endpoint
1398
+ :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
1399
+ """
1400
+ self.load_markets()
1401
+ params = self.extend(params, {'cost': cost})
1402
+ return self.create_order(symbol, 'market', 'sell', cost, None, params)
1403
+
1355
1404
  def create_order(self, symbol: str, type: OrderType, side: OrderSide, amount: float, price: Num = None, params={}):
1356
1405
  """
1357
1406
  create a trade order
@@ -1369,6 +1418,7 @@ class exmo(Exchange, ImplicitAPI):
1369
1418
  :param float [params.stopPrice]: the price at which a trigger order is triggered at
1370
1419
  :param str [params.timeInForce]: *spot only* 'fok', 'ioc' or 'post_only'
1371
1420
  :param boolean [params.postOnly]: *spot only* True for post only orders
1421
+ :param float [params.cost]: *spot only* *market orders only* the cost of the order in the quote currency for market orders
1372
1422
  :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
1373
1423
  """
1374
1424
  self.load_markets()
@@ -1379,11 +1429,12 @@ class exmo(Exchange, ImplicitAPI):
1379
1429
  if marginMode == 'cross':
1380
1430
  raise BadRequest(self.id + ' only supports isolated margin')
1381
1431
  isSpot = (marginMode != 'isolated')
1382
- triggerPrice = self.safe_number_n(params, ['triggerPrice', 'stopPrice', 'stop_price'])
1432
+ triggerPrice = self.safe_string_n(params, ['triggerPrice', 'stopPrice', 'stop_price'])
1433
+ cost = self.safe_string(params, 'cost')
1383
1434
  request: dict = {
1384
1435
  'pair': market['id'],
1385
1436
  # 'leverage': 2,
1386
- 'quantity': self.amount_to_precision(market['symbol'], amount),
1437
+ # 'quantity': self.amount_to_precision(market['symbol'], amount),
1387
1438
  # spot - buy, sell, market_buy, market_sell, market_buy_total, market_sell_total
1388
1439
  # margin - limit_buy, limit_sell, market_buy, market_sell, stop_buy, stop_sell, stop_limit_buy, stop_limit_sell, trailing_stop_buy, trailing_stop_sell
1389
1440
  # 'stop_price': self.price_to_precision(symbol, stopPrice),
@@ -1392,6 +1443,10 @@ class exmo(Exchange, ImplicitAPI):
1392
1443
  # 'client_id': 123, # optional, must be a positive integer
1393
1444
  # 'comment': '', # up to 50 latin symbols, whitespaces, underscores
1394
1445
  }
1446
+ if cost is None:
1447
+ request['quantity'] = self.amount_to_precision(market['symbol'], amount)
1448
+ else:
1449
+ request['quantity'] = self.cost_to_precision(market['symbol'], cost)
1395
1450
  clientOrderId = self.safe_value_2(params, 'client_id', 'clientOrderId')
1396
1451
  if clientOrderId is not None:
1397
1452
  clientOrderId = self.safe_integer_2(params, 'client_id', 'clientOrderId')
@@ -1402,7 +1457,7 @@ class exmo(Exchange, ImplicitAPI):
1402
1457
  leverage = self.safe_number(params, 'leverage')
1403
1458
  if not isSpot and (leverage is None):
1404
1459
  raise ArgumentsRequired(self.id + ' createOrder requires an extra param params["leverage"] for margin orders')
1405
- params = self.omit(params, ['stopPrice', 'stop_price', 'triggerPrice', 'timeInForce', 'client_id', 'clientOrderId'])
1460
+ params = self.omit(params, ['stopPrice', 'stop_price', 'triggerPrice', 'timeInForce', 'client_id', 'clientOrderId', 'cost'])
1406
1461
  if price is not None:
1407
1462
  request['price'] = self.price_to_precision(market['symbol'], price)
1408
1463
  response = None
@@ -1423,7 +1478,8 @@ class exmo(Exchange, ImplicitAPI):
1423
1478
  if type == 'limit':
1424
1479
  request['type'] = side
1425
1480
  elif type == 'market':
1426
- request['type'] = 'market_' + side
1481
+ marketSuffix = '_total' if (cost is not None) else ''
1482
+ request['type'] = 'market_' + side + marketSuffix
1427
1483
  if isPostOnly:
1428
1484
  request['exec_type'] = 'post_only'
1429
1485
  elif timeInForce is not None:
@@ -1463,7 +1519,7 @@ class exmo(Exchange, ImplicitAPI):
1463
1519
  """
1464
1520
  self.load_markets()
1465
1521
  request: dict = {}
1466
- stop = self.safe_value_2(params, 'trigger', 'stop')
1522
+ trigger = self.safe_value_2(params, 'trigger', 'stop')
1467
1523
  params = self.omit(params, ['trigger', 'stop'])
1468
1524
  marginMode = None
1469
1525
  marginMode, params = self.handle_margin_mode_and_params('cancelOrder', params)
@@ -1477,7 +1533,7 @@ class exmo(Exchange, ImplicitAPI):
1477
1533
  # {}
1478
1534
  #
1479
1535
  else:
1480
- if stop:
1536
+ if trigger:
1481
1537
  request['parent_order_id'] = id
1482
1538
  response = self.privatePostStopMarketOrderCancel(self.extend(request, params))
1483
1539
  #
ccxt/gate.py CHANGED
@@ -6487,7 +6487,7 @@ class gate(Exchange, ImplicitAPI):
6487
6487
  # ...
6488
6488
  # ]
6489
6489
  #
6490
- return self.parse_open_interests(response, market, since, limit)
6490
+ return self.parse_open_interests_history(response, market, since, limit)
6491
6491
 
6492
6492
  def parse_open_interest(self, interest, market: Market = None):
6493
6493
  #
@@ -6705,7 +6705,7 @@ class gate(Exchange, ImplicitAPI):
6705
6705
  :param dict [params]: extra parameters specific to the exchange API endpoint
6706
6706
  :param int [params.until]: end time in ms
6707
6707
  :param boolean [params.paginate]: default False, when True will automatically paginate by calling self endpoint multiple times. See in the docs all the [available parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
6708
- :returns dict: a `ledger structure <https://docs.ccxt.com/#/?id=ledger-structure>`
6708
+ :returns dict: a `ledger structure <https://docs.ccxt.com/#/?id=ledger>`
6709
6709
  """
6710
6710
  self.load_markets()
6711
6711
  paginate = False
ccxt/hashkey.py CHANGED
@@ -2199,7 +2199,7 @@ class hashkey(Exchange, ImplicitAPI):
2199
2199
  :param int [params.until]: the latest time in ms to fetch entries for
2200
2200
  :param int [params.flowType]: trade, fee, transfer, deposit, withdrawal
2201
2201
  :param int [params.accountType]: spot, swap, custody
2202
- :returns dict: a `ledger structure <https://docs.ccxt.com/#/?id=ledger-structure>`
2202
+ :returns dict: a `ledger structure <https://docs.ccxt.com/#/?id=ledger>`
2203
2203
  """
2204
2204
  methodName = 'fetchLedger'
2205
2205
  if since is None:
@@ -3337,10 +3337,8 @@ class hashkey(Exchange, ImplicitAPI):
3337
3337
  raise BadRequest(self.id + ' ' + methodName + '() type parameter can not be "' + paramsType + '". It should define the type of the market("spot" or "swap"). To define the type of an order use the trigger parameter(True for trigger orders)')
3338
3338
 
3339
3339
  def handle_trigger_option_and_params(self, params: object, methodName: str, defaultValue=None):
3340
- isStop = defaultValue
3341
- isStop, params = self.handle_option_and_params(params, methodName, 'stop', isStop)
3342
- isTrigger = isStop
3343
- isTrigger, params = self.handle_option_and_params(params, methodName, 'trigger', isTrigger)
3340
+ isTrigger = defaultValue
3341
+ isTrigger, params = self.handle_option_and_params_2(params, methodName, 'stop', 'trigger', isTrigger)
3344
3342
  return [isTrigger, params]
3345
3343
 
3346
3344
  def parse_order(self, order: dict, market: Market = None) -> Order:
ccxt/htx.py CHANGED
@@ -7763,7 +7763,7 @@ class htx(Exchange, ImplicitAPI):
7763
7763
  :param dict [params]: extra parameters specific to the exchange API endpoint
7764
7764
  :param int [params.until]: the latest time in ms to fetch entries for
7765
7765
  :param boolean [params.paginate]: default False, when True will automatically paginate by calling self endpoint multiple times. See in the docs all the [available parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
7766
- :returns dict: a `ledger structure <https://docs.ccxt.com/#/?id=ledger-structure>`
7766
+ :returns dict: a `ledger structure <https://docs.ccxt.com/#/?id=ledger>`
7767
7767
  """
7768
7768
  self.load_markets()
7769
7769
  paginate = False
@@ -8003,7 +8003,7 @@ class htx(Exchange, ImplicitAPI):
8003
8003
  #
8004
8004
  data = self.safe_value(response, 'data')
8005
8005
  tick = self.safe_list(data, 'tick')
8006
- return self.parse_open_interests(tick, market, since, limit)
8006
+ return self.parse_open_interests_history(tick, market, since, limit)
8007
8007
 
8008
8008
  def fetch_open_interest(self, symbol: str, params={}):
8009
8009
  """
ccxt/hyperliquid.py CHANGED
@@ -94,8 +94,9 @@ class hyperliquid(Exchange, ImplicitAPI):
94
94
  'fetchMyLiquidations': False,
95
95
  'fetchMyTrades': True,
96
96
  'fetchOHLCV': True,
97
- 'fetchOpenInterest': False,
97
+ 'fetchOpenInterest': True,
98
98
  'fetchOpenInterestHistory': False,
99
+ 'fetchOpenInterests': True,
99
100
  'fetchOpenOrders': True,
100
101
  'fetchOrder': True,
101
102
  'fetchOrderBook': True,
@@ -2970,7 +2971,7 @@ class hyperliquid(Exchange, ImplicitAPI):
2970
2971
  :param int [limit]: max number of ledger entries to return
2971
2972
  :param dict [params]: extra parameters specific to the exchange API endpoint
2972
2973
  :param int [params.until]: timestamp in ms of the latest ledger entry
2973
- :returns dict: a `ledger structure <https://docs.ccxt.com/#/?id=ledger-structure>`
2974
+ :returns dict: a `ledger structure <https://docs.ccxt.com/#/?id=ledger>`
2974
2975
  """
2975
2976
  self.load_markets()
2976
2977
  userAddress = None
@@ -3131,6 +3132,64 @@ class hyperliquid(Exchange, ImplicitAPI):
3131
3132
  withdrawals = self.filter_by_array(records, 'type', ['withdraw'], False)
3132
3133
  return self.parse_transactions(withdrawals, None, since, limit)
3133
3134
 
3135
+ def fetch_open_interests(self, symbols: Strings = None, params={}):
3136
+ """
3137
+ Retrieves the open interest for a list of symbols
3138
+ :param str[] [symbols]: Unified CCXT market symbol
3139
+ :param dict [params]: exchange specific parameters
3140
+ :returns dict} an open interest structure{@link https://docs.ccxt.com/#/?id=open-interest-structure:
3141
+ """
3142
+ self.load_markets()
3143
+ symbols = self.market_symbols(symbols)
3144
+ swapMarkets = self.fetch_swap_markets()
3145
+ result = self.parse_open_interests(swapMarkets)
3146
+ return self.filter_by_array(result, 'symbol', symbols)
3147
+
3148
+ def fetch_open_interest(self, symbol: str, params={}):
3149
+ """
3150
+ retrieves the open interest of a contract trading pair
3151
+ :param str symbol: unified CCXT market symbol
3152
+ :param dict [params]: exchange specific parameters
3153
+ :returns dict: an `open interest structure <https://docs.ccxt.com/#/?id=open-interest-structure>`
3154
+ """
3155
+ symbol = self.symbol(symbol)
3156
+ self.load_markets()
3157
+ ois = self.fetch_open_interests([symbol], params)
3158
+ return ois[symbol]
3159
+
3160
+ def parse_open_interest(self, interest, market: Market = None):
3161
+ #
3162
+ # {
3163
+ # szDecimals: '2',
3164
+ # name: 'HYPE',
3165
+ # maxLeverage: '3',
3166
+ # funding: '0.00014735',
3167
+ # openInterest: '14677900.74',
3168
+ # prevDayPx: '26.145',
3169
+ # dayNtlVlm: '299643445.12560016',
3170
+ # premium: '0.00081613',
3171
+ # oraclePx: '27.569',
3172
+ # markPx: '27.63',
3173
+ # midPx: '27.599',
3174
+ # impactPxs: ['27.5915', '27.6319'],
3175
+ # dayBaseVlm: '10790652.83',
3176
+ # baseId: 159
3177
+ # }
3178
+ #
3179
+ interest = self.safe_dict(interest, 'info', {})
3180
+ coin = self.safe_string(interest, 'name')
3181
+ marketId = None
3182
+ if coin is not None:
3183
+ marketId = self.coin_to_market_id(coin)
3184
+ return self.safe_open_interest({
3185
+ 'symbol': self.safe_symbol(marketId),
3186
+ 'openInterestAmount': self.safe_number(interest, 'openInterest'),
3187
+ 'openInterestValue': None,
3188
+ 'timestamp': None,
3189
+ 'datetime': None,
3190
+ 'info': interest,
3191
+ }, market)
3192
+
3134
3193
  def extract_type_from_delta(self, data=[]):
3135
3194
  records = []
3136
3195
  for i in range(0, len(data)):
ccxt/kraken.py CHANGED
@@ -1129,7 +1129,7 @@ class kraken(Exchange, ImplicitAPI):
1129
1129
  :param dict [params]: extra parameters specific to the exchange API endpoint
1130
1130
  :param int [params.until]: timestamp in ms of the latest ledger entry
1131
1131
  :param int [params.end]: timestamp in seconds of the latest ledger entry
1132
- :returns dict: a `ledger structure <https://docs.ccxt.com/#/?id=ledger-structure>`
1132
+ :returns dict: a `ledger structure <https://docs.ccxt.com/#/?id=ledger>`
1133
1133
  """
1134
1134
  # https://www.kraken.com/features/api#get-ledgers-info
1135
1135
  self.load_markets()
@@ -1621,6 +1621,37 @@ class kraken(Exchange, ImplicitAPI):
1621
1621
  # }
1622
1622
  # }
1623
1623
  #
1624
+ # fetchOpenOrders
1625
+ #
1626
+ # {
1627
+ # "refid": null,
1628
+ # "userref": null,
1629
+ # "cl_ord_id": "1234",
1630
+ # "status": "open",
1631
+ # "opentm": 1733815269.370054,
1632
+ # "starttm": 0,
1633
+ # "expiretm": 0,
1634
+ # "descr": {
1635
+ # "pair": "XBTUSD",
1636
+ # "type": "buy",
1637
+ # "ordertype": "limit",
1638
+ # "price": "70000.0",
1639
+ # "price2": "0",
1640
+ # "leverage": "none",
1641
+ # "order": "buy 0.00010000 XBTUSD @ limit 70000.0",
1642
+ # "close": ""
1643
+ # },
1644
+ # "vol": "0.00010000",
1645
+ # "vol_exec": "0.00000000",
1646
+ # "cost": "0.00000",
1647
+ # "fee": "0.00000",
1648
+ # "price": "0.00000",
1649
+ # "stopprice": "0.00000",
1650
+ # "limitprice": "0.00000",
1651
+ # "misc": "",
1652
+ # "oflags": "fciq"
1653
+ # }
1654
+ #
1624
1655
  description = self.safe_dict(order, 'descr', {})
1625
1656
  orderDescriptionObj = self.safe_dict(order, 'descr') # can be null
1626
1657
  orderDescription = None
@@ -1694,7 +1725,8 @@ class kraken(Exchange, ImplicitAPI):
1694
1725
  if (id is None) or (id.startswith('[')):
1695
1726
  txid = self.safe_list(order, 'txid')
1696
1727
  id = self.safe_string(txid, 0)
1697
- clientOrderId = self.safe_string(order, 'userref')
1728
+ userref = self.safe_string(order, 'userref')
1729
+ clientOrderId = self.safe_string(order, 'cl_ord_id', userref)
1698
1730
  rawTrades = self.safe_value(order, 'trades', [])
1699
1731
  trades = []
1700
1732
  for i in range(0, len(rawTrades)):
@@ -1888,10 +1920,10 @@ class kraken(Exchange, ImplicitAPI):
1888
1920
  request: dict = {
1889
1921
  'txid': id,
1890
1922
  }
1891
- clientOrderId = self.safe_string(params, 'clientOrderId')
1923
+ clientOrderId = self.safe_string_2(params, 'clientOrderId', 'cl_ord_id')
1892
1924
  if clientOrderId is not None:
1893
1925
  request['cl_ord_id'] = clientOrderId
1894
- params = self.omit(params, 'clientOrderId')
1926
+ params = self.omit(params, ['clientOrderId', 'cl_ord_id'])
1895
1927
  request = self.omit(request, 'txid')
1896
1928
  isMarket = (type == 'market')
1897
1929
  postOnly = None
@@ -2158,20 +2190,27 @@ class kraken(Exchange, ImplicitAPI):
2158
2190
  """
2159
2191
  cancels an open order
2160
2192
 
2161
- https://docs.kraken.com/rest/#tag/Spot-Trading/operation/cancelOrder
2193
+ https://docs.kraken.com/api/docs/rest-api/cancel-order
2162
2194
 
2163
2195
  :param str id: order id
2164
- :param str symbol: unified symbol of the market the order was made in
2196
+ :param str [symbol]: unified symbol of the market the order was made in
2165
2197
  :param dict [params]: extra parameters specific to the exchange API endpoint
2166
- :returns dict: An `order structure <https://docs.ccxt.com/#/?id=order-structure>`
2198
+ :param str [params.clientOrderId]: the orders client order id
2199
+ :param int [params.userref]: the orders user reference id
2200
+ :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
2167
2201
  """
2168
2202
  self.load_markets()
2169
2203
  response = None
2170
- clientOrderId = self.safe_value_2(params, 'userref', 'clientOrderId', id)
2204
+ requestId = self.safe_value(params, 'userref', id) # string or integer
2205
+ params = self.omit(params, 'userref')
2171
2206
  request: dict = {
2172
- 'txid': clientOrderId, # order id or userref
2207
+ 'txid': requestId, # order id or userref
2173
2208
  }
2174
- params = self.omit(params, ['userref', 'clientOrderId'])
2209
+ clientOrderId = self.safe_string_2(params, 'clientOrderId', 'cl_ord_id')
2210
+ if clientOrderId is not None:
2211
+ request['cl_ord_id'] = clientOrderId
2212
+ params = self.omit(params, ['clientOrderId', 'cl_ord_id'])
2213
+ request = self.omit(request, 'txid')
2175
2214
  try:
2176
2215
  response = self.privatePostCancelOrder(self.extend(request, params))
2177
2216
  #
@@ -2278,55 +2317,108 @@ class kraken(Exchange, ImplicitAPI):
2278
2317
  """
2279
2318
  fetch all unfilled currently open orders
2280
2319
 
2281
- https://docs.kraken.com/rest/#tag/Account-Data/operation/getOpenOrders
2320
+ https://docs.kraken.com/api/docs/rest-api/get-open-orders
2282
2321
 
2283
- :param str symbol: unified market symbol
2322
+ :param str [symbol]: unified market symbol
2284
2323
  :param int [since]: the earliest time in ms to fetch open orders for
2285
2324
  :param int [limit]: the maximum number of open orders structures to retrieve
2286
2325
  :param dict [params]: extra parameters specific to the exchange API endpoint
2326
+ :param str [params.clientOrderId]: the orders client order id
2327
+ :param int [params.userref]: the orders user reference id
2287
2328
  :returns Order[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
2288
2329
  """
2289
2330
  self.load_markets()
2290
2331
  request: dict = {}
2291
2332
  if since is not None:
2292
2333
  request['start'] = self.parse_to_int(since / 1000)
2293
- query = params
2294
- clientOrderId = self.safe_value_2(params, 'userref', 'clientOrderId')
2334
+ userref = self.safe_integer(params, 'userref')
2335
+ if userref is not None:
2336
+ request['userref'] = userref
2337
+ params = self.omit(params, 'userref')
2338
+ clientOrderId = self.safe_string(params, 'clientOrderId')
2295
2339
  if clientOrderId is not None:
2296
- request['userref'] = clientOrderId
2297
- query = self.omit(params, ['userref', 'clientOrderId'])
2298
- response = self.privatePostOpenOrders(self.extend(request, query))
2340
+ request['cl_ord_id'] = clientOrderId
2341
+ params = self.omit(params, 'clientOrderId')
2342
+ response = self.privatePostOpenOrders(self.extend(request, params))
2343
+ #
2344
+ # {
2345
+ # "error": [],
2346
+ # "result": {
2347
+ # "open": {
2348
+ # "O45M52-BFD5S-YXKQOU": {
2349
+ # "refid": null,
2350
+ # "userref": null,
2351
+ # "cl_ord_id": "1234",
2352
+ # "status": "open",
2353
+ # "opentm": 1733815269.370054,
2354
+ # "starttm": 0,
2355
+ # "expiretm": 0,
2356
+ # "descr": {
2357
+ # "pair": "XBTUSD",
2358
+ # "type": "buy",
2359
+ # "ordertype": "limit",
2360
+ # "price": "70000.0",
2361
+ # "price2": "0",
2362
+ # "leverage": "none",
2363
+ # "order": "buy 0.00010000 XBTUSD @ limit 70000.0",
2364
+ # "close": ""
2365
+ # },
2366
+ # "vol": "0.00010000",
2367
+ # "vol_exec": "0.00000000",
2368
+ # "cost": "0.00000",
2369
+ # "fee": "0.00000",
2370
+ # "price": "0.00000",
2371
+ # "stopprice": "0.00000",
2372
+ # "limitprice": "0.00000",
2373
+ # "misc": "",
2374
+ # "oflags": "fciq"
2375
+ # }
2376
+ # }
2377
+ # }
2378
+ # }
2379
+ #
2299
2380
  market = None
2300
2381
  if symbol is not None:
2301
2382
  market = self.market(symbol)
2302
2383
  result = self.safe_dict(response, 'result', {})
2303
- orders = self.safe_dict(result, 'open', {})
2384
+ open = self.safe_dict(result, 'open', {})
2385
+ orders = []
2386
+ orderIds = list(open.keys())
2387
+ for i in range(0, len(orderIds)):
2388
+ id = orderIds[i]
2389
+ item = open[id]
2390
+ orders.append(self.extend({'id': id}, item))
2304
2391
  return self.parse_orders(orders, market, since, limit)
2305
2392
 
2306
2393
  def fetch_closed_orders(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}) -> List[Order]:
2307
2394
  """
2308
2395
  fetches information on multiple closed orders made by the user
2309
2396
 
2310
- https://docs.kraken.com/rest/#tag/Account-Data/operation/getClosedOrders
2397
+ https://docs.kraken.com/api/docs/rest-api/get-closed-orders
2311
2398
 
2312
- :param str symbol: unified market symbol of the market orders were made in
2399
+ :param str [symbol]: unified market symbol of the market orders were made in
2313
2400
  :param int [since]: the earliest time in ms to fetch orders for
2314
2401
  :param int [limit]: the maximum number of order structures to retrieve
2315
2402
  :param dict [params]: extra parameters specific to the exchange API endpoint
2316
2403
  :param int [params.until]: timestamp in ms of the latest entry
2404
+ :param str [params.clientOrderId]: the orders client order id
2405
+ :param int [params.userref]: the orders user reference id
2317
2406
  :returns Order[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
2318
2407
  """
2319
2408
  self.load_markets()
2320
2409
  request: dict = {}
2321
2410
  if since is not None:
2322
2411
  request['start'] = self.parse_to_int(since / 1000)
2323
- query = params
2324
- clientOrderId = self.safe_value_2(params, 'userref', 'clientOrderId')
2412
+ userref = self.safe_integer(params, 'userref')
2413
+ if userref is not None:
2414
+ request['userref'] = userref
2415
+ params = self.omit(params, 'userref')
2416
+ clientOrderId = self.safe_string(params, 'clientOrderId')
2325
2417
  if clientOrderId is not None:
2326
- request['userref'] = clientOrderId
2327
- query = self.omit(params, ['userref', 'clientOrderId'])
2418
+ request['cl_ord_id'] = clientOrderId
2419
+ params = self.omit(params, 'clientOrderId')
2328
2420
  request, params = self.handle_until_option('end', request, params)
2329
- response = self.privatePostClosedOrders(self.extend(request, query))
2421
+ response = self.privatePostClosedOrders(self.extend(request, params))
2330
2422
  #
2331
2423
  # {
2332
2424
  # "error":[],
@@ -2370,7 +2462,13 @@ class kraken(Exchange, ImplicitAPI):
2370
2462
  if symbol is not None:
2371
2463
  market = self.market(symbol)
2372
2464
  result = self.safe_dict(response, 'result', {})
2373
- orders = self.safe_dict(result, 'closed', {})
2465
+ closed = self.safe_dict(result, 'closed', {})
2466
+ orders = []
2467
+ orderIds = list(closed.keys())
2468
+ for i in range(0, len(orderIds)):
2469
+ id = orderIds[i]
2470
+ item = closed[id]
2471
+ orders.append(self.extend({'id': id}, item))
2374
2472
  return self.parse_orders(orders, market, since, limit)
2375
2473
 
2376
2474
  def parse_transaction_status(self, status: Str):