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
@@ -633,6 +633,7 @@ class poloniex(Exchange, ImplicitAPI):
633
633
  'average': None,
634
634
  'baseVolume': self.safe_string(ticker, 'quantity'),
635
635
  'quoteVolume': self.safe_string(ticker, 'amount'),
636
+ 'markPrice': self.safe_string(ticker, 'markPrice'),
636
637
  'info': ticker,
637
638
  }, market)
638
639
 
@@ -48,6 +48,8 @@ class poloniexfutures(Exchange, ImplicitAPI):
48
48
  'fetchDepositAddress': False,
49
49
  'fetchDepositAddresses': False,
50
50
  'fetchDepositAddressesByNetwork': False,
51
+ 'fetchFundingInterval': True,
52
+ 'fetchFundingIntervals': False,
51
53
  'fetchFundingRate': True,
52
54
  'fetchFundingRateHistory': False,
53
55
  'fetchL3OrderBook': True,
@@ -1550,28 +1552,50 @@ class poloniexfutures(Exchange, ImplicitAPI):
1550
1552
  # "predictedValue": 0.00375
1551
1553
  # }
1552
1554
  #
1553
- data = self.safe_value(response, 'data')
1555
+ data = self.safe_dict(response, 'data', {})
1556
+ return self.parse_funding_rate(data, market)
1557
+
1558
+ async def fetch_funding_interval(self, symbol: str, params={}) -> FundingRate:
1559
+ """
1560
+ fetch the current funding rate interval
1561
+ :see: https://api-docs.poloniex.com/futures/api/futures-index#get-premium-index
1562
+ :param str symbol: unified market symbol
1563
+ :param dict [params]: extra parameters specific to the exchange API endpoint
1564
+ :returns dict: a `funding rate structure <https://docs.ccxt.com/#/?id=funding-rate-structure>`
1565
+ """
1566
+ return await self.fetch_funding_rate(symbol, params)
1567
+
1568
+ def parse_funding_rate(self, data, market: Market = None) -> FundingRate:
1569
+ #
1570
+ # {
1571
+ # "symbol": ".ETHUSDTMFPI8H",
1572
+ # "granularity": 28800000,
1573
+ # "timePoint": 1637380800000,
1574
+ # "value": 0.0001,
1575
+ # "predictedValue": 0.0001,
1576
+ # }
1577
+ #
1554
1578
  fundingTimestamp = self.safe_integer(data, 'timePoint')
1555
- # the website displayes the previous funding rate as "funding rate"
1579
+ marketId = self.safe_string(data, 'symbol')
1556
1580
  return {
1557
1581
  'info': data,
1558
- 'symbol': market['symbol'],
1582
+ 'symbol': self.safe_symbol(marketId, market, None, 'contract'),
1559
1583
  'markPrice': None,
1560
1584
  'indexPrice': None,
1561
1585
  'interestRate': None,
1562
1586
  'estimatedSettlePrice': None,
1563
1587
  'timestamp': None,
1564
1588
  'datetime': None,
1565
- 'fundingRate': self.safe_number(data, 'predictedValue'),
1566
- 'fundingTimestamp': None,
1567
- 'fundingDatetime': None,
1568
- 'nextFundingRate': None,
1589
+ 'fundingRate': self.safe_number(data, 'value'),
1590
+ 'fundingTimestamp': fundingTimestamp,
1591
+ 'fundingDatetime': self.iso8601(fundingTimestamp),
1592
+ 'nextFundingRate': self.safe_number(data, 'predictedValue'),
1569
1593
  'nextFundingTimestamp': None,
1570
1594
  'nextFundingDatetime': None,
1571
- 'previousFundingRate': self.safe_number(data, 'value'),
1572
- 'previousFundingTimestamp': fundingTimestamp,
1573
- 'previousFundingDatetime': self.iso8601(fundingTimestamp),
1574
- 'interval': self.parse_funding_interval(self.safe_string(data, 'interval')),
1595
+ 'previousFundingRate': None,
1596
+ 'previousFundingTimestamp': None,
1597
+ 'previousFundingDatetime': None,
1598
+ 'interval': self.parse_funding_interval(self.safe_string(data, 'granularity')),
1575
1599
  }
1576
1600
 
1577
1601
  def parse_funding_interval(self, interval):
ccxt/async_support/woo.py CHANGED
@@ -79,6 +79,8 @@ class woo(Exchange, ImplicitAPI):
79
79
  'fetchDeposits': True,
80
80
  'fetchDepositsWithdrawals': True,
81
81
  'fetchFundingHistory': True,
82
+ 'fetchFundingInterval': True,
83
+ 'fetchFundingIntervals': False,
82
84
  'fetchFundingRate': True,
83
85
  'fetchFundingRateHistory': True,
84
86
  'fetchFundingRates': True,
@@ -2590,6 +2592,16 @@ class woo(Exchange, ImplicitAPI):
2590
2592
  'interval': intervalString + 'h',
2591
2593
  }
2592
2594
 
2595
+ async def fetch_funding_interval(self, symbol: str, params={}) -> FundingRate:
2596
+ """
2597
+ fetch the current funding rate interval
2598
+ :see: https://docs.woox.io/#get-predicted-funding-rate-for-one-market-public
2599
+ :param str symbol: unified market symbol
2600
+ :param dict [params]: extra parameters specific to the exchange API endpoint
2601
+ :returns dict: a `funding rate structure <https://docs.ccxt.com/#/?id=funding-rate-structure>`
2602
+ """
2603
+ return await self.fetch_funding_rate(symbol, params)
2604
+
2593
2605
  async def fetch_funding_rate(self, symbol: str, params={}) -> FundingRate:
2594
2606
  """
2595
2607
  fetch the current funding rate
@@ -77,6 +77,8 @@ class woofipro(Exchange, ImplicitAPI):
77
77
  'fetchDeposits': True,
78
78
  'fetchDepositsWithdrawals': True,
79
79
  'fetchFundingHistory': True,
80
+ 'fetchFundingInterval': True,
81
+ 'fetchFundingIntervals': False,
80
82
  'fetchFundingRate': True,
81
83
  'fetchFundingRateHistory': True,
82
84
  'fetchFundingRates': True,
@@ -787,6 +789,16 @@ class woofipro(Exchange, ImplicitAPI):
787
789
  }
788
790
  return self.safe_string(intervals, interval, interval)
789
791
 
792
+ async def fetch_funding_interval(self, symbol: str, params={}) -> FundingRate:
793
+ """
794
+ fetch the current funding rate interval
795
+ :see: https://orderly.network/docs/build-on-evm/evm-api/restful-api/public/get-predicted-funding-rate-for-one-market
796
+ :param str symbol: unified market symbol
797
+ :param dict [params]: extra parameters specific to the exchange API endpoint
798
+ :returns dict: a `funding rate structure <https://docs.ccxt.com/#/?id=funding-rate-structure>`
799
+ """
800
+ return await self.fetch_funding_rate(symbol, params)
801
+
790
802
  async def fetch_funding_rate(self, symbol: str, params={}) -> FundingRate:
791
803
  """
792
804
  fetch the current funding rate
ccxt/async_support/xt.py CHANGED
@@ -78,6 +78,8 @@ class xt(Exchange, ImplicitAPI):
78
78
  'fetchDepositWithdrawFee': False,
79
79
  'fetchDepositWithdrawFees': False,
80
80
  'fetchFundingHistory': True,
81
+ 'fetchFundingInterval': True,
82
+ 'fetchFundingIntervals': False,
81
83
  'fetchFundingRate': True,
82
84
  'fetchFundingRateHistory': True,
83
85
  'fetchFundingRates': False,
@@ -4030,6 +4032,16 @@ class xt(Exchange, ImplicitAPI):
4030
4032
  sorted = self.sort_by(rates, 'timestamp')
4031
4033
  return self.filter_by_symbol_since_limit(sorted, market['symbol'], since, limit)
4032
4034
 
4035
+ async def fetch_funding_interval(self, symbol: str, params={}) -> FundingRate:
4036
+ """
4037
+ fetch the current funding rate interval
4038
+ :see: https://doc.xt.com/#futures_quotesgetFundingRate
4039
+ :param str symbol: unified market symbol
4040
+ :param dict [params]: extra parameters specific to the exchange API endpoint
4041
+ :returns dict: a `funding rate structure <https://docs.ccxt.com/#/?id=funding-rate-structure>`
4042
+ """
4043
+ return await self.fetch_funding_rate(symbol, params)
4044
+
4033
4045
  async def fetch_funding_rate(self, symbol: str, params={}) -> FundingRate:
4034
4046
  """
4035
4047
  fetch the current funding rate
ccxt/base/exchange.py CHANGED
@@ -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
 
@@ -1892,6 +1892,8 @@ class Exchange(object):
1892
1892
  'fetchFundingHistory': None,
1893
1893
  'fetchFundingRate': None,
1894
1894
  'fetchFundingRateHistory': None,
1895
+ 'fetchFundingInterval': None,
1896
+ 'fetchFundingIntervals': None,
1895
1897
  'fetchFundingRates': None,
1896
1898
  'fetchGreeks': None,
1897
1899
  'fetchIndexOHLCV': None,
@@ -1952,6 +1954,7 @@ class Exchange(object):
1952
1954
  'fetchTicker': True,
1953
1955
  'fetchTickerWs': None,
1954
1956
  'fetchTickers': None,
1957
+ 'fetchMarkPrices': None,
1955
1958
  'fetchTickersWs': None,
1956
1959
  'fetchTime': None,
1957
1960
  'fetchTrades': True,
@@ -2560,6 +2563,9 @@ class Exchange(object):
2560
2563
  def fetch_funding_rates(self, symbols: Strings = None, params={}):
2561
2564
  raise NotSupported(self.id + ' fetchFundingRates() is not supported yet')
2562
2565
 
2566
+ def fetch_funding_intervals(self, symbols: Strings = None, params={}):
2567
+ raise NotSupported(self.id + ' fetchFundingIntervals() is not supported yet')
2568
+
2563
2569
  def watch_funding_rate(self, symbol: str, params={}):
2564
2570
  raise NotSupported(self.id + ' watchFundingRate() is not supported yet')
2565
2571
 
@@ -3478,6 +3484,8 @@ class Exchange(object):
3478
3484
  'baseVolume': self.parse_number(baseVolume),
3479
3485
  'quoteVolume': self.parse_number(quoteVolume),
3480
3486
  'previousClose': self.safe_number(ticker, 'previousClose'),
3487
+ 'indexPrice': self.safe_number(ticker, 'indexPrice'),
3488
+ 'markPrice': self.safe_number(ticker, 'markPrice'),
3481
3489
  })
3482
3490
 
3483
3491
  def fetch_borrow_rate(self, code: str, amount, params={}):
@@ -4488,6 +4496,20 @@ class Exchange(object):
4488
4496
  else:
4489
4497
  raise NotSupported(self.id + ' fetchTicker() is not supported yet')
4490
4498
 
4499
+ def fetch_mark_price(self, symbol: str, params={}):
4500
+ if self.has['fetchMarkPrices']:
4501
+ self.load_markets()
4502
+ market = self.market(symbol)
4503
+ symbol = market['symbol']
4504
+ tickers = self.fetch_mark_prices([symbol], params)
4505
+ ticker = self.safe_dict(tickers, symbol)
4506
+ if ticker is None:
4507
+ raise NullResponse(self.id + ' fetchMarkPrices() could not find a ticker for ' + symbol)
4508
+ else:
4509
+ return ticker
4510
+ else:
4511
+ raise NotSupported(self.id + ' fetchMarkPrices() is not supported yet')
4512
+
4491
4513
  def fetch_ticker_ws(self, symbol: str, params={}):
4492
4514
  if self.has['fetchTickersWs']:
4493
4515
  self.load_markets()
@@ -4508,6 +4530,9 @@ class Exchange(object):
4508
4530
  def fetch_tickers(self, symbols: Strings = None, params={}):
4509
4531
  raise NotSupported(self.id + ' fetchTickers() is not supported yet')
4510
4532
 
4533
+ def fetch_mark_prices(self, symbols: Strings = None, params={}):
4534
+ raise NotSupported(self.id + ' fetchMarkPrices() is not supported yet')
4535
+
4511
4536
  def fetch_tickers_ws(self, symbols: Strings = None, params={}):
4512
4537
  raise NotSupported(self.id + ' fetchTickers() is not supported yet')
4513
4538
 
@@ -5160,7 +5185,8 @@ class Exchange(object):
5160
5185
  if precision is None:
5161
5186
  return self.force_string(fee)
5162
5187
  else:
5163
- return self.decimal_to_precision(fee, ROUND, precision, self.precisionMode, self.paddingMode)
5188
+ roundingMode = self.safe_integer(self.options, 'currencyToPrecisionRoundingMode', ROUND)
5189
+ return self.decimal_to_precision(fee, roundingMode, precision, self.precisionMode, self.paddingMode)
5164
5190
 
5165
5191
  def force_string(self, value):
5166
5192
  if not isinstance(value, str):
@@ -5547,6 +5573,22 @@ class Exchange(object):
5547
5573
  else:
5548
5574
  raise NotSupported(self.id + ' fetchFundingRate() is not supported yet')
5549
5575
 
5576
+ def fetch_funding_interval(self, symbol: str, params={}):
5577
+ if self.has['fetchFundingIntervals']:
5578
+ self.load_markets()
5579
+ market = self.market(symbol)
5580
+ symbol = market['symbol']
5581
+ if not market['contract']:
5582
+ raise BadSymbol(self.id + ' fetchFundingInterval() supports contract markets only')
5583
+ rates = self.fetch_funding_intervals([symbol], params)
5584
+ rate = self.safe_value(rates, symbol)
5585
+ if rate is None:
5586
+ raise NullResponse(self.id + ' fetchFundingInterval() returned no data for ' + symbol)
5587
+ else:
5588
+ return rate
5589
+ else:
5590
+ raise NotSupported(self.id + ' fetchFundingInterval() is not supported yet')
5591
+
5550
5592
  def fetch_mark_ohlcv(self, symbol, timeframe='1m', since: Int = None, limit: Int = None, params={}):
5551
5593
  """
5552
5594
  fetches historical mark price candlestick data containing the open, high, low, and close price of a market
ccxt/base/types.py CHANGED
@@ -272,6 +272,8 @@ class Ticker(TypedDict):
272
272
  average: Num
273
273
  quoteVolume: Num
274
274
  baseVolume: Num
275
+ markPrice: Num
276
+ indexPrice: Num
275
277
 
276
278
 
277
279
  Tickers = Dict[str, Ticker]
ccxt/bigone.py CHANGED
@@ -723,6 +723,8 @@ class bigone(Exchange, ImplicitAPI):
723
723
  'average': None,
724
724
  'baseVolume': self.safe_string_2(ticker, 'volume', 'volume24h'),
725
725
  'quoteVolume': self.safe_string(ticker, 'volume24hInUsd'),
726
+ 'markPrice': self.safe_string(ticker, 'markPrice'),
727
+ 'indexPrice': self.safe_string(ticker, 'indexPrice'),
726
728
  'info': ticker,
727
729
  }, market)
728
730
 
ccxt/binance.py CHANGED
@@ -111,6 +111,8 @@ class binance(Exchange, ImplicitAPI):
111
111
  'fetchDepositWithdrawFee': 'emulated',
112
112
  'fetchDepositWithdrawFees': True,
113
113
  'fetchFundingHistory': True,
114
+ 'fetchFundingInterval': 'emulated',
115
+ 'fetchFundingIntervals': True,
114
116
  'fetchFundingRate': True,
115
117
  'fetchFundingRateHistory': True,
116
118
  'fetchFundingRates': True,
@@ -132,6 +134,7 @@ class binance(Exchange, ImplicitAPI):
132
134
  'fetchMarketLeverageTiers': 'emulated',
133
135
  'fetchMarkets': True,
134
136
  'fetchMarkOHLCV': True,
137
+ 'fetchMarkPrices': True,
135
138
  'fetchMyLiquidations': True,
136
139
  'fetchMySettlementHistory': True,
137
140
  'fetchMyTrades': True,
@@ -733,6 +736,7 @@ class binance(Exchange, ImplicitAPI):
733
736
  'ticker/bookTicker': {'cost': 2, 'noSymbol': 5},
734
737
  'constituents': 2,
735
738
  'openInterest': 1,
739
+ 'fundingInfo': 1,
736
740
  },
737
741
  },
738
742
  'dapiData': {
@@ -1216,6 +1220,9 @@ class binance(Exchange, ImplicitAPI):
1216
1220
  },
1217
1221
  'option': {},
1218
1222
  },
1223
+ 'currencies': {
1224
+ 'BNFCR': self.safe_currency_structure({'id': 'BNFCR', 'code': 'BNFCR', 'precision': self.parse_number('0.001')}),
1225
+ },
1219
1226
  'commonCurrencies': {
1220
1227
  'BCC': 'BCC', # kept for backward-compatibility https://github.com/ccxt/ccxt/issues/4848
1221
1228
  'YOYO': 'YOYOW',
@@ -3714,6 +3721,18 @@ class binance(Exchange, ImplicitAPI):
3714
3721
  return orderbook
3715
3722
 
3716
3723
  def parse_ticker(self, ticker: dict, market: Market = None) -> Ticker:
3724
+ # markPrices
3725
+ #
3726
+ # {
3727
+ # "symbol": "BTCUSDT",
3728
+ # "markPrice": "11793.63104562", # mark price
3729
+ # "indexPrice": "11781.80495970", # index price
3730
+ # "estimatedSettlePrice": "11781.16138815", # Estimated Settle Price, only useful in the last hour before the settlement starts.
3731
+ # "lastFundingRate": "0.00038246", # This is the lastest estimated funding rate
3732
+ # "nextFundingTime": 1597392000000,
3733
+ # "interestRate": "0.00010000",
3734
+ # "time": 1597370495002
3735
+ # }
3717
3736
  #
3718
3737
  # {
3719
3738
  # "symbol": "ETHBTC",
@@ -3817,7 +3836,7 @@ class binance(Exchange, ImplicitAPI):
3817
3836
  # "time":"1673899278514"
3818
3837
  # }
3819
3838
  #
3820
- timestamp = self.safe_integer(ticker, 'closeTime')
3839
+ timestamp = self.safe_integer_2(ticker, 'closeTime', 'time')
3821
3840
  marketType = None
3822
3841
  if ('time' in ticker):
3823
3842
  marketType = 'contract'
@@ -3857,6 +3876,8 @@ class binance(Exchange, ImplicitAPI):
3857
3876
  'average': None,
3858
3877
  'baseVolume': baseVolume,
3859
3878
  'quoteVolume': quoteVolume,
3879
+ 'markPrice': self.safe_string(ticker, 'markPrice'),
3880
+ 'indexPrice': self.safe_string(ticker, 'indexPrice'),
3860
3881
  'info': ticker,
3861
3882
  }, market)
3862
3883
 
@@ -4087,6 +4108,31 @@ class binance(Exchange, ImplicitAPI):
4087
4108
  raise NotSupported(self.id + ' fetchTickers() does not support ' + type + ' markets yet')
4088
4109
  return self.parse_tickers(response, symbols)
4089
4110
 
4111
+ def fetch_mark_prices(self, symbols: Strings = None, params={}) -> Tickers:
4112
+ """
4113
+ fetches mark prices for multiple markets
4114
+ :see: https://binance-docs.github.io/apidocs/futures/en/#mark-price
4115
+ :param str[] [symbols]: unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
4116
+ :param dict [params]: extra parameters specific to the exchange API endpoint
4117
+ :param str [params.subType]: "linear" or "inverse"
4118
+ :returns dict: a dictionary of `ticker structures <https://docs.ccxt.com/#/?id=ticker-structure>`
4119
+ """
4120
+ self.load_markets()
4121
+ symbols = self.market_symbols(symbols, None, True, True, True)
4122
+ market = self.get_market_from_symbols(symbols)
4123
+ type = None
4124
+ type, params = self.handle_market_type_and_params('fetchTickers', market, params, 'swap')
4125
+ subType = None
4126
+ subType, params = self.handle_sub_type_and_params('fetchTickers', market, params, 'linear')
4127
+ response = None
4128
+ if self.is_linear(type, subType):
4129
+ response = self.fapiPublicGetPremiumIndex(params)
4130
+ elif self.is_inverse(type, subType):
4131
+ response = self.dapiPublicGetPremiumIndex(params)
4132
+ else:
4133
+ raise NotSupported(self.id + ' fetchMarkPrices() does not support ' + type + ' markets yet')
4134
+ return self.parse_tickers(response, symbols)
4135
+
4090
4136
  def parse_ohlcv(self, ohlcv, market: Market = None) -> list:
4091
4137
  # when api method = publicGetKlines or fapiPublicGetKlines or dapiPublicGetKlines
4092
4138
  # [
@@ -8785,16 +8831,28 @@ class binance(Exchange, ImplicitAPI):
8785
8831
  def parse_funding_rate(self, contract, market: Market = None) -> FundingRate:
8786
8832
  # ensure it matches with https://www.binance.com/en/futures/funding-history/0
8787
8833
  #
8788
- # {
8789
- # "symbol": "BTCUSDT",
8790
- # "markPrice": "45802.81129892",
8791
- # "indexPrice": "45745.47701915",
8792
- # "estimatedSettlePrice": "45133.91753671",
8793
- # "lastFundingRate": "0.00063521",
8794
- # "interestRate": "0.00010000",
8795
- # "nextFundingTime": "1621267200000",
8796
- # "time": "1621252344001"
8797
- # }
8834
+ # fetchFundingRate, fetchFundingRates
8835
+ #
8836
+ # {
8837
+ # "symbol": "BTCUSDT",
8838
+ # "markPrice": "45802.81129892",
8839
+ # "indexPrice": "45745.47701915",
8840
+ # "estimatedSettlePrice": "45133.91753671",
8841
+ # "lastFundingRate": "0.00063521",
8842
+ # "interestRate": "0.00010000",
8843
+ # "nextFundingTime": "1621267200000",
8844
+ # "time": "1621252344001"
8845
+ # }
8846
+ #
8847
+ # fetchFundingInterval, fetchFundingIntervals
8848
+ #
8849
+ # {
8850
+ # "symbol": "BLZUSDT",
8851
+ # "adjustedFundingRateCap": "0.03000000",
8852
+ # "adjustedFundingRateFloor": "-0.03000000",
8853
+ # "fundingIntervalHours": 4,
8854
+ # "disclaimer": False
8855
+ # }
8798
8856
  #
8799
8857
  timestamp = self.safe_integer(contract, 'time')
8800
8858
  marketId = self.safe_string(contract, 'symbol')
@@ -8805,6 +8863,10 @@ class binance(Exchange, ImplicitAPI):
8805
8863
  estimatedSettlePrice = self.safe_number(contract, 'estimatedSettlePrice')
8806
8864
  fundingRate = self.safe_number(contract, 'lastFundingRate')
8807
8865
  fundingTime = self.safe_integer(contract, 'nextFundingTime')
8866
+ interval = self.safe_string(contract, 'fundingIntervalHours')
8867
+ intervalString = None
8868
+ if interval is not None:
8869
+ intervalString = interval + 'h'
8808
8870
  return {
8809
8871
  'info': contract,
8810
8872
  'symbol': symbol,
@@ -8823,7 +8885,7 @@ class binance(Exchange, ImplicitAPI):
8823
8885
  'previousFundingRate': None,
8824
8886
  'previousFundingTimestamp': None,
8825
8887
  'previousFundingDatetime': None,
8826
- 'interval': None,
8888
+ 'interval': intervalString,
8827
8889
  }
8828
8890
 
8829
8891
  def parse_account_positions(self, account, filterClosed=False):
@@ -12537,3 +12599,42 @@ class binance(Exchange, ImplicitAPI):
12537
12599
  'price': None,
12538
12600
  'fee': None,
12539
12601
  }
12602
+
12603
+ def fetch_funding_intervals(self, symbols: Strings = None, params={}) -> FundingRates:
12604
+ """
12605
+ fetch the funding rate interval for multiple markets
12606
+ :see: https://developers.binance.com/docs/derivatives/usds-margined-futures/market-data/rest-api/Get-Funding-Info
12607
+ :see: https://developers.binance.com/docs/derivatives/coin-margined-futures/market-data/Get-Funding-Info
12608
+ :param str[] [symbols]: list of unified market symbols
12609
+ :param dict [params]: extra parameters specific to the exchange API endpoint
12610
+ :param str [params.subType]: "linear" or "inverse"
12611
+ :returns dict[]: a list of `funding rate structures <https://docs.ccxt.com/#/?id=funding-rate-structure>`
12612
+ """
12613
+ self.load_markets()
12614
+ market = None
12615
+ if symbols is not None:
12616
+ symbols = self.market_symbols(symbols)
12617
+ market = self.market(symbols[0])
12618
+ type = 'swap'
12619
+ subType = None
12620
+ subType, params = self.handle_sub_type_and_params('fetchFundingIntervals', market, params, 'linear')
12621
+ response = None
12622
+ if self.is_linear(type, subType):
12623
+ response = self.fapiPublicGetFundingInfo(params)
12624
+ elif self.is_inverse(type, subType):
12625
+ response = self.dapiPublicGetFundingInfo(params)
12626
+ else:
12627
+ raise NotSupported(self.id + ' fetchFundingIntervals() supports linear and inverse swap contracts only')
12628
+ #
12629
+ # [
12630
+ # {
12631
+ # "symbol": "BLZUSDT",
12632
+ # "adjustedFundingRateCap": "0.03000000",
12633
+ # "adjustedFundingRateFloor": "-0.03000000",
12634
+ # "fundingIntervalHours": 4,
12635
+ # "disclaimer": False
12636
+ # },
12637
+ # ]
12638
+ #
12639
+ result = self.parse_funding_rates(response, market)
12640
+ return self.filter_by_array(result, 'symbol', symbols)
ccxt/bingx.py CHANGED
@@ -80,6 +80,7 @@ class bingx(Exchange, ImplicitAPI):
80
80
  'fetchMarginMode': True,
81
81
  'fetchMarkets': True,
82
82
  'fetchMarkOHLCV': True,
83
+ 'fetchMarkPrices': True,
83
84
  'fetchMyLiquidations': True,
84
85
  'fetchOHLCV': True,
85
86
  'fetchOpenInterest': True,
@@ -590,8 +591,8 @@ class bingx(Exchange, ImplicitAPI):
590
591
  networkList = self.safe_list(entry, 'networkList')
591
592
  networks: dict = {}
592
593
  fee = None
593
- depositEnabled = None
594
- withdrawEnabled = None
594
+ depositEnabled = False
595
+ withdrawEnabled = False
595
596
  defaultLimits: dict = {}
596
597
  for j in range(0, len(networkList)):
597
598
  rawNetwork = networkList[j]
@@ -602,7 +603,7 @@ class bingx(Exchange, ImplicitAPI):
602
603
  if networkDepositEnabled:
603
604
  depositEnabled = True
604
605
  networkWithdrawEnabled = self.safe_bool(rawNetwork, 'withdrawEnable')
605
- if networkDepositEnabled:
606
+ if networkWithdrawEnabled:
606
607
  withdrawEnabled = True
607
608
  limits: dict = {
608
609
  'withdraw': {
@@ -1654,7 +1655,70 @@ class bingx(Exchange, ImplicitAPI):
1654
1655
  tickers = self.safe_list(response, 'data')
1655
1656
  return self.parse_tickers(tickers, symbols)
1656
1657
 
1658
+ def fetch_mark_prices(self, symbols: Strings = None, params={}) -> Tickers:
1659
+ """
1660
+ fetches mark prices for multiple markets
1661
+ :see: https://bingx-api.github.io/docs/#/en-us/swapV2/market-api.html#Mark%20Price%20and%20Funding%20Rate
1662
+ :param str[] [symbols]: unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
1663
+ :param dict [params]: extra parameters specific to the exchange API endpoint
1664
+ :returns dict: a dictionary of `ticker structures <https://docs.ccxt.com/#/?id=ticker-structure>`
1665
+ """
1666
+ self.load_markets()
1667
+ market = None
1668
+ if symbols is not None:
1669
+ symbols = self.market_symbols(symbols)
1670
+ firstSymbol = self.safe_string(symbols, 0)
1671
+ if firstSymbol is not None:
1672
+ market = self.market(firstSymbol)
1673
+ subType = None
1674
+ subType, params = self.handle_sub_type_and_params('fetchMarkPrices', market, params, 'linear')
1675
+ response = None
1676
+ if subType == 'inverse':
1677
+ response = self.cswapV1PublicGetMarketPremiumIndex(params)
1678
+ else:
1679
+ response = self.swapV2PublicGetQuotePremiumIndex(params)
1680
+ #
1681
+ # spot and swap
1682
+ #
1683
+ # {
1684
+ # "code": 0,
1685
+ # "msg": "",
1686
+ # "timestamp": 1720647285296,
1687
+ # "data": [
1688
+ # {
1689
+ # "symbol": "SOL-USD",
1690
+ # "priceChange": "-2.418",
1691
+ # "priceChangePercent": "-1.6900%",
1692
+ # "lastPrice": "140.574",
1693
+ # "lastQty": "1",
1694
+ # "highPrice": "146.190",
1695
+ # "lowPrice": "138.586",
1696
+ # "volume": "1464648.00",
1697
+ # "quoteVolume": "102928.12",
1698
+ # "openPrice": "142.994",
1699
+ # "closeTime": "1720647284976",
1700
+ # "bidPrice": "140.573",
1701
+ # "bidQty": "372",
1702
+ # "askPrice": "140.577",
1703
+ # "askQty": "58"
1704
+ # },
1705
+ # ...
1706
+ # ]
1707
+ # }
1708
+ #
1709
+ tickers = self.safe_list(response, 'data')
1710
+ return self.parse_tickers(tickers, symbols)
1711
+
1657
1712
  def parse_ticker(self, ticker: dict, market: Market = None) -> Ticker:
1713
+ #
1714
+ # mark price
1715
+ # {
1716
+ # "symbol": "string",
1717
+ # "lastFundingRate": "string",
1718
+ # "markPrice": "string",
1719
+ # "indexPrice": "string",
1720
+ # "nextFundingTime": "int64"
1721
+ # }
1658
1722
  #
1659
1723
  # spot
1660
1724
  # {
@@ -1740,6 +1804,8 @@ class bingx(Exchange, ImplicitAPI):
1740
1804
  'average': None,
1741
1805
  'baseVolume': baseVolume,
1742
1806
  'quoteVolume': quoteVolume,
1807
+ 'markPrice': self.safe_string(ticker, 'markPrice'),
1808
+ 'indexPrice': self.safe_string(ticker, 'indexPrice'),
1743
1809
  'info': ticker,
1744
1810
  }, market)
1745
1811