ccxt 4.4.13__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 (51) 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 +34 -1
  9. ccxt/async_support/binance.py +69 -11
  10. ccxt/async_support/bitget.py +101 -3
  11. ccxt/async_support/bitrue.py +1 -7
  12. ccxt/async_support/bitvavo.py +1 -3
  13. ccxt/async_support/coinex.py +13 -1
  14. ccxt/async_support/cryptocom.py +1 -0
  15. ccxt/async_support/digifinex.py +13 -1
  16. ccxt/async_support/huobijp.py +1 -3
  17. ccxt/async_support/kucoin.py +36 -1
  18. ccxt/async_support/kucoinfutures.py +55 -4
  19. ccxt/async_support/mexc.py +52 -8
  20. ccxt/async_support/okx.py +12 -0
  21. ccxt/async_support/poloniexfutures.py +35 -11
  22. ccxt/async_support/woo.py +12 -0
  23. ccxt/async_support/woofipro.py +12 -0
  24. ccxt/async_support/xt.py +12 -0
  25. ccxt/base/exchange.py +38 -2
  26. ccxt/binance.py +69 -11
  27. ccxt/bitget.py +101 -3
  28. ccxt/bitrue.py +1 -7
  29. ccxt/bitvavo.py +1 -3
  30. ccxt/coinex.py +13 -1
  31. ccxt/cryptocom.py +1 -0
  32. ccxt/digifinex.py +13 -1
  33. ccxt/huobijp.py +1 -3
  34. ccxt/kucoin.py +36 -1
  35. ccxt/kucoinfutures.py +55 -4
  36. ccxt/mexc.py +52 -8
  37. ccxt/okx.py +12 -0
  38. ccxt/poloniexfutures.py +35 -11
  39. ccxt/pro/__init__.py +1 -1
  40. ccxt/pro/okx.py +38 -0
  41. ccxt/test/tests_async.py +53 -53
  42. ccxt/test/tests_helpers.py +14 -0
  43. ccxt/test/tests_sync.py +53 -53
  44. ccxt/woo.py +12 -0
  45. ccxt/woofipro.py +12 -0
  46. ccxt/xt.py +12 -0
  47. {ccxt-4.4.13.dist-info → ccxt-4.4.14.dist-info}/METADATA +4 -4
  48. {ccxt-4.4.13.dist-info → ccxt-4.4.14.dist-info}/RECORD +51 -51
  49. {ccxt-4.4.13.dist-info → ccxt-4.4.14.dist-info}/LICENSE.txt +0 -0
  50. {ccxt-4.4.13.dist-info → ccxt-4.4.14.dist-info}/WHEEL +0 -0
  51. {ccxt-4.4.13.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
  #
@@ -2570,6 +2581,7 @@ class bitget(Exchange, ImplicitAPI):
2570
2581
  'baseVolume': self.safe_string(ticker, 'baseVolume'),
2571
2582
  'quoteVolume': self.safe_string(ticker, 'quoteVolume'),
2572
2583
  'indexPrice': self.safe_string(ticker, 'indexPrice'),
2584
+ 'markPrice': self.safe_string(ticker, 'markPrice'),
2573
2585
  'info': ticker,
2574
2586
  }, market)
2575
2587
 
@@ -2667,6 +2679,36 @@ class bitget(Exchange, ImplicitAPI):
2667
2679
  data = self.safe_list(response, 'data', [])
2668
2680
  return self.parse_ticker(data[0], market)
2669
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
+
2670
2712
  def fetch_tickers(self, symbols: Strings = None, params={}) -> Tickers:
2671
2713
  """
2672
2714
  fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
@@ -6303,14 +6345,29 @@ class bitget(Exchange, ImplicitAPI):
6303
6345
  return self.parse_funding_rate(data[0], market)
6304
6346
 
6305
6347
  def parse_funding_rate(self, contract, market: Market = None) -> FundingRate:
6348
+ #
6349
+ # fetchFundingRate
6306
6350
  #
6307
6351
  # {
6308
6352
  # "symbol": "BTCUSDT",
6309
6353
  # "fundingRate": "-0.000182"
6310
6354
  # }
6311
6355
  #
6356
+ # fetchFundingInterval
6357
+ #
6358
+ # {
6359
+ # "symbol": "BTCUSDT",
6360
+ # "nextFundingTime": "1727942400000",
6361
+ # "ratePeriod": "8"
6362
+ # }
6363
+ #
6312
6364
  marketId = self.safe_string(contract, 'symbol')
6313
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'
6314
6371
  return {
6315
6372
  'info': contract,
6316
6373
  'symbol': symbol,
@@ -6321,15 +6378,15 @@ class bitget(Exchange, ImplicitAPI):
6321
6378
  'timestamp': None,
6322
6379
  'datetime': None,
6323
6380
  'fundingRate': self.safe_number(contract, 'fundingRate'),
6324
- 'fundingTimestamp': None,
6325
- 'fundingDatetime': None,
6381
+ 'fundingTimestamp': fundingTimestamp,
6382
+ 'fundingDatetime': self.iso8601(fundingTimestamp),
6326
6383
  'nextFundingRate': None,
6327
6384
  'nextFundingTimestamp': None,
6328
6385
  'nextFundingDatetime': None,
6329
6386
  'previousFundingRate': None,
6330
6387
  'previousFundingTimestamp': None,
6331
6388
  'previousFundingDatetime': None,
6332
- 'interval': None,
6389
+ 'interval': intervalString,
6333
6390
  }
6334
6391
 
6335
6392
  def fetch_funding_history(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}) -> List[FundingHistory]:
@@ -8173,6 +8230,47 @@ class bitget(Exchange, ImplicitAPI):
8173
8230
  }
8174
8231
  return result
8175
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
+
8176
8274
  def handle_errors(self, code: int, reason: str, url: str, method: str, headers: dict, body: str, response, requestHeaders, requestBody):
8177
8275
  if not response:
8178
8276
  return None # fallback to default error handler
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/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,
@@ -4293,9 +4295,19 @@ class coinex(Exchange, ImplicitAPI):
4293
4295
  first = self.safe_dict(data, 0, {})
4294
4296
  return self.parse_funding_rate(first, market)
4295
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
+
4296
4308
  def parse_funding_rate(self, contract, market: Market = None) -> FundingRate:
4297
4309
  #
4298
- # fetchFundingRate, fetchFundingRates
4310
+ # fetchFundingRate, fetchFundingRates, fetchFundingInterval
4299
4311
  #
4300
4312
  # {
4301
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/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,
@@ -3010,9 +3012,19 @@ class digifinex(Exchange, ImplicitAPI):
3010
3012
  # }
3011
3013
  # }
3012
3014
  #
3013
- data = self.safe_value(response, 'data', {})
3015
+ data = self.safe_dict(response, 'data', {})
3014
3016
  return self.parse_funding_rate(data, market)
3015
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
+
3016
3028
  def parse_funding_rate(self, contract, market: Market = None) -> FundingRate:
3017
3029
  #
3018
3030
  # {
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/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,7 +972,7 @@ class kucoinfutures(kucoin, ImplicitAPI):
944
972
  'average': None,
945
973
  'baseVolume': self.safe_string(ticker, 'volumeOf24h'),
946
974
  'quoteVolume': self.safe_string(ticker, 'turnoverOf24h'),
947
- 'markPrice': self.safe_string(ticker, 'markPrice'),
975
+ 'markPrice': self.safe_string_2(ticker, 'markPrice', 'value'),
948
976
  'indexPrice': self.safe_string(ticker, 'indexPrice'),
949
977
  'info': ticker,
950
978
  }, market)
@@ -2074,12 +2102,35 @@ class kucoinfutures(kucoin, ImplicitAPI):
2074
2102
  # },
2075
2103
  # }
2076
2104
  #
2077
- data = self.safe_value(response, 'data')
2078
- fundingTimestamp = self.safe_integer(data, 'timePoint')
2105
+ data = self.safe_dict(response, 'data', {})
2079
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')
2080
2131
  return {
2081
2132
  'info': data,
2082
- 'symbol': market['symbol'],
2133
+ 'symbol': self.safe_symbol(marketId, market, None, 'contract'),
2083
2134
  'markPrice': None,
2084
2135
  'indexPrice': None,
2085
2136
  'interestRate': None,
ccxt/mexc.py CHANGED
@@ -89,6 +89,8 @@ class mexc(Exchange, ImplicitAPI):
89
89
  'fetchDepositWithdrawFee': 'emulated',
90
90
  'fetchDepositWithdrawFees': True,
91
91
  'fetchFundingHistory': True,
92
+ 'fetchFundingInterval': True,
93
+ 'fetchFundingIntervals': False,
92
94
  'fetchFundingRate': True,
93
95
  'fetchFundingRateHistory': True,
94
96
  'fetchFundingRates': None,
@@ -2468,6 +2470,7 @@ class mexc(Exchange, ImplicitAPI):
2468
2470
  :param int [since]: the earliest time in ms to fetch orders for
2469
2471
  :param int [limit]: the maximum number of order structures to retrieve
2470
2472
  :param dict [params]: extra parameters specific to the exchange API endpoint
2473
+ :param int [params.until]: the latest time in ms to fetch orders for
2471
2474
  :param str [params.marginMode]: only 'isolated' is supported, for spot-margin trading
2472
2475
  :returns Order[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
2473
2476
  """
@@ -2477,6 +2480,8 @@ class mexc(Exchange, ImplicitAPI):
2477
2480
  if symbol is not None:
2478
2481
  market = self.market(symbol)
2479
2482
  request['symbol'] = market['id']
2483
+ until = self.safe_integer(params, 'until')
2484
+ params = self.omit(params, 'until')
2480
2485
  marketType, query = self.handle_market_type_and_params('fetchOrders', market, params)
2481
2486
  if marketType == 'spot':
2482
2487
  if symbol is None:
@@ -2484,6 +2489,8 @@ class mexc(Exchange, ImplicitAPI):
2484
2489
  marginMode, queryInner = self.handle_margin_mode_and_params('fetchOrders', params)
2485
2490
  if since is not None:
2486
2491
  request['startTime'] = since
2492
+ if until is not None:
2493
+ request['endTime'] = until
2487
2494
  if limit is not None:
2488
2495
  request['limit'] = limit
2489
2496
  response = None
@@ -2545,9 +2552,17 @@ class mexc(Exchange, ImplicitAPI):
2545
2552
  else:
2546
2553
  if since is not None:
2547
2554
  request['start_time'] = since
2548
- end = self.safe_integer(params, 'end_time')
2555
+ end = self.safe_integer(params, 'end_time', until)
2549
2556
  if end is None:
2550
2557
  request['end_time'] = self.sum(since, self.options['maxTimeTillEnd'])
2558
+ else:
2559
+ if (end - since) > self.options['maxTimeTillEnd']:
2560
+ raise BadRequest(self.id + ' end is invalid, i.e. exceeds allowed 90 days.')
2561
+ else:
2562
+ request['end_time'] = until
2563
+ elif until is not None:
2564
+ request['start_time'] = self.sum(until, self.options['maxTimeTillEnd'] * -1)
2565
+ request['end_time'] = until
2551
2566
  if limit is not None:
2552
2567
  request['page_size'] = limit
2553
2568
  method = self.safe_string(self.options, 'fetchOrders', 'contractPrivateGetOrderListHistoryOrders')
@@ -3937,9 +3952,12 @@ class mexc(Exchange, ImplicitAPI):
3937
3952
  nextFundingRate = self.safe_number(contract, 'fundingRate')
3938
3953
  nextFundingTimestamp = self.safe_integer(contract, 'nextSettleTime')
3939
3954
  marketId = self.safe_string(contract, 'symbol')
3940
- symbol = self.safe_symbol(marketId, market)
3955
+ symbol = self.safe_symbol(marketId, market, None, 'contract')
3941
3956
  timestamp = self.safe_integer(contract, 'timestamp')
3942
- datetime = self.iso8601(timestamp)
3957
+ interval = self.safe_string(contract, 'collectCycle')
3958
+ intervalString = None
3959
+ if interval is not None:
3960
+ intervalString = interval + 'h'
3943
3961
  return {
3944
3962
  'info': contract,
3945
3963
  'symbol': symbol,
@@ -3948,7 +3966,7 @@ class mexc(Exchange, ImplicitAPI):
3948
3966
  'interestRate': None,
3949
3967
  'estimatedSettlePrice': None,
3950
3968
  'timestamp': timestamp,
3951
- 'datetime': datetime,
3969
+ 'datetime': self.iso8601(timestamp),
3952
3970
  'fundingRate': nextFundingRate,
3953
3971
  'fundingTimestamp': nextFundingTimestamp,
3954
3972
  'fundingDatetime': self.iso8601(nextFundingTimestamp),
@@ -3958,9 +3976,19 @@ class mexc(Exchange, ImplicitAPI):
3958
3976
  'previousFundingRate': None,
3959
3977
  'previousFundingTimestamp': None,
3960
3978
  'previousFundingDatetime': None,
3961
- 'interval': None,
3979
+ 'interval': intervalString,
3962
3980
  }
3963
3981
 
3982
+ def fetch_funding_interval(self, symbol: str, params={}) -> FundingRate:
3983
+ """
3984
+ fetch the current funding rate interval
3985
+ :see: https://mexcdevelop.github.io/apidocs/contract_v1_en/#get-contract-funding-rate
3986
+ :param str symbol: unified market symbol
3987
+ :param dict [params]: extra parameters specific to the exchange API endpoint
3988
+ :returns dict: a `funding rate structure <https://docs.ccxt.com/#/?id=funding-rate-structure>`
3989
+ """
3990
+ return self.fetch_funding_rate(symbol, params)
3991
+
3964
3992
  def fetch_funding_rate(self, symbol: str, params={}) -> FundingRate:
3965
3993
  """
3966
3994
  fetch the current funding rate
@@ -4229,7 +4257,15 @@ class mexc(Exchange, ImplicitAPI):
4229
4257
  networkCode = self.safe_string(params, 'network')
4230
4258
  networkId = None
4231
4259
  if networkCode is not None:
4232
- networkId = self.network_code_to_id(networkCode, code)
4260
+ # createDepositAddress and fetchDepositAddress use a different network-id compared to withdraw
4261
+ networkUnified = self.network_id_to_code(networkCode, code)
4262
+ networks = self.safe_dict(currency, 'networks', {})
4263
+ if networkUnified in networks:
4264
+ network = self.safe_dict(networks, networkUnified, {})
4265
+ networkInfo = self.safe_value(network, 'info', {})
4266
+ networkId = self.safe_string(networkInfo, 'network')
4267
+ else:
4268
+ networkId = self.network_code_to_id(networkCode, code)
4233
4269
  if networkId is not None:
4234
4270
  request['network'] = networkId
4235
4271
  params = self.omit(params, 'network')
@@ -4265,7 +4301,16 @@ class mexc(Exchange, ImplicitAPI):
4265
4301
  networkCode = self.safe_string(params, 'network')
4266
4302
  if networkCode is None:
4267
4303
  raise ArgumentsRequired(self.id + ' createDepositAddress requires a `network` parameter')
4268
- networkId = self.network_code_to_id(networkCode, code)
4304
+ # createDepositAddress and fetchDepositAddress use a different network-id compared to withdraw
4305
+ networkId = None
4306
+ networkUnified = self.network_id_to_code(networkCode, code)
4307
+ networks = self.safe_dict(currency, 'networks', {})
4308
+ if networkUnified in networks:
4309
+ network = self.safe_dict(networks, networkUnified, {})
4310
+ networkInfo = self.safe_value(network, 'info', {})
4311
+ networkId = self.safe_string(networkInfo, 'network')
4312
+ else:
4313
+ networkId = self.network_code_to_id(networkCode, code)
4269
4314
  if networkId is not None:
4270
4315
  request['network'] = networkId
4271
4316
  params = self.omit(params, 'network')
@@ -4288,7 +4333,6 @@ class mexc(Exchange, ImplicitAPI):
4288
4333
  :returns dict: an `address structure <https://docs.ccxt.com/#/?id=address-structure>`
4289
4334
  """
4290
4335
  network = self.safe_string(params, 'network')
4291
- params = self.omit(params, ['network'])
4292
4336
  addressStructures = self.fetch_deposit_addresses_by_network(code, params)
4293
4337
  result = None
4294
4338
  if network is not None:
ccxt/okx.py CHANGED
@@ -104,6 +104,8 @@ class okx(Exchange, ImplicitAPI):
104
104
  'fetchDepositWithdrawFee': 'emulated',
105
105
  'fetchDepositWithdrawFees': True,
106
106
  'fetchFundingHistory': True,
107
+ 'fetchFundingInterval': True,
108
+ 'fetchFundingIntervals': False,
107
109
  'fetchFundingRate': True,
108
110
  'fetchFundingRateHistory': True,
109
111
  'fetchFundingRates': False,
@@ -5725,6 +5727,16 @@ class okx(Exchange, ImplicitAPI):
5725
5727
  }
5726
5728
  return self.safe_string(intervals, interval, interval)
5727
5729
 
5730
+ def fetch_funding_interval(self, symbol: str, params={}) -> FundingRate:
5731
+ """
5732
+ fetch the current funding rate interval
5733
+ :see: https://www.okx.com/docs-v5/en/#public-data-rest-api-get-funding-rate
5734
+ :param str symbol: unified market symbol
5735
+ :param dict [params]: extra parameters specific to the exchange API endpoint
5736
+ :returns dict: a `funding rate structure <https://docs.ccxt.com/#/?id=funding-rate-structure>`
5737
+ """
5738
+ return self.fetch_funding_rate(symbol, params)
5739
+
5728
5740
  def fetch_funding_rate(self, symbol: str, params={}) -> FundingRate:
5729
5741
  """
5730
5742
  fetch the current funding rate