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/__init__.py CHANGED
@@ -22,7 +22,7 @@
22
22
 
23
23
  # ----------------------------------------------------------------------------
24
24
 
25
- __version__ = '4.4.12'
25
+ __version__ = '4.4.14'
26
26
 
27
27
  # ----------------------------------------------------------------------------
28
28
 
ccxt/abstract/binance.py CHANGED
@@ -414,6 +414,7 @@ class ImplicitAPI:
414
414
  dapipublic_get_ticker_bookticker = dapiPublicGetTickerBookTicker = Entry('ticker/bookTicker', 'dapiPublic', 'GET', {'cost': 2, 'noSymbol': 5})
415
415
  dapipublic_get_constituents = dapiPublicGetConstituents = Entry('constituents', 'dapiPublic', 'GET', {'cost': 2})
416
416
  dapipublic_get_openinterest = dapiPublicGetOpenInterest = Entry('openInterest', 'dapiPublic', 'GET', {'cost': 1})
417
+ dapipublic_get_fundinginfo = dapiPublicGetFundingInfo = Entry('fundingInfo', 'dapiPublic', 'GET', {'cost': 1})
417
418
  dapidata_get_delivery_price = dapiDataGetDeliveryPrice = Entry('delivery-price', 'dapiData', 'GET', {'cost': 1})
418
419
  dapidata_get_openinteresthist = dapiDataGetOpenInterestHist = Entry('openInterestHist', 'dapiData', 'GET', {'cost': 1})
419
420
  dapidata_get_toplongshortaccountratio = dapiDataGetTopLongShortAccountRatio = Entry('topLongShortAccountRatio', 'dapiData', 'GET', {'cost': 1})
@@ -414,6 +414,7 @@ class ImplicitAPI:
414
414
  dapipublic_get_ticker_bookticker = dapiPublicGetTickerBookTicker = Entry('ticker/bookTicker', 'dapiPublic', 'GET', {'cost': 2, 'noSymbol': 5})
415
415
  dapipublic_get_constituents = dapiPublicGetConstituents = Entry('constituents', 'dapiPublic', 'GET', {'cost': 2})
416
416
  dapipublic_get_openinterest = dapiPublicGetOpenInterest = Entry('openInterest', 'dapiPublic', 'GET', {'cost': 1})
417
+ dapipublic_get_fundinginfo = dapiPublicGetFundingInfo = Entry('fundingInfo', 'dapiPublic', 'GET', {'cost': 1})
417
418
  dapidata_get_delivery_price = dapiDataGetDeliveryPrice = Entry('delivery-price', 'dapiData', 'GET', {'cost': 1})
418
419
  dapidata_get_openinteresthist = dapiDataGetOpenInterestHist = Entry('openInterestHist', 'dapiData', 'GET', {'cost': 1})
419
420
  dapidata_get_toplongshortaccountratio = dapiDataGetTopLongShortAccountRatio = Entry('topLongShortAccountRatio', 'dapiData', 'GET', {'cost': 1})
@@ -466,6 +466,7 @@ class ImplicitAPI:
466
466
  dapipublic_get_ticker_bookticker = dapiPublicGetTickerBookTicker = Entry('ticker/bookTicker', 'dapiPublic', 'GET', {'cost': 2, 'noSymbol': 5})
467
467
  dapipublic_get_constituents = dapiPublicGetConstituents = Entry('constituents', 'dapiPublic', 'GET', {'cost': 2})
468
468
  dapipublic_get_openinterest = dapiPublicGetOpenInterest = Entry('openInterest', 'dapiPublic', 'GET', {'cost': 1})
469
+ dapipublic_get_fundinginfo = dapiPublicGetFundingInfo = Entry('fundingInfo', 'dapiPublic', 'GET', {'cost': 1})
469
470
  dapidata_get_delivery_price = dapiDataGetDeliveryPrice = Entry('delivery-price', 'dapiData', 'GET', {'cost': 1})
470
471
  dapidata_get_openinteresthist = dapiDataGetOpenInterestHist = Entry('openInterestHist', 'dapiData', 'GET', {'cost': 1})
471
472
  dapidata_get_toplongshortaccountratio = dapiDataGetTopLongShortAccountRatio = Entry('topLongShortAccountRatio', 'dapiData', 'GET', {'cost': 1})
@@ -414,6 +414,7 @@ class ImplicitAPI:
414
414
  dapipublic_get_ticker_bookticker = dapiPublicGetTickerBookTicker = Entry('ticker/bookTicker', 'dapiPublic', 'GET', {'cost': 2, 'noSymbol': 5})
415
415
  dapipublic_get_constituents = dapiPublicGetConstituents = Entry('constituents', 'dapiPublic', 'GET', {'cost': 2})
416
416
  dapipublic_get_openinterest = dapiPublicGetOpenInterest = Entry('openInterest', 'dapiPublic', 'GET', {'cost': 1})
417
+ dapipublic_get_fundinginfo = dapiPublicGetFundingInfo = Entry('fundingInfo', 'dapiPublic', 'GET', {'cost': 1})
417
418
  dapidata_get_delivery_price = dapiDataGetDeliveryPrice = Entry('delivery-price', 'dapiData', 'GET', {'cost': 1})
418
419
  dapidata_get_openinteresthist = dapiDataGetOpenInterestHist = Entry('openInterestHist', 'dapiData', 'GET', {'cost': 1})
419
420
  dapidata_get_toplongshortaccountratio = dapiDataGetTopLongShortAccountRatio = Entry('topLongShortAccountRatio', 'dapiData', 'GET', {'cost': 1})
@@ -11,6 +11,7 @@ class ImplicitAPI:
11
11
  v1_public_get_public_get_valuations = v1PublicGetPublicGetValuations = Entry('public/get-valuations', ['v1', 'public'], 'GET', {'cost': 1})
12
12
  v1_public_get_public_get_expired_settlement_price = v1PublicGetPublicGetExpiredSettlementPrice = Entry('public/get-expired-settlement-price', ['v1', 'public'], 'GET', {'cost': 3.3333333333333335})
13
13
  v1_public_get_public_get_insurance = v1PublicGetPublicGetInsurance = Entry('public/get-insurance', ['v1', 'public'], 'GET', {'cost': 1})
14
+ v1_public_get_public_get_risk_parameters = v1PublicGetPublicGetRiskParameters = Entry('public/get-risk-parameters', ['v1', 'public'], 'GET', {'cost': 1})
14
15
  v1_public_post_public_staking_get_conversion_rate = v1PublicPostPublicStakingGetConversionRate = Entry('public/staking/get-conversion-rate', ['v1', 'public'], 'POST', {'cost': 2})
15
16
  v1_private_post_private_set_cancel_on_disconnect = v1PrivatePostPrivateSetCancelOnDisconnect = Entry('private/set-cancel-on-disconnect', ['v1', 'private'], 'POST', {'cost': 3.3333333333333335})
16
17
  v1_private_post_private_get_cancel_on_disconnect = v1PrivatePostPrivateGetCancelOnDisconnect = Entry('private/get-cancel-on-disconnect', ['v1', 'private'], 'POST', {'cost': 3.3333333333333335})
@@ -4,7 +4,7 @@
4
4
 
5
5
  # -----------------------------------------------------------------------------
6
6
 
7
- __version__ = '4.4.12'
7
+ __version__ = '4.4.14'
8
8
 
9
9
  # -----------------------------------------------------------------------------
10
10
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  # -----------------------------------------------------------------------------
4
4
 
5
- __version__ = '4.4.12'
5
+ __version__ = '4.4.14'
6
6
 
7
7
  # -----------------------------------------------------------------------------
8
8
 
@@ -661,6 +661,9 @@ class Exchange(BaseExchange):
661
661
  async def fetch_funding_rates(self, symbols: Strings = None, params={}):
662
662
  raise NotSupported(self.id + ' fetchFundingRates() is not supported yet')
663
663
 
664
+ async def fetch_funding_intervals(self, symbols: Strings = None, params={}):
665
+ raise NotSupported(self.id + ' fetchFundingIntervals() is not supported yet')
666
+
664
667
  async def watch_funding_rate(self, symbol: str, params={}):
665
668
  raise NotSupported(self.id + ' watchFundingRate() is not supported yet')
666
669
 
@@ -1016,6 +1019,20 @@ class Exchange(BaseExchange):
1016
1019
  else:
1017
1020
  raise NotSupported(self.id + ' fetchTicker() is not supported yet')
1018
1021
 
1022
+ async def fetch_mark_price(self, symbol: str, params={}):
1023
+ if self.has['fetchMarkPrices']:
1024
+ await self.load_markets()
1025
+ market = self.market(symbol)
1026
+ symbol = market['symbol']
1027
+ tickers = await self.fetch_mark_prices([symbol], params)
1028
+ ticker = self.safe_dict(tickers, symbol)
1029
+ if ticker is None:
1030
+ raise NullResponse(self.id + ' fetchMarkPrices() could not find a ticker for ' + symbol)
1031
+ else:
1032
+ return ticker
1033
+ else:
1034
+ raise NotSupported(self.id + ' fetchMarkPrices() is not supported yet')
1035
+
1019
1036
  async def fetch_ticker_ws(self, symbol: str, params={}):
1020
1037
  if self.has['fetchTickersWs']:
1021
1038
  await self.load_markets()
@@ -1036,6 +1053,9 @@ class Exchange(BaseExchange):
1036
1053
  async def fetch_tickers(self, symbols: Strings = None, params={}):
1037
1054
  raise NotSupported(self.id + ' fetchTickers() is not supported yet')
1038
1055
 
1056
+ async def fetch_mark_prices(self, symbols: Strings = None, params={}):
1057
+ raise NotSupported(self.id + ' fetchMarkPrices() is not supported yet')
1058
+
1039
1059
  async def fetch_tickers_ws(self, symbols: Strings = None, params={}):
1040
1060
  raise NotSupported(self.id + ' fetchTickers() is not supported yet')
1041
1061
 
@@ -1677,6 +1697,22 @@ class Exchange(BaseExchange):
1677
1697
  else:
1678
1698
  raise NotSupported(self.id + ' fetchFundingRate() is not supported yet')
1679
1699
 
1700
+ async def fetch_funding_interval(self, symbol: str, params={}):
1701
+ if self.has['fetchFundingIntervals']:
1702
+ await self.load_markets()
1703
+ market = self.market(symbol)
1704
+ symbol = market['symbol']
1705
+ if not market['contract']:
1706
+ raise BadSymbol(self.id + ' fetchFundingInterval() supports contract markets only')
1707
+ rates = await self.fetch_funding_intervals([symbol], params)
1708
+ rate = self.safe_value(rates, symbol)
1709
+ if rate is None:
1710
+ raise NullResponse(self.id + ' fetchFundingInterval() returned no data for ' + symbol)
1711
+ else:
1712
+ return rate
1713
+ else:
1714
+ raise NotSupported(self.id + ' fetchFundingInterval() is not supported yet')
1715
+
1680
1716
  async def fetch_mark_ohlcv(self, symbol, timeframe='1m', since: Int = None, limit: Int = None, params={}):
1681
1717
  """
1682
1718
  fetches historical mark price candlestick data containing the open, high, low, and close price of a market
@@ -724,6 +724,8 @@ class bigone(Exchange, ImplicitAPI):
724
724
  'average': None,
725
725
  'baseVolume': self.safe_string_2(ticker, 'volume', 'volume24h'),
726
726
  'quoteVolume': self.safe_string(ticker, 'volume24hInUsd'),
727
+ 'markPrice': self.safe_string(ticker, 'markPrice'),
728
+ 'indexPrice': self.safe_string(ticker, 'indexPrice'),
727
729
  'info': ticker,
728
730
  }, market)
729
731
 
@@ -112,6 +112,8 @@ class binance(Exchange, ImplicitAPI):
112
112
  'fetchDepositWithdrawFee': 'emulated',
113
113
  'fetchDepositWithdrawFees': True,
114
114
  'fetchFundingHistory': True,
115
+ 'fetchFundingInterval': 'emulated',
116
+ 'fetchFundingIntervals': True,
115
117
  'fetchFundingRate': True,
116
118
  'fetchFundingRateHistory': True,
117
119
  'fetchFundingRates': True,
@@ -133,6 +135,7 @@ class binance(Exchange, ImplicitAPI):
133
135
  'fetchMarketLeverageTiers': 'emulated',
134
136
  'fetchMarkets': True,
135
137
  'fetchMarkOHLCV': True,
138
+ 'fetchMarkPrices': True,
136
139
  'fetchMyLiquidations': True,
137
140
  'fetchMySettlementHistory': True,
138
141
  'fetchMyTrades': True,
@@ -734,6 +737,7 @@ class binance(Exchange, ImplicitAPI):
734
737
  'ticker/bookTicker': {'cost': 2, 'noSymbol': 5},
735
738
  'constituents': 2,
736
739
  'openInterest': 1,
740
+ 'fundingInfo': 1,
737
741
  },
738
742
  },
739
743
  'dapiData': {
@@ -1217,6 +1221,9 @@ class binance(Exchange, ImplicitAPI):
1217
1221
  },
1218
1222
  'option': {},
1219
1223
  },
1224
+ 'currencies': {
1225
+ 'BNFCR': self.safe_currency_structure({'id': 'BNFCR', 'code': 'BNFCR', 'precision': self.parse_number('0.001')}),
1226
+ },
1220
1227
  'commonCurrencies': {
1221
1228
  'BCC': 'BCC', # kept for backward-compatibility https://github.com/ccxt/ccxt/issues/4848
1222
1229
  'YOYO': 'YOYOW',
@@ -3715,6 +3722,18 @@ class binance(Exchange, ImplicitAPI):
3715
3722
  return orderbook
3716
3723
 
3717
3724
  def parse_ticker(self, ticker: dict, market: Market = None) -> Ticker:
3725
+ # markPrices
3726
+ #
3727
+ # {
3728
+ # "symbol": "BTCUSDT",
3729
+ # "markPrice": "11793.63104562", # mark price
3730
+ # "indexPrice": "11781.80495970", # index price
3731
+ # "estimatedSettlePrice": "11781.16138815", # Estimated Settle Price, only useful in the last hour before the settlement starts.
3732
+ # "lastFundingRate": "0.00038246", # This is the lastest estimated funding rate
3733
+ # "nextFundingTime": 1597392000000,
3734
+ # "interestRate": "0.00010000",
3735
+ # "time": 1597370495002
3736
+ # }
3718
3737
  #
3719
3738
  # {
3720
3739
  # "symbol": "ETHBTC",
@@ -3818,7 +3837,7 @@ class binance(Exchange, ImplicitAPI):
3818
3837
  # "time":"1673899278514"
3819
3838
  # }
3820
3839
  #
3821
- timestamp = self.safe_integer(ticker, 'closeTime')
3840
+ timestamp = self.safe_integer_2(ticker, 'closeTime', 'time')
3822
3841
  marketType = None
3823
3842
  if ('time' in ticker):
3824
3843
  marketType = 'contract'
@@ -3858,6 +3877,8 @@ class binance(Exchange, ImplicitAPI):
3858
3877
  'average': None,
3859
3878
  'baseVolume': baseVolume,
3860
3879
  'quoteVolume': quoteVolume,
3880
+ 'markPrice': self.safe_string(ticker, 'markPrice'),
3881
+ 'indexPrice': self.safe_string(ticker, 'indexPrice'),
3861
3882
  'info': ticker,
3862
3883
  }, market)
3863
3884
 
@@ -4088,6 +4109,31 @@ class binance(Exchange, ImplicitAPI):
4088
4109
  raise NotSupported(self.id + ' fetchTickers() does not support ' + type + ' markets yet')
4089
4110
  return self.parse_tickers(response, symbols)
4090
4111
 
4112
+ async def fetch_mark_prices(self, symbols: Strings = None, params={}) -> Tickers:
4113
+ """
4114
+ fetches mark prices for multiple markets
4115
+ :see: https://binance-docs.github.io/apidocs/futures/en/#mark-price
4116
+ :param str[] [symbols]: unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
4117
+ :param dict [params]: extra parameters specific to the exchange API endpoint
4118
+ :param str [params.subType]: "linear" or "inverse"
4119
+ :returns dict: a dictionary of `ticker structures <https://docs.ccxt.com/#/?id=ticker-structure>`
4120
+ """
4121
+ await self.load_markets()
4122
+ symbols = self.market_symbols(symbols, None, True, True, True)
4123
+ market = self.get_market_from_symbols(symbols)
4124
+ type = None
4125
+ type, params = self.handle_market_type_and_params('fetchTickers', market, params, 'swap')
4126
+ subType = None
4127
+ subType, params = self.handle_sub_type_and_params('fetchTickers', market, params, 'linear')
4128
+ response = None
4129
+ if self.is_linear(type, subType):
4130
+ response = await self.fapiPublicGetPremiumIndex(params)
4131
+ elif self.is_inverse(type, subType):
4132
+ response = await self.dapiPublicGetPremiumIndex(params)
4133
+ else:
4134
+ raise NotSupported(self.id + ' fetchMarkPrices() does not support ' + type + ' markets yet')
4135
+ return self.parse_tickers(response, symbols)
4136
+
4091
4137
  def parse_ohlcv(self, ohlcv, market: Market = None) -> list:
4092
4138
  # when api method = publicGetKlines or fapiPublicGetKlines or dapiPublicGetKlines
4093
4139
  # [
@@ -8786,16 +8832,28 @@ class binance(Exchange, ImplicitAPI):
8786
8832
  def parse_funding_rate(self, contract, market: Market = None) -> FundingRate:
8787
8833
  # ensure it matches with https://www.binance.com/en/futures/funding-history/0
8788
8834
  #
8789
- # {
8790
- # "symbol": "BTCUSDT",
8791
- # "markPrice": "45802.81129892",
8792
- # "indexPrice": "45745.47701915",
8793
- # "estimatedSettlePrice": "45133.91753671",
8794
- # "lastFundingRate": "0.00063521",
8795
- # "interestRate": "0.00010000",
8796
- # "nextFundingTime": "1621267200000",
8797
- # "time": "1621252344001"
8798
- # }
8835
+ # fetchFundingRate, fetchFundingRates
8836
+ #
8837
+ # {
8838
+ # "symbol": "BTCUSDT",
8839
+ # "markPrice": "45802.81129892",
8840
+ # "indexPrice": "45745.47701915",
8841
+ # "estimatedSettlePrice": "45133.91753671",
8842
+ # "lastFundingRate": "0.00063521",
8843
+ # "interestRate": "0.00010000",
8844
+ # "nextFundingTime": "1621267200000",
8845
+ # "time": "1621252344001"
8846
+ # }
8847
+ #
8848
+ # fetchFundingInterval, fetchFundingIntervals
8849
+ #
8850
+ # {
8851
+ # "symbol": "BLZUSDT",
8852
+ # "adjustedFundingRateCap": "0.03000000",
8853
+ # "adjustedFundingRateFloor": "-0.03000000",
8854
+ # "fundingIntervalHours": 4,
8855
+ # "disclaimer": False
8856
+ # }
8799
8857
  #
8800
8858
  timestamp = self.safe_integer(contract, 'time')
8801
8859
  marketId = self.safe_string(contract, 'symbol')
@@ -8806,6 +8864,10 @@ class binance(Exchange, ImplicitAPI):
8806
8864
  estimatedSettlePrice = self.safe_number(contract, 'estimatedSettlePrice')
8807
8865
  fundingRate = self.safe_number(contract, 'lastFundingRate')
8808
8866
  fundingTime = self.safe_integer(contract, 'nextFundingTime')
8867
+ interval = self.safe_string(contract, 'fundingIntervalHours')
8868
+ intervalString = None
8869
+ if interval is not None:
8870
+ intervalString = interval + 'h'
8809
8871
  return {
8810
8872
  'info': contract,
8811
8873
  'symbol': symbol,
@@ -8824,7 +8886,7 @@ class binance(Exchange, ImplicitAPI):
8824
8886
  'previousFundingRate': None,
8825
8887
  'previousFundingTimestamp': None,
8826
8888
  'previousFundingDatetime': None,
8827
- 'interval': None,
8889
+ 'interval': intervalString,
8828
8890
  }
8829
8891
 
8830
8892
  def parse_account_positions(self, account, filterClosed=False):
@@ -12538,3 +12600,42 @@ class binance(Exchange, ImplicitAPI):
12538
12600
  'price': None,
12539
12601
  'fee': None,
12540
12602
  }
12603
+
12604
+ async def fetch_funding_intervals(self, symbols: Strings = None, params={}) -> FundingRates:
12605
+ """
12606
+ fetch the funding rate interval for multiple markets
12607
+ :see: https://developers.binance.com/docs/derivatives/usds-margined-futures/market-data/rest-api/Get-Funding-Info
12608
+ :see: https://developers.binance.com/docs/derivatives/coin-margined-futures/market-data/Get-Funding-Info
12609
+ :param str[] [symbols]: list of unified market symbols
12610
+ :param dict [params]: extra parameters specific to the exchange API endpoint
12611
+ :param str [params.subType]: "linear" or "inverse"
12612
+ :returns dict[]: a list of `funding rate structures <https://docs.ccxt.com/#/?id=funding-rate-structure>`
12613
+ """
12614
+ await self.load_markets()
12615
+ market = None
12616
+ if symbols is not None:
12617
+ symbols = self.market_symbols(symbols)
12618
+ market = self.market(symbols[0])
12619
+ type = 'swap'
12620
+ subType = None
12621
+ subType, params = self.handle_sub_type_and_params('fetchFundingIntervals', market, params, 'linear')
12622
+ response = None
12623
+ if self.is_linear(type, subType):
12624
+ response = await self.fapiPublicGetFundingInfo(params)
12625
+ elif self.is_inverse(type, subType):
12626
+ response = await self.dapiPublicGetFundingInfo(params)
12627
+ else:
12628
+ raise NotSupported(self.id + ' fetchFundingIntervals() supports linear and inverse swap contracts only')
12629
+ #
12630
+ # [
12631
+ # {
12632
+ # "symbol": "BLZUSDT",
12633
+ # "adjustedFundingRateCap": "0.03000000",
12634
+ # "adjustedFundingRateFloor": "-0.03000000",
12635
+ # "fundingIntervalHours": 4,
12636
+ # "disclaimer": False
12637
+ # },
12638
+ # ]
12639
+ #
12640
+ result = self.parse_funding_rates(response, market)
12641
+ return self.filter_by_array(result, 'symbol', symbols)
@@ -81,6 +81,7 @@ class bingx(Exchange, ImplicitAPI):
81
81
  'fetchMarginMode': True,
82
82
  'fetchMarkets': True,
83
83
  'fetchMarkOHLCV': True,
84
+ 'fetchMarkPrices': True,
84
85
  'fetchMyLiquidations': True,
85
86
  'fetchOHLCV': True,
86
87
  'fetchOpenInterest': True,
@@ -591,8 +592,8 @@ class bingx(Exchange, ImplicitAPI):
591
592
  networkList = self.safe_list(entry, 'networkList')
592
593
  networks: dict = {}
593
594
  fee = None
594
- depositEnabled = None
595
- withdrawEnabled = None
595
+ depositEnabled = False
596
+ withdrawEnabled = False
596
597
  defaultLimits: dict = {}
597
598
  for j in range(0, len(networkList)):
598
599
  rawNetwork = networkList[j]
@@ -603,7 +604,7 @@ class bingx(Exchange, ImplicitAPI):
603
604
  if networkDepositEnabled:
604
605
  depositEnabled = True
605
606
  networkWithdrawEnabled = self.safe_bool(rawNetwork, 'withdrawEnable')
606
- if networkDepositEnabled:
607
+ if networkWithdrawEnabled:
607
608
  withdrawEnabled = True
608
609
  limits: dict = {
609
610
  'withdraw': {
@@ -1655,7 +1656,70 @@ class bingx(Exchange, ImplicitAPI):
1655
1656
  tickers = self.safe_list(response, 'data')
1656
1657
  return self.parse_tickers(tickers, symbols)
1657
1658
 
1659
+ async def fetch_mark_prices(self, symbols: Strings = None, params={}) -> Tickers:
1660
+ """
1661
+ fetches mark prices for multiple markets
1662
+ :see: https://bingx-api.github.io/docs/#/en-us/swapV2/market-api.html#Mark%20Price%20and%20Funding%20Rate
1663
+ :param str[] [symbols]: unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
1664
+ :param dict [params]: extra parameters specific to the exchange API endpoint
1665
+ :returns dict: a dictionary of `ticker structures <https://docs.ccxt.com/#/?id=ticker-structure>`
1666
+ """
1667
+ await self.load_markets()
1668
+ market = None
1669
+ if symbols is not None:
1670
+ symbols = self.market_symbols(symbols)
1671
+ firstSymbol = self.safe_string(symbols, 0)
1672
+ if firstSymbol is not None:
1673
+ market = self.market(firstSymbol)
1674
+ subType = None
1675
+ subType, params = self.handle_sub_type_and_params('fetchMarkPrices', market, params, 'linear')
1676
+ response = None
1677
+ if subType == 'inverse':
1678
+ response = await self.cswapV1PublicGetMarketPremiumIndex(params)
1679
+ else:
1680
+ response = await self.swapV2PublicGetQuotePremiumIndex(params)
1681
+ #
1682
+ # spot and swap
1683
+ #
1684
+ # {
1685
+ # "code": 0,
1686
+ # "msg": "",
1687
+ # "timestamp": 1720647285296,
1688
+ # "data": [
1689
+ # {
1690
+ # "symbol": "SOL-USD",
1691
+ # "priceChange": "-2.418",
1692
+ # "priceChangePercent": "-1.6900%",
1693
+ # "lastPrice": "140.574",
1694
+ # "lastQty": "1",
1695
+ # "highPrice": "146.190",
1696
+ # "lowPrice": "138.586",
1697
+ # "volume": "1464648.00",
1698
+ # "quoteVolume": "102928.12",
1699
+ # "openPrice": "142.994",
1700
+ # "closeTime": "1720647284976",
1701
+ # "bidPrice": "140.573",
1702
+ # "bidQty": "372",
1703
+ # "askPrice": "140.577",
1704
+ # "askQty": "58"
1705
+ # },
1706
+ # ...
1707
+ # ]
1708
+ # }
1709
+ #
1710
+ tickers = self.safe_list(response, 'data')
1711
+ return self.parse_tickers(tickers, symbols)
1712
+
1658
1713
  def parse_ticker(self, ticker: dict, market: Market = None) -> Ticker:
1714
+ #
1715
+ # mark price
1716
+ # {
1717
+ # "symbol": "string",
1718
+ # "lastFundingRate": "string",
1719
+ # "markPrice": "string",
1720
+ # "indexPrice": "string",
1721
+ # "nextFundingTime": "int64"
1722
+ # }
1659
1723
  #
1660
1724
  # spot
1661
1725
  # {
@@ -1741,6 +1805,8 @@ class bingx(Exchange, ImplicitAPI):
1741
1805
  'average': None,
1742
1806
  'baseVolume': baseVolume,
1743
1807
  'quoteVolume': quoteVolume,
1808
+ 'markPrice': self.safe_string(ticker, 'markPrice'),
1809
+ 'indexPrice': self.safe_string(ticker, 'indexPrice'),
1744
1810
  'info': ticker,
1745
1811
  }, market)
1746
1812
 
@@ -101,6 +101,8 @@ class bitget(Exchange, ImplicitAPI):
101
101
  'fetchDepositWithdrawFee': 'emulated',
102
102
  'fetchDepositWithdrawFees': True,
103
103
  'fetchFundingHistory': True,
104
+ 'fetchFundingInterval': True,
105
+ 'fetchFundingIntervals': False,
104
106
  'fetchFundingRate': True,
105
107
  'fetchFundingRateHistory': True,
106
108
  'fetchFundingRates': False,
@@ -116,6 +118,7 @@ class bitget(Exchange, ImplicitAPI):
116
118
  'fetchMarketLeverageTiers': True,
117
119
  'fetchMarkets': True,
118
120
  'fetchMarkOHLCV': True,
121
+ 'fetchMarkPrice': True,
119
122
  'fetchMyLiquidations': True,
120
123
  'fetchMyTrades': True,
121
124
  'fetchOHLCV': True,
@@ -2466,6 +2469,14 @@ class bitget(Exchange, ImplicitAPI):
2466
2469
  return self.parse_order_book(data, market['symbol'], timestamp)
2467
2470
 
2468
2471
  def parse_ticker(self, ticker: dict, market: Market = None) -> Ticker:
2472
+ #
2473
+ # {
2474
+ # "symbol": "BTCUSDT",
2475
+ # "price": "26242",
2476
+ # "indexPrice": "34867",
2477
+ # "markPrice": "25555",
2478
+ # "ts": "1695793390482"
2479
+ # }
2469
2480
  #
2470
2481
  # spot: fetchTicker, fetchTickers
2471
2482
  #
@@ -2570,6 +2581,8 @@ class bitget(Exchange, ImplicitAPI):
2570
2581
  'average': None,
2571
2582
  'baseVolume': self.safe_string(ticker, 'baseVolume'),
2572
2583
  'quoteVolume': self.safe_string(ticker, 'quoteVolume'),
2584
+ 'indexPrice': self.safe_string(ticker, 'indexPrice'),
2585
+ 'markPrice': self.safe_string(ticker, 'markPrice'),
2573
2586
  'info': ticker,
2574
2587
  }, market)
2575
2588
 
@@ -2667,6 +2680,36 @@ class bitget(Exchange, ImplicitAPI):
2667
2680
  data = self.safe_list(response, 'data', [])
2668
2681
  return self.parse_ticker(data[0], market)
2669
2682
 
2683
+ async def fetch_mark_price(self, symbol: str, params={}) -> Ticker:
2684
+ """
2685
+ fetches the mark price for a specific market
2686
+ :see: https://www.bitget.com/api-doc/contract/market/Get-Symbol-Price
2687
+ :param str symbol: unified symbol of the market to fetch the ticker for
2688
+ :param dict [params]: extra parameters specific to the exchange API endpoint
2689
+ :returns dict: a `ticker structure <https://docs.ccxt.com/#/?id=ticker-structure>`
2690
+ """
2691
+ await self.load_markets()
2692
+ sandboxMode = self.safe_bool(self.options, 'sandboxMode', False)
2693
+ market = None
2694
+ if sandboxMode:
2695
+ sandboxSymbol = self.convert_symbol_for_sandbox(symbol)
2696
+ market = self.market(sandboxSymbol)
2697
+ else:
2698
+ market = self.market(symbol)
2699
+ request: dict = {
2700
+ 'symbol': market['id'],
2701
+ }
2702
+ response = None
2703
+ if market['spot']:
2704
+ raise NotSupported(self.id + ' fetchMarkPrice() is not supported for spot markets')
2705
+ else:
2706
+ productType = None
2707
+ productType, params = self.handle_product_type_and_params(market, params)
2708
+ request['productType'] = productType
2709
+ response = await self.publicMixGetV2MixMarketSymbolPrice(self.extend(request, params))
2710
+ data = self.safe_list(response, 'data', [])
2711
+ return self.parse_ticker(data[0], market)
2712
+
2670
2713
  async def fetch_tickers(self, symbols: Strings = None, params={}) -> Tickers:
2671
2714
  """
2672
2715
  fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
@@ -6303,14 +6346,29 @@ class bitget(Exchange, ImplicitAPI):
6303
6346
  return self.parse_funding_rate(data[0], market)
6304
6347
 
6305
6348
  def parse_funding_rate(self, contract, market: Market = None) -> FundingRate:
6349
+ #
6350
+ # fetchFundingRate
6306
6351
  #
6307
6352
  # {
6308
6353
  # "symbol": "BTCUSDT",
6309
6354
  # "fundingRate": "-0.000182"
6310
6355
  # }
6311
6356
  #
6357
+ # fetchFundingInterval
6358
+ #
6359
+ # {
6360
+ # "symbol": "BTCUSDT",
6361
+ # "nextFundingTime": "1727942400000",
6362
+ # "ratePeriod": "8"
6363
+ # }
6364
+ #
6312
6365
  marketId = self.safe_string(contract, 'symbol')
6313
6366
  symbol = self.safe_symbol(marketId, market, None, 'swap')
6367
+ fundingTimestamp = self.safe_integer(contract, 'nextFundingTime')
6368
+ interval = self.safe_string(contract, 'ratePeriod')
6369
+ intervalString = None
6370
+ if interval is not None:
6371
+ intervalString = interval + 'h'
6314
6372
  return {
6315
6373
  'info': contract,
6316
6374
  'symbol': symbol,
@@ -6321,15 +6379,15 @@ class bitget(Exchange, ImplicitAPI):
6321
6379
  'timestamp': None,
6322
6380
  'datetime': None,
6323
6381
  'fundingRate': self.safe_number(contract, 'fundingRate'),
6324
- 'fundingTimestamp': None,
6325
- 'fundingDatetime': None,
6382
+ 'fundingTimestamp': fundingTimestamp,
6383
+ 'fundingDatetime': self.iso8601(fundingTimestamp),
6326
6384
  'nextFundingRate': None,
6327
6385
  'nextFundingTimestamp': None,
6328
6386
  'nextFundingDatetime': None,
6329
6387
  'previousFundingRate': None,
6330
6388
  'previousFundingTimestamp': None,
6331
6389
  'previousFundingDatetime': None,
6332
- 'interval': None,
6390
+ 'interval': intervalString,
6333
6391
  }
6334
6392
 
6335
6393
  async def fetch_funding_history(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}) -> List[FundingHistory]:
@@ -8173,6 +8231,47 @@ class bitget(Exchange, ImplicitAPI):
8173
8231
  }
8174
8232
  return result
8175
8233
 
8234
+ async def fetch_funding_interval(self, symbol: str, params={}) -> FundingRate:
8235
+ """
8236
+ fetch the current funding rate interval
8237
+ :see: https://www.bitget.com/api-doc/contract/market/Get-Symbol-Next-Funding-Time
8238
+ :param str symbol: unified market symbol
8239
+ :param dict [params]: extra parameters specific to the exchange API endpoint
8240
+ :returns dict: a `funding rate structure <https://docs.ccxt.com/#/?id=funding-rate-structure>`
8241
+ """
8242
+ await self.load_markets()
8243
+ sandboxMode = self.safe_bool(self.options, 'sandboxMode', False)
8244
+ market = None
8245
+ if sandboxMode:
8246
+ sandboxSymbol = self.convert_symbol_for_sandbox(symbol)
8247
+ market = self.market(sandboxSymbol)
8248
+ else:
8249
+ market = self.market(symbol)
8250
+ productType = None
8251
+ productType, params = self.handle_product_type_and_params(market, params)
8252
+ request: dict = {
8253
+ 'symbol': market['id'],
8254
+ 'productType': productType,
8255
+ }
8256
+ response = await self.publicMixGetV2MixMarketFundingTime(self.extend(request, params))
8257
+ #
8258
+ # {
8259
+ # "code": "00000",
8260
+ # "msg": "success",
8261
+ # "requestTime": 1727930153888,
8262
+ # "data": [
8263
+ # {
8264
+ # "symbol": "BTCUSDT",
8265
+ # "nextFundingTime": "1727942400000",
8266
+ # "ratePeriod": "8"
8267
+ # }
8268
+ # ]
8269
+ # }
8270
+ #
8271
+ data = self.safe_list(response, 'data', [])
8272
+ first = self.safe_dict(data, 0, {})
8273
+ return self.parse_funding_rate(first, market)
8274
+
8176
8275
  def handle_errors(self, code: int, reason: str, url: str, method: str, headers: dict, body: str, response, requestHeaders, requestBody):
8177
8276
  if not response:
8178
8277
  return None # fallback to default error handler
@@ -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