ccxt 4.4.12__py2.py3-none-any.whl → 4.4.14__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 (84) 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/cryptocom.py +1 -0
  7. ccxt/async_support/__init__.py +1 -1
  8. ccxt/async_support/base/exchange.py +37 -1
  9. ccxt/async_support/bigone.py +2 -0
  10. ccxt/async_support/binance.py +113 -12
  11. ccxt/async_support/bingx.py +69 -3
  12. ccxt/async_support/bitget.py +102 -3
  13. ccxt/async_support/bitmex.py +1 -0
  14. ccxt/async_support/bitrue.py +1 -7
  15. ccxt/async_support/bitvavo.py +1 -3
  16. ccxt/async_support/bybit.py +2 -0
  17. ccxt/async_support/coinbaseinternational.py +2 -0
  18. ccxt/async_support/coinex.py +15 -1
  19. ccxt/async_support/cryptocom.py +1 -0
  20. ccxt/async_support/delta.py +2 -0
  21. ccxt/async_support/deribit.py +2 -0
  22. ccxt/async_support/digifinex.py +15 -1
  23. ccxt/async_support/gate.py +2 -0
  24. ccxt/async_support/htx.py +2 -2
  25. ccxt/async_support/huobijp.py +1 -3
  26. ccxt/async_support/krakenfutures.py +2 -0
  27. ccxt/async_support/kucoin.py +36 -1
  28. ccxt/async_support/kucoinfutures.py +56 -3
  29. ccxt/async_support/mexc.py +52 -8
  30. ccxt/async_support/okx.py +48 -0
  31. ccxt/async_support/oxfun.py +1 -0
  32. ccxt/async_support/paradex.py +1 -0
  33. ccxt/async_support/poloniex.py +1 -0
  34. ccxt/async_support/poloniexfutures.py +35 -11
  35. ccxt/async_support/woo.py +12 -0
  36. ccxt/async_support/woofipro.py +12 -0
  37. ccxt/async_support/xt.py +12 -0
  38. ccxt/base/exchange.py +44 -2
  39. ccxt/base/types.py +2 -0
  40. ccxt/bigone.py +2 -0
  41. ccxt/binance.py +113 -12
  42. ccxt/bingx.py +69 -3
  43. ccxt/bitget.py +102 -3
  44. ccxt/bitmex.py +1 -0
  45. ccxt/bitrue.py +1 -7
  46. ccxt/bitvavo.py +1 -3
  47. ccxt/bybit.py +2 -0
  48. ccxt/coinbaseinternational.py +2 -0
  49. ccxt/coinex.py +15 -1
  50. ccxt/cryptocom.py +1 -0
  51. ccxt/delta.py +2 -0
  52. ccxt/deribit.py +2 -0
  53. ccxt/digifinex.py +15 -1
  54. ccxt/gate.py +2 -0
  55. ccxt/htx.py +2 -2
  56. ccxt/huobijp.py +1 -3
  57. ccxt/krakenfutures.py +2 -0
  58. ccxt/kucoin.py +36 -1
  59. ccxt/kucoinfutures.py +56 -3
  60. ccxt/mexc.py +52 -8
  61. ccxt/okx.py +48 -0
  62. ccxt/oxfun.py +1 -0
  63. ccxt/paradex.py +1 -0
  64. ccxt/poloniex.py +1 -0
  65. ccxt/poloniexfutures.py +35 -11
  66. ccxt/pro/__init__.py +1 -1
  67. ccxt/pro/binance.py +72 -5
  68. ccxt/pro/bitfinex.py +8 -8
  69. ccxt/pro/krakenfutures.py +2 -0
  70. ccxt/pro/okx.py +38 -0
  71. ccxt/pro/phemex.py +2 -0
  72. ccxt/pro/woo.py +69 -0
  73. ccxt/test/tests_async.py +76 -48
  74. ccxt/test/tests_helpers.py +27 -36
  75. ccxt/test/tests_init.py +6 -2
  76. ccxt/test/tests_sync.py +76 -48
  77. ccxt/woo.py +12 -0
  78. ccxt/woofipro.py +12 -0
  79. ccxt/xt.py +12 -0
  80. {ccxt-4.4.12.dist-info → ccxt-4.4.14.dist-info}/METADATA +4 -5
  81. {ccxt-4.4.12.dist-info → ccxt-4.4.14.dist-info}/RECORD +84 -84
  82. {ccxt-4.4.12.dist-info → ccxt-4.4.14.dist-info}/LICENSE.txt +0 -0
  83. {ccxt-4.4.12.dist-info → ccxt-4.4.14.dist-info}/WHEEL +0 -0
  84. {ccxt-4.4.12.dist-info → ccxt-4.4.14.dist-info}/top_level.txt +0 -0
ccxt/bitget.py CHANGED
@@ -100,6 +100,8 @@ class bitget(Exchange, ImplicitAPI):
100
100
  'fetchDepositWithdrawFee': 'emulated',
101
101
  'fetchDepositWithdrawFees': True,
102
102
  'fetchFundingHistory': True,
103
+ 'fetchFundingInterval': True,
104
+ 'fetchFundingIntervals': False,
103
105
  'fetchFundingRate': True,
104
106
  'fetchFundingRateHistory': True,
105
107
  'fetchFundingRates': False,
@@ -115,6 +117,7 @@ class bitget(Exchange, ImplicitAPI):
115
117
  'fetchMarketLeverageTiers': True,
116
118
  'fetchMarkets': True,
117
119
  'fetchMarkOHLCV': True,
120
+ 'fetchMarkPrice': True,
118
121
  'fetchMyLiquidations': True,
119
122
  'fetchMyTrades': True,
120
123
  'fetchOHLCV': True,
@@ -2465,6 +2468,14 @@ class bitget(Exchange, ImplicitAPI):
2465
2468
  return self.parse_order_book(data, market['symbol'], timestamp)
2466
2469
 
2467
2470
  def parse_ticker(self, ticker: dict, market: Market = None) -> Ticker:
2471
+ #
2472
+ # {
2473
+ # "symbol": "BTCUSDT",
2474
+ # "price": "26242",
2475
+ # "indexPrice": "34867",
2476
+ # "markPrice": "25555",
2477
+ # "ts": "1695793390482"
2478
+ # }
2468
2479
  #
2469
2480
  # spot: fetchTicker, fetchTickers
2470
2481
  #
@@ -2569,6 +2580,8 @@ class bitget(Exchange, ImplicitAPI):
2569
2580
  'average': None,
2570
2581
  'baseVolume': self.safe_string(ticker, 'baseVolume'),
2571
2582
  'quoteVolume': self.safe_string(ticker, 'quoteVolume'),
2583
+ 'indexPrice': self.safe_string(ticker, 'indexPrice'),
2584
+ 'markPrice': self.safe_string(ticker, 'markPrice'),
2572
2585
  'info': ticker,
2573
2586
  }, market)
2574
2587
 
@@ -2666,6 +2679,36 @@ class bitget(Exchange, ImplicitAPI):
2666
2679
  data = self.safe_list(response, 'data', [])
2667
2680
  return self.parse_ticker(data[0], market)
2668
2681
 
2682
+ def fetch_mark_price(self, symbol: str, params={}) -> Ticker:
2683
+ """
2684
+ fetches the mark price for a specific market
2685
+ :see: https://www.bitget.com/api-doc/contract/market/Get-Symbol-Price
2686
+ :param str symbol: unified symbol of the market to fetch the ticker for
2687
+ :param dict [params]: extra parameters specific to the exchange API endpoint
2688
+ :returns dict: a `ticker structure <https://docs.ccxt.com/#/?id=ticker-structure>`
2689
+ """
2690
+ self.load_markets()
2691
+ sandboxMode = self.safe_bool(self.options, 'sandboxMode', False)
2692
+ market = None
2693
+ if sandboxMode:
2694
+ sandboxSymbol = self.convert_symbol_for_sandbox(symbol)
2695
+ market = self.market(sandboxSymbol)
2696
+ else:
2697
+ market = self.market(symbol)
2698
+ request: dict = {
2699
+ 'symbol': market['id'],
2700
+ }
2701
+ response = None
2702
+ if market['spot']:
2703
+ raise NotSupported(self.id + ' fetchMarkPrice() is not supported for spot markets')
2704
+ else:
2705
+ productType = None
2706
+ productType, params = self.handle_product_type_and_params(market, params)
2707
+ request['productType'] = productType
2708
+ response = self.publicMixGetV2MixMarketSymbolPrice(self.extend(request, params))
2709
+ data = self.safe_list(response, 'data', [])
2710
+ return self.parse_ticker(data[0], market)
2711
+
2669
2712
  def fetch_tickers(self, symbols: Strings = None, params={}) -> Tickers:
2670
2713
  """
2671
2714
  fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
@@ -6302,14 +6345,29 @@ class bitget(Exchange, ImplicitAPI):
6302
6345
  return self.parse_funding_rate(data[0], market)
6303
6346
 
6304
6347
  def parse_funding_rate(self, contract, market: Market = None) -> FundingRate:
6348
+ #
6349
+ # fetchFundingRate
6305
6350
  #
6306
6351
  # {
6307
6352
  # "symbol": "BTCUSDT",
6308
6353
  # "fundingRate": "-0.000182"
6309
6354
  # }
6310
6355
  #
6356
+ # fetchFundingInterval
6357
+ #
6358
+ # {
6359
+ # "symbol": "BTCUSDT",
6360
+ # "nextFundingTime": "1727942400000",
6361
+ # "ratePeriod": "8"
6362
+ # }
6363
+ #
6311
6364
  marketId = self.safe_string(contract, 'symbol')
6312
6365
  symbol = self.safe_symbol(marketId, market, None, 'swap')
6366
+ fundingTimestamp = self.safe_integer(contract, 'nextFundingTime')
6367
+ interval = self.safe_string(contract, 'ratePeriod')
6368
+ intervalString = None
6369
+ if interval is not None:
6370
+ intervalString = interval + 'h'
6313
6371
  return {
6314
6372
  'info': contract,
6315
6373
  'symbol': symbol,
@@ -6320,15 +6378,15 @@ class bitget(Exchange, ImplicitAPI):
6320
6378
  'timestamp': None,
6321
6379
  'datetime': None,
6322
6380
  'fundingRate': self.safe_number(contract, 'fundingRate'),
6323
- 'fundingTimestamp': None,
6324
- 'fundingDatetime': None,
6381
+ 'fundingTimestamp': fundingTimestamp,
6382
+ 'fundingDatetime': self.iso8601(fundingTimestamp),
6325
6383
  'nextFundingRate': None,
6326
6384
  'nextFundingTimestamp': None,
6327
6385
  'nextFundingDatetime': None,
6328
6386
  'previousFundingRate': None,
6329
6387
  'previousFundingTimestamp': None,
6330
6388
  'previousFundingDatetime': None,
6331
- 'interval': None,
6389
+ 'interval': intervalString,
6332
6390
  }
6333
6391
 
6334
6392
  def fetch_funding_history(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}) -> List[FundingHistory]:
@@ -8172,6 +8230,47 @@ class bitget(Exchange, ImplicitAPI):
8172
8230
  }
8173
8231
  return result
8174
8232
 
8233
+ def fetch_funding_interval(self, symbol: str, params={}) -> FundingRate:
8234
+ """
8235
+ fetch the current funding rate interval
8236
+ :see: https://www.bitget.com/api-doc/contract/market/Get-Symbol-Next-Funding-Time
8237
+ :param str symbol: unified market symbol
8238
+ :param dict [params]: extra parameters specific to the exchange API endpoint
8239
+ :returns dict: a `funding rate structure <https://docs.ccxt.com/#/?id=funding-rate-structure>`
8240
+ """
8241
+ self.load_markets()
8242
+ sandboxMode = self.safe_bool(self.options, 'sandboxMode', False)
8243
+ market = None
8244
+ if sandboxMode:
8245
+ sandboxSymbol = self.convert_symbol_for_sandbox(symbol)
8246
+ market = self.market(sandboxSymbol)
8247
+ else:
8248
+ market = self.market(symbol)
8249
+ productType = None
8250
+ productType, params = self.handle_product_type_and_params(market, params)
8251
+ request: dict = {
8252
+ 'symbol': market['id'],
8253
+ 'productType': productType,
8254
+ }
8255
+ response = self.publicMixGetV2MixMarketFundingTime(self.extend(request, params))
8256
+ #
8257
+ # {
8258
+ # "code": "00000",
8259
+ # "msg": "success",
8260
+ # "requestTime": 1727930153888,
8261
+ # "data": [
8262
+ # {
8263
+ # "symbol": "BTCUSDT",
8264
+ # "nextFundingTime": "1727942400000",
8265
+ # "ratePeriod": "8"
8266
+ # }
8267
+ # ]
8268
+ # }
8269
+ #
8270
+ data = self.safe_list(response, 'data', [])
8271
+ first = self.safe_dict(data, 0, {})
8272
+ return self.parse_funding_rate(first, market)
8273
+
8175
8274
  def handle_errors(self, code: int, reason: str, url: str, method: str, headers: dict, body: str, response, requestHeaders, requestBody):
8176
8275
  if not response:
8177
8276
  return None # fallback to default error handler
ccxt/bitmex.py CHANGED
@@ -1370,6 +1370,7 @@ class bitmex(Exchange, ImplicitAPI):
1370
1370
  'average': None,
1371
1371
  'baseVolume': self.safe_string(ticker, 'homeNotional24h'),
1372
1372
  'quoteVolume': self.safe_string(ticker, 'foreignNotional24h'),
1373
+ 'markPrice': self.safe_string(ticker, 'markPrice'),
1373
1374
  'info': ticker,
1374
1375
  }, market)
1375
1376
 
ccxt/bitrue.py CHANGED
@@ -344,6 +344,7 @@ class bitrue(Exchange, ImplicitAPI):
344
344
  # 'fetchTradesMethod': 'publicGetAggTrades', # publicGetTrades, publicGetHistoricalTrades
345
345
  'fetchMyTradesMethod': 'v2PrivateGetMyTrades', # spotV1PrivateGetMyTrades
346
346
  'hasAlreadyAuthenticatedSuccessfully': False,
347
+ 'currencyToPrecisionRoundingMode': TRUNCATE,
347
348
  'recvWindow': 5 * 1000, # 5 sec, binance default
348
349
  'timeDifference': 0, # the difference between system clock and Binance clock
349
350
  'adjustForTimeDifference': False, # controls the adjustment logic upon instantiation
@@ -533,13 +534,6 @@ class bitrue(Exchange, ImplicitAPI):
533
534
  },
534
535
  })
535
536
 
536
- def currency_to_precision(self, code, fee, networkCode=None):
537
- # info is available in currencies only if the user has configured his api keys
538
- if self.safe_value(self.currencies[code], 'precision') is not None:
539
- return self.decimal_to_precision(fee, TRUNCATE, self.currencies[code]['precision'], self.precisionMode, self.paddingMode)
540
- else:
541
- return self.number_to_string(fee)
542
-
543
537
  def nonce(self):
544
538
  return self.milliseconds() - self.options['timeDifference']
545
539
 
ccxt/bitvavo.py CHANGED
@@ -284,6 +284,7 @@ class bitvavo(Exchange, ImplicitAPI):
284
284
  },
285
285
  },
286
286
  'options': {
287
+ 'currencyToPrecisionRoundingMode': TRUNCATE,
287
288
  'BITVAVO-ACCESS-WINDOW': 10000, # default 10 sec
288
289
  'networks': {
289
290
  'ERC20': 'ETH',
@@ -296,9 +297,6 @@ class bitvavo(Exchange, ImplicitAPI):
296
297
  },
297
298
  })
298
299
 
299
- def currency_to_precision(self, code, fee, networkCode=None):
300
- return self.decimal_to_precision(fee, 0, self.currencies[code]['precision'], DECIMAL_PLACES)
301
-
302
300
  def amount_to_precision(self, symbol, amount):
303
301
  # https://docs.bitfinex.com/docs/introduction#amount-precision
304
302
  # The amount field allows up to 8 decimals.
ccxt/bybit.py CHANGED
@@ -2053,6 +2053,8 @@ class bybit(Exchange, ImplicitAPI):
2053
2053
  'average': None,
2054
2054
  'baseVolume': baseVolume,
2055
2055
  'quoteVolume': quoteVolume,
2056
+ 'markPrice': self.safe_string(ticker, 'markPrice'),
2057
+ 'indexPrice': self.safe_string(ticker, 'indexPrice'),
2056
2058
  'info': ticker,
2057
2059
  }, market)
2058
2060
 
@@ -1426,6 +1426,8 @@ class coinbaseinternational(Exchange, ImplicitAPI):
1426
1426
  'baseVolume': None,
1427
1427
  'quoteVolume': None,
1428
1428
  'previousClose': None,
1429
+ 'markPrice': self.safe_number(ticker, 'mark_price'),
1430
+ 'indexPrice': self.safe_number(ticker, 'index_price'),
1429
1431
  })
1430
1432
 
1431
1433
  def fetch_balance(self, params={}) -> Balances:
ccxt/coinex.py CHANGED
@@ -84,6 +84,8 @@ class coinex(Exchange, ImplicitAPI):
84
84
  'fetchDepositWithdrawFee': True,
85
85
  'fetchDepositWithdrawFees': False,
86
86
  'fetchFundingHistory': True,
87
+ 'fetchFundingInterval': True,
88
+ 'fetchFundingIntervals': False,
87
89
  'fetchFundingRate': True,
88
90
  'fetchFundingRateHistory': True,
89
91
  'fetchFundingRates': True,
@@ -921,6 +923,8 @@ class coinex(Exchange, ImplicitAPI):
921
923
  'average': None,
922
924
  'baseVolume': self.safe_string(ticker, 'volume'),
923
925
  'quoteVolume': None,
926
+ 'markPrice': self.safe_string(ticker, 'mark_price'),
927
+ 'indexPrice': self.safe_string(ticker, 'index_price'),
924
928
  'info': ticker,
925
929
  }, market)
926
930
 
@@ -4291,9 +4295,19 @@ class coinex(Exchange, ImplicitAPI):
4291
4295
  first = self.safe_dict(data, 0, {})
4292
4296
  return self.parse_funding_rate(first, market)
4293
4297
 
4298
+ def fetch_funding_interval(self, symbol: str, params={}) -> FundingRate:
4299
+ """
4300
+ fetch the current funding rate interval
4301
+ :see: https://docs.coinex.com/api/v2/futures/market/http/list-market-funding-rate
4302
+ :param str symbol: unified market symbol
4303
+ :param dict [params]: extra parameters specific to the exchange API endpoint
4304
+ :returns dict: a `funding rate structure <https://docs.ccxt.com/#/?id=funding-rate-structure>`
4305
+ """
4306
+ return self.fetch_funding_rate(symbol, params)
4307
+
4294
4308
  def parse_funding_rate(self, contract, market: Market = None) -> FundingRate:
4295
4309
  #
4296
- # fetchFundingRate, fetchFundingRates
4310
+ # fetchFundingRate, fetchFundingRates, fetchFundingInterval
4297
4311
  #
4298
4312
  # {
4299
4313
  # "latest_funding_rate": "0",
ccxt/cryptocom.py CHANGED
@@ -178,6 +178,7 @@ class cryptocom(Exchange, ImplicitAPI):
178
178
  'public/get-valuations': 1,
179
179
  'public/get-expired-settlement-price': 10 / 3,
180
180
  'public/get-insurance': 1,
181
+ 'public/get-risk-parameters': 1,
181
182
  },
182
183
  'post': {
183
184
  'public/staking/get-conversion-rate': 2,
ccxt/delta.py CHANGED
@@ -946,6 +946,8 @@ class delta(Exchange, ImplicitAPI):
946
946
  'average': None,
947
947
  'baseVolume': self.safe_number(ticker, 'volume'),
948
948
  'quoteVolume': self.safe_number(ticker, 'turnover'),
949
+ 'markPrice': self.safe_number(ticker, 'mark_price'),
950
+ 'indexPrice': self.safe_number(ticker, 'spot_price'),
949
951
  'info': ticker,
950
952
  }, market)
951
953
 
ccxt/deribit.py CHANGED
@@ -1133,6 +1133,8 @@ class deribit(Exchange, ImplicitAPI):
1133
1133
  'average': None,
1134
1134
  'baseVolume': None,
1135
1135
  'quoteVolume': self.safe_string(stats, 'volume'),
1136
+ 'markPrice': self.safe_string(ticker, 'mark_price'),
1137
+ 'indexPrice': self.safe_string(ticker, 'index_price'),
1136
1138
  'info': ticker,
1137
1139
  }, market)
1138
1140
 
ccxt/digifinex.py CHANGED
@@ -71,6 +71,8 @@ class digifinex(Exchange, ImplicitAPI):
71
71
  'fetchDepositWithdrawFee': 'emulated',
72
72
  'fetchDepositWithdrawFees': True,
73
73
  'fetchFundingHistory': True,
74
+ 'fetchFundingInterval': True,
75
+ 'fetchFundingIntervals': False,
74
76
  'fetchFundingRate': True,
75
77
  'fetchFundingRateHistory': True,
76
78
  'fetchFundingRates': False,
@@ -1163,6 +1165,8 @@ class digifinex(Exchange, ImplicitAPI):
1163
1165
  'average': None,
1164
1166
  'baseVolume': self.safe_string_2(ticker, 'vol', 'volume_24h'),
1165
1167
  'quoteVolume': self.safe_string(ticker, 'base_vol'),
1168
+ 'markPrice': self.safe_string(ticker, 'mark_price'),
1169
+ 'indexPrice': indexPrice,
1166
1170
  'info': ticker,
1167
1171
  }, market)
1168
1172
 
@@ -3008,9 +3012,19 @@ class digifinex(Exchange, ImplicitAPI):
3008
3012
  # }
3009
3013
  # }
3010
3014
  #
3011
- data = self.safe_value(response, 'data', {})
3015
+ data = self.safe_dict(response, 'data', {})
3012
3016
  return self.parse_funding_rate(data, market)
3013
3017
 
3018
+ def fetch_funding_interval(self, symbol: str, params={}) -> FundingRate:
3019
+ """
3020
+ fetch the current funding rate interval
3021
+ :see: https://docs.digifinex.com/en-ww/swap/v2/rest.html#currentfundingrate
3022
+ :param str symbol: unified market symbol
3023
+ :param dict [params]: extra parameters specific to the exchange API endpoint
3024
+ :returns dict: a `funding rate structure <https://docs.ccxt.com/#/?id=funding-rate-structure>`
3025
+ """
3026
+ return self.fetch_funding_rate(symbol, params)
3027
+
3014
3028
  def parse_funding_rate(self, contract, market: Market = None) -> FundingRate:
3015
3029
  #
3016
3030
  # {
ccxt/gate.py CHANGED
@@ -2514,6 +2514,8 @@ class gate(Exchange, ImplicitAPI):
2514
2514
  'average': None,
2515
2515
  'baseVolume': baseVolume,
2516
2516
  'quoteVolume': quoteVolume,
2517
+ 'markPrice': self.safe_string(ticker, 'mark_price'),
2518
+ 'indexPrice': self.safe_string(ticker, 'index_price'),
2517
2519
  'info': ticker,
2518
2520
  }, market)
2519
2521
 
ccxt/htx.py CHANGED
@@ -4087,7 +4087,7 @@ class htx(Exchange, ImplicitAPI):
4087
4087
  self.load_accounts()
4088
4088
  for i in range(0, len(self.accounts)):
4089
4089
  account = self.accounts[i]
4090
- if account['type'] == 'spot':
4090
+ if self.safe_string(account, 'type') == 'spot':
4091
4091
  accountId = self.safe_string(account, 'id')
4092
4092
  if accountId is not None:
4093
4093
  break
@@ -4742,7 +4742,7 @@ class htx(Exchange, ImplicitAPI):
4742
4742
  cost = self.safe_string(order, 'amount')
4743
4743
  else:
4744
4744
  amount = self.safe_string_2(order, 'volume', 'amount')
4745
- cost = self.safe_string_n(order, ['filled-cash-amount', 'field-cash-amount', 'trade_turnover']) # same typo
4745
+ cost = self.safe_string_n(order, ['filled-cash-amount', 'field-cash-amount', 'trade_turnover']) # same typo here
4746
4746
  filled = self.safe_string_n(order, ['filled-amount', 'field-amount', 'trade_volume']) # typo in their API, filled amount
4747
4747
  price = self.safe_string_2(order, 'price', 'order_price')
4748
4748
  feeCost = self.safe_string_2(order, 'filled-fees', 'field-fees') # typo in their API, filled feeSide
ccxt/huobijp.py CHANGED
@@ -323,6 +323,7 @@ class huobijp(Exchange, ImplicitAPI):
323
323
  'fetchMarketsMethod': 'publicGetCommonSymbols',
324
324
  'fetchBalanceMethod': 'privateGetAccountAccountsIdBalance',
325
325
  'createOrderMethod': 'privatePostOrderOrdersPlace',
326
+ 'currencyToPrecisionRoundingMode': TRUNCATE,
326
327
  'language': 'en-US',
327
328
  'broker': {
328
329
  'id': 'AA03022abc',
@@ -1561,9 +1562,6 @@ class huobijp(Exchange, ImplicitAPI):
1561
1562
  }),
1562
1563
  ]
1563
1564
 
1564
- def currency_to_precision(self, code, fee, networkCode=None):
1565
- return self.decimal_to_precision(fee, 0, self.currencies[code]['precision'], self.precisionMode)
1566
-
1567
1565
  def parse_deposit_address(self, depositAddress, currency: Currency = None):
1568
1566
  #
1569
1567
  # {
ccxt/krakenfutures.py CHANGED
@@ -611,6 +611,8 @@ class krakenfutures(Exchange, ImplicitAPI):
611
611
  'average': average,
612
612
  'baseVolume': baseVolume,
613
613
  'quoteVolume': quoteVolume,
614
+ 'markPrice': self.safe_string(ticker, 'markPrice'),
615
+ 'indexPrice': self.safe_string(ticker, 'indexPrice'),
614
616
  'info': ticker,
615
617
  })
616
618
 
ccxt/kucoin.py CHANGED
@@ -97,6 +97,8 @@ class kucoin(Exchange, ImplicitAPI):
97
97
  'fetchMarketLeverageTiers': False,
98
98
  'fetchMarkets': True,
99
99
  'fetchMarkOHLCV': False,
100
+ 'fetchMarkPrice': True,
101
+ 'fetchMarkPrices': True,
100
102
  'fetchMyTrades': True,
101
103
  'fetchOHLCV': True,
102
104
  'fetchOpenInterest': False,
@@ -1643,7 +1645,7 @@ class kucoin(Exchange, ImplicitAPI):
1643
1645
  symbol = market['symbol']
1644
1646
  baseVolume = self.safe_string(ticker, 'vol')
1645
1647
  quoteVolume = self.safe_string(ticker, 'volValue')
1646
- timestamp = self.safe_integer_2(ticker, 'time', 'datetime')
1648
+ timestamp = self.safe_integer_n(ticker, ['time', 'datetime', 'timePoint'])
1647
1649
  return self.safe_ticker({
1648
1650
  'symbol': symbol,
1649
1651
  'timestamp': timestamp,
@@ -1664,6 +1666,7 @@ class kucoin(Exchange, ImplicitAPI):
1664
1666
  'average': self.safe_string(ticker, 'averagePrice'),
1665
1667
  'baseVolume': baseVolume,
1666
1668
  'quoteVolume': quoteVolume,
1669
+ 'markPrice': self.safe_string(ticker, 'value'),
1667
1670
  'info': ticker,
1668
1671
  }, market)
1669
1672
 
@@ -1718,6 +1721,20 @@ class kucoin(Exchange, ImplicitAPI):
1718
1721
  result[symbol] = ticker
1719
1722
  return self.filter_by_array_tickers(result, 'symbol', symbols)
1720
1723
 
1724
+ def fetch_mark_prices(self, symbols: Strings = None, params={}) -> Tickers:
1725
+ """
1726
+ fetches the mark price for multiple markets
1727
+ :see: https://www.kucoin.com/docs/rest/margin-trading/margin-info/get-all-margin-trading-pairs-mark-prices
1728
+ :param str[] [symbols]: unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
1729
+ :param dict [params]: extra parameters specific to the exchange API endpoint
1730
+ :returns dict: a dictionary of `ticker structures <https://docs.ccxt.com/#/?id=ticker-structure>`
1731
+ """
1732
+ self.load_markets()
1733
+ symbols = self.market_symbols(symbols)
1734
+ response = self.publicGetMarkPriceAllSymbols(params)
1735
+ data = self.safe_list(response, 'data', [])
1736
+ return self.parse_tickers(data)
1737
+
1721
1738
  def fetch_ticker(self, symbol: str, params={}) -> Ticker:
1722
1739
  """
1723
1740
  fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
@@ -1758,6 +1775,24 @@ class kucoin(Exchange, ImplicitAPI):
1758
1775
  data = self.safe_dict(response, 'data', {})
1759
1776
  return self.parse_ticker(data, market)
1760
1777
 
1778
+ def fetch_mark_price(self, symbol: str, params={}) -> Ticker:
1779
+ """
1780
+ fetches the mark price for a specific market
1781
+ :see: https://www.kucoin.com/docs/rest/margin-trading/margin-info/get-mark-price
1782
+ :param str symbol: unified symbol of the market to fetch the ticker for
1783
+ :param dict [params]: extra parameters specific to the exchange API endpoint
1784
+ :returns dict: a `ticker structure <https://docs.ccxt.com/#/?id=ticker-structure>`
1785
+ """
1786
+ self.load_markets()
1787
+ market = self.market(symbol)
1788
+ request: dict = {
1789
+ 'symbol': market['id'],
1790
+ }
1791
+ response = self.publicGetMarkPriceSymbolCurrent(self.extend(request, params))
1792
+ #
1793
+ data = self.safe_dict(response, 'data', {})
1794
+ return self.parse_ticker(data, market)
1795
+
1761
1796
  def parse_ohlcv(self, ohlcv, market: Market = None) -> list:
1762
1797
  #
1763
1798
  # [
ccxt/kucoinfutures.py CHANGED
@@ -73,6 +73,8 @@ class kucoinfutures(kucoin, ImplicitAPI):
73
73
  'fetchDepositWithdrawFee': False,
74
74
  'fetchDepositWithdrawFees': False,
75
75
  'fetchFundingHistory': True,
76
+ 'fetchFundingInterval': True,
77
+ 'fetchFundingIntervals': False,
76
78
  'fetchFundingRate': True,
77
79
  'fetchFundingRateHistory': True,
78
80
  'fetchIndexOHLCV': False,
@@ -87,6 +89,7 @@ class kucoinfutures(kucoin, ImplicitAPI):
87
89
  'fetchMarketLeverageTiers': True,
88
90
  'fetchMarkets': True,
89
91
  'fetchMarkOHLCV': False,
92
+ 'fetchMarkPrice': True,
90
93
  'fetchMyTrades': True,
91
94
  'fetchOHLCV': True,
92
95
  'fetchOpenOrders': True,
@@ -757,6 +760,23 @@ class kucoinfutures(kucoin, ImplicitAPI):
757
760
  #
758
761
  return self.parse_ticker(response['data'], market)
759
762
 
763
+ def fetch_mark_price(self, symbol: str, params={}) -> Ticker:
764
+ """
765
+ fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
766
+ :see: https://www.kucoin.com/docs/rest/futures-trading/market-data/get-current-mark-price
767
+ :param str symbol: unified symbol of the market to fetch the ticker for
768
+ :param dict [params]: extra parameters specific to the exchange API endpoint
769
+ :returns dict: a `ticker structure <https://docs.ccxt.com/#/?id=ticker-structure>`
770
+ """
771
+ self.load_markets()
772
+ market = self.market(symbol)
773
+ request: dict = {
774
+ 'symbol': market['id'],
775
+ }
776
+ response = self.futuresPublicGetMarkPriceSymbolCurrent(self.extend(request, params))
777
+ #
778
+ return self.parse_ticker(response['data'], market)
779
+
760
780
  def fetch_tickers(self, symbols: Strings = None, params={}) -> Tickers:
761
781
  """
762
782
  fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
@@ -842,6 +862,14 @@ class kucoinfutures(kucoin, ImplicitAPI):
842
862
  return self.filter_by_array_tickers(tickers, 'symbol', symbols)
843
863
 
844
864
  def parse_ticker(self, ticker: dict, market: Market = None) -> Ticker:
865
+ #
866
+ # {
867
+ # "symbol": "LTCUSDTM",
868
+ # "granularity": 1000,
869
+ # "timePoint": 1727967339000,
870
+ # "value": 62.37, mark price
871
+ # "indexPrice": 62.37
872
+ # }
845
873
  #
846
874
  # {
847
875
  # "code": "200000",
@@ -944,6 +972,8 @@ class kucoinfutures(kucoin, ImplicitAPI):
944
972
  'average': None,
945
973
  'baseVolume': self.safe_string(ticker, 'volumeOf24h'),
946
974
  'quoteVolume': self.safe_string(ticker, 'turnoverOf24h'),
975
+ 'markPrice': self.safe_string_2(ticker, 'markPrice', 'value'),
976
+ 'indexPrice': self.safe_string(ticker, 'indexPrice'),
947
977
  'info': ticker,
948
978
  }, market)
949
979
 
@@ -2072,12 +2102,35 @@ class kucoinfutures(kucoin, ImplicitAPI):
2072
2102
  # },
2073
2103
  # }
2074
2104
  #
2075
- data = self.safe_value(response, 'data')
2076
- fundingTimestamp = self.safe_integer(data, 'timePoint')
2105
+ data = self.safe_dict(response, 'data', {})
2077
2106
  # the website displayes the previous funding rate as "funding rate"
2107
+ return self.parse_funding_rate(data, market)
2108
+
2109
+ def fetch_funding_interval(self, symbol: str, params={}) -> FundingRate:
2110
+ """
2111
+ fetch the current funding rate interval
2112
+ :see: https://www.kucoin.com/docs/rest/futures-trading/funding-fees/get-current-funding-rate
2113
+ :param str symbol: unified market symbol
2114
+ :param dict [params]: extra parameters specific to the exchange API endpoint
2115
+ :returns dict: a `funding rate structure <https://docs.ccxt.com/#/?id=funding-rate-structure>`
2116
+ """
2117
+ return self.fetch_funding_rate(symbol, params)
2118
+
2119
+ def parse_funding_rate(self, data, market: Market = None) -> FundingRate:
2120
+ #
2121
+ # {
2122
+ # "symbol": ".ETHUSDTMFPI8H",
2123
+ # "granularity": 28800000,
2124
+ # "timePoint": 1637380800000,
2125
+ # "value": 0.0001,
2126
+ # "predictedValue": 0.0001,
2127
+ # }
2128
+ #
2129
+ fundingTimestamp = self.safe_integer(data, 'timePoint')
2130
+ marketId = self.safe_string(data, 'symbol')
2078
2131
  return {
2079
2132
  'info': data,
2080
- 'symbol': market['symbol'],
2133
+ 'symbol': self.safe_symbol(marketId, market, None, 'contract'),
2081
2134
  'markPrice': None,
2082
2135
  'indexPrice': None,
2083
2136
  'interestRate': None,