ccxt 4.4.8__py2.py3-none-any.whl → 4.4.10__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 (89) hide show
  1. ccxt/__init__.py +1 -1
  2. ccxt/abstract/bigone.py +1 -1
  3. ccxt/abstract/kucoinfutures.py +5 -0
  4. ccxt/abstract/oceanex.py +5 -0
  5. ccxt/ascendex.py +5 -4
  6. ccxt/async_support/__init__.py +1 -1
  7. ccxt/async_support/ascendex.py +5 -4
  8. ccxt/async_support/base/exchange.py +1 -1
  9. ccxt/async_support/bigone.py +35 -86
  10. ccxt/async_support/binance.py +8 -11
  11. ccxt/async_support/bingx.py +27 -23
  12. ccxt/async_support/bitfinex2.py +7 -16
  13. ccxt/async_support/bitget.py +10 -6
  14. ccxt/async_support/bitmart.py +4 -3
  15. ccxt/async_support/bitmex.py +7 -6
  16. ccxt/async_support/blofin.py +7 -16
  17. ccxt/async_support/bybit.py +22 -17
  18. ccxt/async_support/coinex.py +19 -5
  19. ccxt/async_support/delta.py +6 -5
  20. ccxt/async_support/deribit.py +4 -3
  21. ccxt/async_support/digifinex.py +18 -4
  22. ccxt/async_support/gate.py +61 -13
  23. ccxt/async_support/hashkey.py +6 -6
  24. ccxt/async_support/hitbtc.py +6 -5
  25. ccxt/async_support/htx.py +25 -6
  26. ccxt/async_support/hyperliquid.py +6 -1
  27. ccxt/async_support/krakenfutures.py +6 -5
  28. ccxt/async_support/kucoin.py +1 -0
  29. ccxt/async_support/kucoinfutures.py +164 -4
  30. ccxt/async_support/mexc.py +4 -3
  31. ccxt/async_support/oceanex.py +80 -4
  32. ccxt/async_support/okx.py +17 -3
  33. ccxt/async_support/oxfun.py +7 -7
  34. ccxt/async_support/phemex.py +4 -3
  35. ccxt/async_support/poloniexfutures.py +13 -2
  36. ccxt/async_support/vertex.py +6 -5
  37. ccxt/async_support/whitebit.py +14 -13
  38. ccxt/async_support/woo.py +42 -21
  39. ccxt/async_support/woofipro.py +19 -6
  40. ccxt/async_support/xt.py +5 -3
  41. ccxt/base/exchange.py +1 -1
  42. ccxt/base/types.py +1 -0
  43. ccxt/bigone.py +35 -86
  44. ccxt/binance.py +8 -11
  45. ccxt/bingx.py +27 -23
  46. ccxt/bitfinex2.py +7 -16
  47. ccxt/bitget.py +10 -6
  48. ccxt/bitmart.py +4 -3
  49. ccxt/bitmex.py +7 -6
  50. ccxt/blofin.py +7 -16
  51. ccxt/bybit.py +22 -17
  52. ccxt/coinex.py +19 -5
  53. ccxt/delta.py +6 -5
  54. ccxt/deribit.py +4 -3
  55. ccxt/digifinex.py +18 -4
  56. ccxt/gate.py +61 -13
  57. ccxt/hashkey.py +6 -6
  58. ccxt/hitbtc.py +6 -5
  59. ccxt/htx.py +25 -6
  60. ccxt/hyperliquid.py +6 -1
  61. ccxt/krakenfutures.py +6 -5
  62. ccxt/kucoin.py +1 -0
  63. ccxt/kucoinfutures.py +164 -4
  64. ccxt/mexc.py +4 -3
  65. ccxt/oceanex.py +80 -4
  66. ccxt/okx.py +17 -3
  67. ccxt/oxfun.py +7 -7
  68. ccxt/phemex.py +4 -3
  69. ccxt/poloniexfutures.py +13 -2
  70. ccxt/pro/__init__.py +1 -1
  71. ccxt/pro/binance.py +3 -3
  72. ccxt/pro/deribit.py +39 -2
  73. ccxt/pro/gate.py +1 -1
  74. ccxt/pro/hitbtc.py +112 -44
  75. ccxt/pro/hollaex.py +5 -0
  76. ccxt/pro/okx.py +12 -1
  77. ccxt/pro/p2b.py +33 -2
  78. ccxt/pro/whitebit.py +29 -1
  79. ccxt/vertex.py +6 -5
  80. ccxt/whitebit.py +14 -13
  81. ccxt/woo.py +42 -21
  82. ccxt/woofipro.py +19 -6
  83. ccxt/xt.py +5 -3
  84. ccxt-4.4.10.dist-info/METADATA +636 -0
  85. {ccxt-4.4.8.dist-info → ccxt-4.4.10.dist-info}/RECORD +88 -88
  86. ccxt-4.4.8.dist-info/METADATA +0 -636
  87. {ccxt-4.4.8.dist-info → ccxt-4.4.10.dist-info}/LICENSE.txt +0 -0
  88. {ccxt-4.4.8.dist-info → ccxt-4.4.10.dist-info}/WHEEL +0 -0
  89. {ccxt-4.4.8.dist-info → ccxt-4.4.10.dist-info}/top_level.txt +0 -0
ccxt/async_support/okx.py CHANGED
@@ -7,7 +7,7 @@ from ccxt.async_support.base.exchange import Exchange
7
7
  from ccxt.abstract.okx import ImplicitAPI
8
8
  import asyncio
9
9
  import hashlib
10
- from ccxt.base.types import Account, Balances, Conversion, CrossBorrowRate, CrossBorrowRates, Currencies, Currency, Greeks, Int, LedgerEntry, Leverage, LeverageTier, MarginModification, Market, MarketInterface, Num, Option, OptionChain, Order, OrderBook, OrderRequest, CancellationRequest, OrderSide, OrderType, Position, Str, Strings, Ticker, Tickers, Trade, TradingFeeInterface, Transaction, TransferEntry
10
+ from ccxt.base.types import Account, Balances, Conversion, CrossBorrowRate, CrossBorrowRates, Currencies, Currency, Greeks, Int, LedgerEntry, Leverage, LeverageTier, MarginModification, Market, MarketInterface, Num, Option, OptionChain, Order, OrderBook, OrderRequest, CancellationRequest, OrderSide, OrderType, Position, Str, Strings, Ticker, Tickers, FundingRate, Trade, TradingFeeInterface, Transaction, TransferEntry
11
11
  from typing import List
12
12
  from typing import Any
13
13
  from ccxt.base.errors import ExchangeError
@@ -5623,7 +5623,7 @@ class okx(Exchange, ImplicitAPI):
5623
5623
  headers['OK-ACCESS-SIGN'] = signature
5624
5624
  return {'url': url, 'method': method, 'body': body, 'headers': headers}
5625
5625
 
5626
- def parse_funding_rate(self, contract, market: Market = None):
5626
+ def parse_funding_rate(self, contract, market: Market = None) -> FundingRate:
5627
5627
  #
5628
5628
  # {
5629
5629
  # "fundingRate": "0.00027815",
@@ -5657,6 +5657,9 @@ class okx(Exchange, ImplicitAPI):
5657
5657
  symbol = self.safe_symbol(marketId, market)
5658
5658
  nextFundingRate = self.safe_number(contract, 'nextFundingRate')
5659
5659
  fundingTime = self.safe_integer(contract, 'fundingTime')
5660
+ fundingTimeString = self.safe_string(contract, 'fundingTime')
5661
+ nextFundingTimeString = self.safe_string(contract, 'nextFundingRate')
5662
+ millisecondsInterval = Precise.string_sub(nextFundingTimeString, fundingTimeString)
5660
5663
  # https://www.okx.com/support/hc/en-us/articles/360053909272-Ⅸ-Introduction-to-perpetual-swap-funding-fee
5661
5664
  # > The current interest is 0.
5662
5665
  return {
@@ -5677,9 +5680,20 @@ class okx(Exchange, ImplicitAPI):
5677
5680
  'previousFundingRate': None,
5678
5681
  'previousFundingTimestamp': None,
5679
5682
  'previousFundingDatetime': None,
5683
+ 'interval': self.parse_funding_interval(millisecondsInterval),
5680
5684
  }
5681
5685
 
5682
- async def fetch_funding_rate(self, symbol: str, params={}):
5686
+ def parse_funding_interval(self, interval):
5687
+ intervals: dict = {
5688
+ '3600000': '1h',
5689
+ '14400000': '4h',
5690
+ '28800000': '8h',
5691
+ '57600000': '16h',
5692
+ '86400000': '24h',
5693
+ }
5694
+ return self.safe_string(intervals, interval, interval)
5695
+
5696
+ async def fetch_funding_rate(self, symbol: str, params={}) -> FundingRate:
5683
5697
  """
5684
5698
  fetch the current funding rate
5685
5699
  :see: https://www.okx.com/docs-v5/en/#public-data-rest-api-get-funding-rate
@@ -7,7 +7,7 @@ from ccxt.async_support.base.exchange import Exchange
7
7
  from ccxt.abstract.oxfun import ImplicitAPI
8
8
  import asyncio
9
9
  import hashlib
10
- from ccxt.base.types import Account, Balances, Bool, Currencies, Currency, Int, Market, Num, Order, OrderBook, OrderRequest, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, Transaction, TransferEntry
10
+ from ccxt.base.types import Account, Balances, Bool, Currencies, Currency, Int, Market, Num, Order, OrderBook, OrderRequest, OrderSide, OrderType, Str, Strings, Ticker, Tickers, FundingRate, FundingRates, Trade, Transaction, TransferEntry
11
11
  from typing import List
12
12
  from ccxt.base.errors import ExchangeError
13
13
  from ccxt.base.errors import AuthenticationError
@@ -84,7 +84,7 @@ class oxfun(Exchange, ImplicitAPI):
84
84
  'fetchDepositWithdrawFee': False,
85
85
  'fetchDepositWithdrawFees': False,
86
86
  'fetchFundingHistory': True,
87
- 'fetchFundingRate': False,
87
+ 'fetchFundingRate': 'emulated',
88
88
  'fetchFundingRateHistory': True,
89
89
  'fetchFundingRates': True,
90
90
  'fetchIndexOHLCV': False,
@@ -988,10 +988,10 @@ class oxfun(Exchange, ImplicitAPI):
988
988
  timestamp = self.safe_integer(data, 'lastUpdatedAt')
989
989
  return self.parse_order_book(data, market['symbol'], timestamp)
990
990
 
991
- async def fetch_funding_rates(self, symbols: Strings = None, params={}):
991
+ async def fetch_funding_rates(self, symbols: Strings = None, params={}) -> FundingRates:
992
992
  """
993
+ fetch the current funding rates for multiple markets
993
994
  :see: https://docs.ox.fun/?json#get-v3-funding-estimates
994
- fetch the current funding rates
995
995
  :param str[] symbols: unified market symbols
996
996
  :param dict [params]: extra parameters specific to the exchange API endpoint
997
997
  :returns Order[]: an array of `funding rate structures <https://docs.ccxt.com/#/?id=funding-rate-structure>`
@@ -1021,14 +1021,13 @@ class oxfun(Exchange, ImplicitAPI):
1021
1021
  result = self.parse_funding_rates(data)
1022
1022
  return self.filter_by_array(result, 'symbol', symbols)
1023
1023
 
1024
- def parse_funding_rate(self, fundingRate, market: Market = None):
1024
+ def parse_funding_rate(self, fundingRate, market: Market = None) -> FundingRate:
1025
1025
  #
1026
1026
  # {
1027
1027
  # "marketCode": "OX-USD-SWAP-LIN",
1028
1028
  # "fundingAt": "1715515200000",
1029
1029
  # "estFundingRate": "0.000200000"
1030
- # },
1031
- #
1030
+ # }
1032
1031
  #
1033
1032
  symbol = self.safe_string(fundingRate, 'marketCode')
1034
1033
  market = self.market(symbol)
@@ -1051,6 +1050,7 @@ class oxfun(Exchange, ImplicitAPI):
1051
1050
  'previousFundingRate': None,
1052
1051
  'previousFundingTimestamp': None,
1053
1052
  'previousFundingDatetime': None,
1053
+ 'interval': None,
1054
1054
  }
1055
1055
 
1056
1056
  async def fetch_funding_rate_history(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
@@ -7,7 +7,7 @@ from ccxt.async_support.base.exchange import Exchange
7
7
  from ccxt.abstract.phemex import ImplicitAPI
8
8
  import hashlib
9
9
  import numbers
10
- from ccxt.base.types import Balances, Currencies, Currency, Int, LeverageTier, LeverageTiers, MarginModification, Market, Num, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, Transaction, TransferEntry
10
+ from ccxt.base.types import Balances, Currencies, Currency, Int, LeverageTier, LeverageTiers, MarginModification, Market, Num, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Tickers, FundingRate, Trade, Transaction, TransferEntry
11
11
  from typing import List
12
12
  from ccxt.base.errors import ExchangeError
13
13
  from ccxt.base.errors import AuthenticationError
@@ -3741,7 +3741,7 @@ class phemex(Exchange, ImplicitAPI):
3741
3741
  value = Precise.string_mul(value, tickPrecision)
3742
3742
  return value
3743
3743
 
3744
- async def fetch_funding_rate(self, symbol: str, params={}):
3744
+ async def fetch_funding_rate(self, symbol: str, params={}) -> FundingRate:
3745
3745
  """
3746
3746
  fetch the current funding rate
3747
3747
  :param str symbol: unified market symbol
@@ -3786,7 +3786,7 @@ class phemex(Exchange, ImplicitAPI):
3786
3786
  result = self.safe_value(response, 'result', {})
3787
3787
  return self.parse_funding_rate(result, market)
3788
3788
 
3789
- def parse_funding_rate(self, contract, market: Market = None):
3789
+ def parse_funding_rate(self, contract, market: Market = None) -> FundingRate:
3790
3790
  #
3791
3791
  # {
3792
3792
  # "askEp": 2332500,
@@ -3845,6 +3845,7 @@ class phemex(Exchange, ImplicitAPI):
3845
3845
  'previousFundingRate': None,
3846
3846
  'previousFundingTimestamp': None,
3847
3847
  'previousFundingDatetime': None,
3848
+ 'interval': None,
3848
3849
  }
3849
3850
 
3850
3851
  async def set_margin(self, symbol: str, amount: float, params={}) -> MarginModification:
@@ -6,7 +6,7 @@
6
6
  from ccxt.async_support.base.exchange import Exchange
7
7
  from ccxt.abstract.poloniexfutures import ImplicitAPI
8
8
  import hashlib
9
- from ccxt.base.types import Balances, Int, Market, Num, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade
9
+ from ccxt.base.types import Balances, Int, Market, Num, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Tickers, FundingRate, Trade
10
10
  from typing import List
11
11
  from ccxt.base.errors import AuthenticationError
12
12
  from ccxt.base.errors import AccountSuspended
@@ -1527,7 +1527,7 @@ class poloniexfutures(Exchange, ImplicitAPI):
1527
1527
  'trades': None,
1528
1528
  }, market)
1529
1529
 
1530
- async def fetch_funding_rate(self, symbol: str, params={}):
1530
+ async def fetch_funding_rate(self, symbol: str, params={}) -> FundingRate:
1531
1531
  """
1532
1532
  fetch the current funding rate
1533
1533
  :see: https://api-docs.poloniex.com/futures/api/futures-index#get-premium-index
@@ -1571,8 +1571,19 @@ class poloniexfutures(Exchange, ImplicitAPI):
1571
1571
  'previousFundingRate': self.safe_number(data, 'value'),
1572
1572
  'previousFundingTimestamp': fundingTimestamp,
1573
1573
  'previousFundingDatetime': self.iso8601(fundingTimestamp),
1574
+ 'interval': self.parse_funding_interval(self.safe_string(data, 'interval')),
1574
1575
  }
1575
1576
 
1577
+ def parse_funding_interval(self, interval):
1578
+ intervals: dict = {
1579
+ '3600000': '1h',
1580
+ '14400000': '4h',
1581
+ '28800000': '8h',
1582
+ '57600000': '16h',
1583
+ '86400000': '24h',
1584
+ }
1585
+ return self.safe_string(intervals, interval, interval)
1586
+
1576
1587
  async def fetch_my_trades(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
1577
1588
  """
1578
1589
  fetch all trades made by the user
@@ -5,7 +5,7 @@
5
5
 
6
6
  from ccxt.async_support.base.exchange import Exchange
7
7
  from ccxt.abstract.vertex import ImplicitAPI
8
- from ccxt.base.types import Balances, Currencies, Int, Market, Num, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, TradingFees
8
+ from ccxt.base.types import Balances, Currencies, Int, Market, Num, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Tickers, FundingRate, FundingRates, Trade, TradingFees
9
9
  from typing import List
10
10
  from ccxt.base.errors import ExchangeError
11
11
  from ccxt.base.errors import AuthenticationError
@@ -1154,7 +1154,7 @@ class vertex(Exchange, ImplicitAPI):
1154
1154
  rows = self.safe_list(response, 'candlesticks', [])
1155
1155
  return self.parse_ohlcvs(rows, market, timeframe, since, limit)
1156
1156
 
1157
- def parse_funding_rate(self, ticker, market: Market = None):
1157
+ def parse_funding_rate(self, ticker, market: Market = None) -> FundingRate:
1158
1158
  #
1159
1159
  # {
1160
1160
  # "product_id": 4,
@@ -1208,9 +1208,10 @@ class vertex(Exchange, ImplicitAPI):
1208
1208
  'previousFundingRate': None,
1209
1209
  'previousFundingTimestamp': None,
1210
1210
  'previousFundingDatetime': None,
1211
+ 'interval': None,
1211
1212
  }
1212
1213
 
1213
- async def fetch_funding_rate(self, symbol: str, params={}):
1214
+ async def fetch_funding_rate(self, symbol: str, params={}) -> FundingRate:
1214
1215
  """
1215
1216
  fetch the current funding rate
1216
1217
  :see: https://docs.vertexprotocol.com/developer-resources/api/archive-indexer/funding-rate
@@ -1235,13 +1236,13 @@ class vertex(Exchange, ImplicitAPI):
1235
1236
  #
1236
1237
  return self.parse_funding_rate(response, market)
1237
1238
 
1238
- async def fetch_funding_rates(self, symbols: Strings = None, params={}):
1239
+ async def fetch_funding_rates(self, symbols: Strings = None, params={}) -> FundingRates:
1239
1240
  """
1240
1241
  fetches funding rates for multiple markets
1241
1242
  :see: https://docs.vertexprotocol.com/developer-resources/api/v2/contracts
1242
1243
  :param str[] symbols: unified symbols of the markets to fetch the funding rates for, all market funding rates are returned if not assigned
1243
1244
  :param dict [params]: extra parameters specific to the exchange API endpoint
1244
- :returns dict: an array of `funding rate structures <https://docs.ccxt.com/#/?id=funding-rate-structure>`
1245
+ :returns dict[]: an array of `funding rate structures <https://docs.ccxt.com/#/?id=funding-rate-structure>`
1245
1246
  """
1246
1247
  await self.load_markets()
1247
1248
  request = {}
@@ -6,7 +6,7 @@
6
6
  from ccxt.async_support.base.exchange import Exchange
7
7
  from ccxt.abstract.whitebit import ImplicitAPI
8
8
  import hashlib
9
- from ccxt.base.types import Balances, Bool, Currencies, Currency, Int, Market, MarketType, Num, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, TradingFees, Transaction, TransferEntry
9
+ from ccxt.base.types import Balances, Bool, Currencies, Currency, Int, Market, MarketType, Num, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Tickers, FundingRate, FundingRates, Trade, TradingFees, Transaction, TransferEntry
10
10
  from typing import List
11
11
  from ccxt.base.errors import ExchangeError
12
12
  from ccxt.base.errors import AuthenticationError
@@ -2219,10 +2219,10 @@ class whitebit(Exchange, ImplicitAPI):
2219
2219
  'info': info,
2220
2220
  }
2221
2221
 
2222
- async def fetch_funding_rate(self, symbol: str, params={}):
2222
+ async def fetch_funding_rate(self, symbol: str, params={}) -> FundingRate:
2223
2223
  """
2224
- :see: https://docs.whitebit.com/public/http-v4/#available-futures-markets-list
2225
2224
  fetch the current funding rate
2225
+ :see: https://docs.whitebit.com/public/http-v4/#available-futures-markets-list
2226
2226
  :param str symbol: unified market symbol
2227
2227
  :param dict [params]: extra parameters specific to the exchange API endpoint
2228
2228
  :returns dict: a `funding rate structure <https://docs.ccxt.com/#/?id=funding-rate-structure>`
@@ -2232,13 +2232,13 @@ class whitebit(Exchange, ImplicitAPI):
2232
2232
  response = await self.fetch_funding_rates([symbol], params)
2233
2233
  return self.safe_value(response, symbol)
2234
2234
 
2235
- async def fetch_funding_rates(self, symbols: Strings = None, params={}):
2235
+ async def fetch_funding_rates(self, symbols: Strings = None, params={}) -> FundingRates:
2236
2236
  """
2237
- :see: https://docs.whitebit.com/public/http-v4/#available-futures-markets-list
2238
2237
  fetch the funding rate for multiple markets
2238
+ :see: https://docs.whitebit.com/public/http-v4/#available-futures-markets-list
2239
2239
  :param str[]|None symbols: list of unified market symbols
2240
2240
  :param dict [params]: extra parameters specific to the exchange API endpoint
2241
- :returns dict: a dictionary of `funding rates structures <https://docs.ccxt.com/#/?id=funding-rates-structure>`, indexe by market symbols
2241
+ :returns dict[]: a list of `funding rate structures <https://docs.ccxt.com/#/?id=funding-rates-structure>`, indexed by market symbols
2242
2242
  """
2243
2243
  await self.load_markets()
2244
2244
  symbols = self.market_symbols(symbols)
@@ -2287,11 +2287,11 @@ class whitebit(Exchange, ImplicitAPI):
2287
2287
  # }
2288
2288
  # ]
2289
2289
  #
2290
- data = self.safe_value(response, 'result', [])
2290
+ data = self.safe_list(response, 'result', [])
2291
2291
  result = self.parse_funding_rates(data)
2292
2292
  return self.filter_by_array(result, 'symbol', symbols)
2293
2293
 
2294
- def parse_funding_rate(self, contract, market: Market = None):
2294
+ def parse_funding_rate(self, contract, market: Market = None) -> FundingRate:
2295
2295
  #
2296
2296
  # {
2297
2297
  # "ticker_id":"ADA_PERP",
@@ -2330,7 +2330,7 @@ class whitebit(Exchange, ImplicitAPI):
2330
2330
  indexPrice = self.safe_number(contract, 'indexPrice')
2331
2331
  interestRate = self.safe_number(contract, 'interestRate')
2332
2332
  fundingRate = self.safe_number(contract, 'funding_rate')
2333
- nextFundingTime = self.safe_integer(contract, 'next_funding_rate_timestamp')
2333
+ fundingTime = self.safe_integer(contract, 'next_funding_rate_timestamp')
2334
2334
  return {
2335
2335
  'info': contract,
2336
2336
  'symbol': symbol,
@@ -2340,14 +2340,15 @@ class whitebit(Exchange, ImplicitAPI):
2340
2340
  'timestamp': None,
2341
2341
  'datetime': None,
2342
2342
  'fundingRate': fundingRate,
2343
- 'fundingTimestamp': None,
2344
- 'fundingDatetime': self.iso8601(None),
2343
+ 'fundingTimestamp': fundingTime,
2344
+ 'fundingDatetime': self.iso8601(fundingTime),
2345
2345
  'nextFundingRate': None,
2346
- 'nextFundingTimestamp': nextFundingTime,
2347
- 'nextFundingDatetime': self.iso8601(nextFundingTime),
2346
+ 'nextFundingTimestamp': None,
2347
+ 'nextFundingDatetime': None,
2348
2348
  'previousFundingRate': None,
2349
2349
  'previousFundingTimestamp': None,
2350
2350
  'previousFundingDatetime': None,
2351
+ 'interval': None,
2351
2352
  }
2352
2353
 
2353
2354
  async def fetch_deposits_withdrawals(self, code: Str = None, since: Int = None, limit: Int = None, params={}) -> List[Transaction]:
ccxt/async_support/woo.py CHANGED
@@ -6,7 +6,7 @@
6
6
  from ccxt.async_support.base.exchange import Exchange
7
7
  from ccxt.abstract.woo import ImplicitAPI
8
8
  import hashlib
9
- from ccxt.base.types import Account, Balances, Bool, Conversion, Currencies, Currency, Int, LedgerEntry, Leverage, MarginModification, Market, MarketType, Num, Order, OrderBook, OrderSide, OrderType, Str, Strings, Trade, TradingFees, Transaction, TransferEntry
9
+ from ccxt.base.types import Account, Balances, Bool, Conversion, Currencies, Currency, Int, LedgerEntry, Leverage, MarginModification, Market, MarketType, Num, Order, OrderBook, OrderSide, OrderType, Str, Strings, FundingRate, FundingRates, Trade, TradingFees, Transaction, TransferEntry
10
10
  from typing import List
11
11
  from typing import Any
12
12
  from ccxt.base.errors import ExchangeError
@@ -2548,23 +2548,27 @@ class woo(Exchange, ImplicitAPI):
2548
2548
  result[resultLength - 1] = lastItem
2549
2549
  return self.parse_incomes(result, market, since, limit)
2550
2550
 
2551
- def parse_funding_rate(self, fundingRate, market: Market = None):
2552
- #
2553
- # {
2554
- # "symbol":"PERP_AAVE_USDT",
2555
- # "est_funding_rate":-0.00003447,
2556
- # "est_funding_rate_timestamp":1653633959001,
2557
- # "last_funding_rate":-0.00002094,
2558
- # "last_funding_rate_timestamp":1653631200000,
2559
- # "next_funding_time":1653634800000
2560
- # }
2551
+ def parse_funding_rate(self, fundingRate, market: Market = None) -> FundingRate:
2561
2552
  #
2553
+ # {
2554
+ # "success": True,
2555
+ # "timestamp": 1727427915529,
2556
+ # "symbol": "PERP_BTC_USDT",
2557
+ # "est_funding_rate": -0.00092719,
2558
+ # "est_funding_rate_timestamp": 1727427899060,
2559
+ # "last_funding_rate": -0.00092610,
2560
+ # "last_funding_rate_timestamp": 1727424000000,
2561
+ # "next_funding_time": 1727452800000,
2562
+ # "last_funding_rate_interval": 8,
2563
+ # "est_funding_rate_interval": 8
2564
+ # }
2562
2565
  #
2563
2566
  symbol = self.safe_string(fundingRate, 'symbol')
2564
2567
  market = self.market(symbol)
2565
2568
  nextFundingTimestamp = self.safe_integer(fundingRate, 'next_funding_time')
2566
2569
  estFundingRateTimestamp = self.safe_integer(fundingRate, 'est_funding_rate_timestamp')
2567
2570
  lastFundingRateTimestamp = self.safe_integer(fundingRate, 'last_funding_rate_timestamp')
2571
+ intervalString = self.safe_string(fundingRate, 'est_funding_rate_interval')
2568
2572
  return {
2569
2573
  'info': fundingRate,
2570
2574
  'symbol': market['symbol'],
@@ -2583,9 +2587,17 @@ class woo(Exchange, ImplicitAPI):
2583
2587
  'previousFundingRate': self.safe_number(fundingRate, 'last_funding_rate'),
2584
2588
  'previousFundingTimestamp': lastFundingRateTimestamp,
2585
2589
  'previousFundingDatetime': self.iso8601(lastFundingRateTimestamp),
2590
+ 'interval': intervalString + 'h',
2586
2591
  }
2587
2592
 
2588
- async def fetch_funding_rate(self, symbol: str, params={}):
2593
+ async def fetch_funding_rate(self, symbol: str, params={}) -> FundingRate:
2594
+ """
2595
+ fetch the current funding rate
2596
+ :see: https://docs.woox.io/#get-predicted-funding-rate-for-one-market-public
2597
+ :param str symbol: unified market symbol
2598
+ :param dict [params]: extra parameters specific to the exchange API endpoint
2599
+ :returns dict: a `funding rate structure <https://docs.ccxt.com/#/?id=funding-rate-structure>`
2600
+ """
2589
2601
  await self.load_markets()
2590
2602
  market = self.market(symbol)
2591
2603
  request: dict = {
@@ -2594,19 +2606,28 @@ class woo(Exchange, ImplicitAPI):
2594
2606
  response = await self.v1PublicGetFundingRateSymbol(self.extend(request, params))
2595
2607
  #
2596
2608
  # {
2597
- # "success":true,
2598
- # "timestamp":1653640572711,
2599
- # "symbol":"PERP_BTC_USDT",
2600
- # "est_funding_rate":0.00000738,
2601
- # "est_funding_rate_timestamp":1653640559003,
2602
- # "last_funding_rate":0.00000629,
2603
- # "last_funding_rate_timestamp":1653638400000,
2604
- # "next_funding_time":1653642000000
2609
+ # "success": True,
2610
+ # "timestamp": 1727428037877,
2611
+ # "symbol": "PERP_BTC_USDT",
2612
+ # "est_funding_rate": -0.00092674,
2613
+ # "est_funding_rate_timestamp": 1727428019064,
2614
+ # "last_funding_rate": -0.00092610,
2615
+ # "last_funding_rate_timestamp": 1727424000000,
2616
+ # "next_funding_time": 1727452800000,
2617
+ # "last_funding_rate_interval": 8,
2618
+ # "est_funding_rate_interval": 8
2605
2619
  # }
2606
2620
  #
2607
2621
  return self.parse_funding_rate(response, market)
2608
2622
 
2609
- async def fetch_funding_rates(self, symbols: Strings = None, params={}):
2623
+ async def fetch_funding_rates(self, symbols: Strings = None, params={}) -> FundingRates:
2624
+ """
2625
+ fetch the funding rate for multiple markets
2626
+ :see: https://docs.woox.io/#get-predicted-funding-rate-for-all-markets-public
2627
+ :param str[]|None symbols: list of unified market symbols
2628
+ :param dict [params]: extra parameters specific to the exchange API endpoint
2629
+ :returns dict[]: a list of `funding rate structures <https://docs.ccxt.com/#/?id=funding-rates-structure>`, indexed by market symbols
2630
+ """
2610
2631
  await self.load_markets()
2611
2632
  symbols = self.market_symbols(symbols)
2612
2633
  response = await self.v1PublicGetFundingRates(params)
@@ -5,7 +5,7 @@
5
5
 
6
6
  from ccxt.async_support.base.exchange import Exchange
7
7
  from ccxt.abstract.woofipro import ImplicitAPI
8
- from ccxt.base.types import Balances, Currencies, Currency, Int, LedgerEntry, Leverage, Market, Num, Order, OrderBook, OrderRequest, OrderSide, OrderType, Str, Strings, Trade, TradingFees, Transaction
8
+ from ccxt.base.types import Balances, Currencies, Currency, Int, LedgerEntry, Leverage, Market, Num, Order, OrderBook, OrderRequest, OrderSide, OrderType, Str, Strings, FundingRate, FundingRates, Trade, TradingFees, Transaction
9
9
  from typing import List
10
10
  from typing import Any
11
11
  from ccxt.base.errors import ExchangeError
@@ -736,7 +736,7 @@ class woofipro(Exchange, ImplicitAPI):
736
736
  rows = self.safe_list(data, 'rows', [])
737
737
  return self.parse_trades(rows, market, since, limit)
738
738
 
739
- def parse_funding_rate(self, fundingRate, market: Market = None):
739
+ def parse_funding_rate(self, fundingRate, market: Market = None) -> FundingRate:
740
740
  #
741
741
  # {
742
742
  # "symbol":"PERP_AAVE_USDT",
@@ -748,12 +748,14 @@ class woofipro(Exchange, ImplicitAPI):
748
748
  # "sum_unitary_funding": 521.367
749
749
  # }
750
750
  #
751
- #
752
751
  symbol = self.safe_string(fundingRate, 'symbol')
753
752
  market = self.market(symbol)
754
753
  nextFundingTimestamp = self.safe_integer(fundingRate, 'next_funding_time')
755
754
  estFundingRateTimestamp = self.safe_integer(fundingRate, 'est_funding_rate_timestamp')
756
755
  lastFundingRateTimestamp = self.safe_integer(fundingRate, 'last_funding_rate_timestamp')
756
+ fundingTimeString = self.safe_string(fundingRate, 'last_funding_rate_timestamp')
757
+ nextFundingTimeString = self.safe_string(fundingRate, 'next_funding_time')
758
+ millisecondsInterval = Precise.string_sub(nextFundingTimeString, fundingTimeString)
757
759
  return {
758
760
  'info': fundingRate,
759
761
  'symbol': market['symbol'],
@@ -772,9 +774,20 @@ class woofipro(Exchange, ImplicitAPI):
772
774
  'previousFundingRate': self.safe_number(fundingRate, 'last_funding_rate'),
773
775
  'previousFundingTimestamp': lastFundingRateTimestamp,
774
776
  'previousFundingDatetime': self.iso8601(lastFundingRateTimestamp),
777
+ 'interval': self.parse_funding_interval(millisecondsInterval),
778
+ }
779
+
780
+ def parse_funding_interval(self, interval):
781
+ intervals: dict = {
782
+ '3600000': '1h',
783
+ '14400000': '4h',
784
+ '28800000': '8h',
785
+ '57600000': '16h',
786
+ '86400000': '24h',
775
787
  }
788
+ return self.safe_string(intervals, interval, interval)
776
789
 
777
- async def fetch_funding_rate(self, symbol: str, params={}):
790
+ async def fetch_funding_rate(self, symbol: str, params={}) -> FundingRate:
778
791
  """
779
792
  fetch the current funding rate
780
793
  :see: https://orderly.network/docs/build-on-evm/evm-api/restful-api/public/get-predicted-funding-rate-for-one-market
@@ -806,9 +819,9 @@ class woofipro(Exchange, ImplicitAPI):
806
819
  data = self.safe_dict(response, 'data', {})
807
820
  return self.parse_funding_rate(data, market)
808
821
 
809
- async def fetch_funding_rates(self, symbols: Strings = None, params={}):
822
+ async def fetch_funding_rates(self, symbols: Strings = None, params={}) -> FundingRates:
810
823
  """
811
- fetch the current funding rates
824
+ fetch the current funding rate for multiple markets
812
825
  :see: https://orderly.network/docs/build-on-evm/evm-api/restful-api/public/get-predicted-funding-rates-for-all-markets
813
826
  :param str[] symbols: unified market symbols
814
827
  :param dict [params]: extra parameters specific to the exchange API endpoint
ccxt/async_support/xt.py CHANGED
@@ -7,7 +7,7 @@ from ccxt.async_support.base.exchange import Exchange
7
7
  from ccxt.abstract.xt import ImplicitAPI
8
8
  import asyncio
9
9
  import hashlib
10
- from ccxt.base.types import Currencies, Currency, Int, LedgerEntry, LeverageTier, MarginModification, Market, Num, Order, OrderSide, OrderType, Str, Tickers, Transaction, TransferEntry
10
+ from ccxt.base.types import Currencies, Currency, Int, LedgerEntry, LeverageTier, MarginModification, Market, Num, Order, OrderSide, OrderType, Str, Tickers, FundingRate, Transaction, TransferEntry
11
11
  from typing import List
12
12
  from ccxt.base.errors import ExchangeError
13
13
  from ccxt.base.errors import AuthenticationError
@@ -4030,7 +4030,7 @@ class xt(Exchange, ImplicitAPI):
4030
4030
  sorted = self.sort_by(rates, 'timestamp')
4031
4031
  return self.filter_by_symbol_since_limit(sorted, market['symbol'], since, limit)
4032
4032
 
4033
- async def fetch_funding_rate(self, symbol: str, params={}):
4033
+ async def fetch_funding_rate(self, symbol: str, params={}) -> FundingRate:
4034
4034
  """
4035
4035
  fetch the current funding rate
4036
4036
  :see: https://doc.xt.com/#futures_quotesgetFundingRate
@@ -4068,7 +4068,7 @@ class xt(Exchange, ImplicitAPI):
4068
4068
  result = self.safe_value(response, 'result', {})
4069
4069
  return self.parse_funding_rate(result, market)
4070
4070
 
4071
- def parse_funding_rate(self, contract, market=None):
4071
+ def parse_funding_rate(self, contract, market=None) -> FundingRate:
4072
4072
  #
4073
4073
  # {
4074
4074
  # "symbol": "btc_usdt",
@@ -4080,6 +4080,7 @@ class xt(Exchange, ImplicitAPI):
4080
4080
  marketId = self.safe_string(contract, 'symbol')
4081
4081
  symbol = self.safe_symbol(marketId, market, '_', 'swap')
4082
4082
  timestamp = self.safe_integer(contract, 'nextCollectionTime')
4083
+ interval = self.safe_string(contract, 'collectionInternal')
4083
4084
  return {
4084
4085
  'info': contract,
4085
4086
  'symbol': symbol,
@@ -4098,6 +4099,7 @@ class xt(Exchange, ImplicitAPI):
4098
4099
  'previousFundingRate': None,
4099
4100
  'previousFundingTimestamp': None,
4100
4101
  'previousFundingDatetime': None,
4102
+ 'interval': interval + 'h',
4101
4103
  }
4102
4104
 
4103
4105
  async def fetch_funding_history(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
ccxt/base/exchange.py CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  # -----------------------------------------------------------------------------
6
6
 
7
- __version__ = '4.4.8'
7
+ __version__ = '4.4.10'
8
8
 
9
9
  # -----------------------------------------------------------------------------
10
10
 
ccxt/base/types.py CHANGED
@@ -481,6 +481,7 @@ class FundingRate(TypedDict):
481
481
  previousFundingDatetime: Str
482
482
  previousFundingRate: Num
483
483
  info: Dict[str, Any]
484
+ interval: Str
484
485
 
485
486
 
486
487
  class LeverageTier: