ccxt 4.4.9__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 (77) hide show
  1. ccxt/__init__.py +1 -1
  2. ccxt/abstract/oceanex.py +5 -0
  3. ccxt/ascendex.py +5 -4
  4. ccxt/async_support/__init__.py +1 -1
  5. ccxt/async_support/ascendex.py +5 -4
  6. ccxt/async_support/base/exchange.py +1 -1
  7. ccxt/async_support/binance.py +8 -11
  8. ccxt/async_support/bingx.py +20 -21
  9. ccxt/async_support/bitfinex2.py +7 -16
  10. ccxt/async_support/bitget.py +8 -7
  11. ccxt/async_support/bitmart.py +4 -3
  12. ccxt/async_support/bitmex.py +7 -6
  13. ccxt/async_support/blofin.py +7 -16
  14. ccxt/async_support/bybit.py +18 -16
  15. ccxt/async_support/coinex.py +19 -5
  16. ccxt/async_support/delta.py +6 -5
  17. ccxt/async_support/deribit.py +4 -3
  18. ccxt/async_support/digifinex.py +18 -4
  19. ccxt/async_support/gate.py +32 -13
  20. ccxt/async_support/hashkey.py +6 -6
  21. ccxt/async_support/hitbtc.py +6 -5
  22. ccxt/async_support/htx.py +23 -6
  23. ccxt/async_support/hyperliquid.py +6 -1
  24. ccxt/async_support/krakenfutures.py +6 -5
  25. ccxt/async_support/kucoinfutures.py +13 -2
  26. ccxt/async_support/mexc.py +4 -3
  27. ccxt/async_support/oceanex.py +80 -4
  28. ccxt/async_support/okx.py +17 -3
  29. ccxt/async_support/oxfun.py +7 -7
  30. ccxt/async_support/phemex.py +4 -3
  31. ccxt/async_support/poloniexfutures.py +13 -2
  32. ccxt/async_support/vertex.py +6 -5
  33. ccxt/async_support/whitebit.py +14 -13
  34. ccxt/async_support/woo.py +42 -21
  35. ccxt/async_support/woofipro.py +19 -6
  36. ccxt/async_support/xt.py +5 -3
  37. ccxt/base/exchange.py +1 -1
  38. ccxt/base/types.py +1 -0
  39. ccxt/binance.py +8 -11
  40. ccxt/bingx.py +20 -21
  41. ccxt/bitfinex2.py +7 -16
  42. ccxt/bitget.py +8 -7
  43. ccxt/bitmart.py +4 -3
  44. ccxt/bitmex.py +7 -6
  45. ccxt/blofin.py +7 -16
  46. ccxt/bybit.py +18 -16
  47. ccxt/coinex.py +19 -5
  48. ccxt/delta.py +6 -5
  49. ccxt/deribit.py +4 -3
  50. ccxt/digifinex.py +18 -4
  51. ccxt/gate.py +32 -13
  52. ccxt/hashkey.py +6 -6
  53. ccxt/hitbtc.py +6 -5
  54. ccxt/htx.py +23 -6
  55. ccxt/hyperliquid.py +6 -1
  56. ccxt/krakenfutures.py +6 -5
  57. ccxt/kucoinfutures.py +13 -2
  58. ccxt/mexc.py +4 -3
  59. ccxt/oceanex.py +80 -4
  60. ccxt/okx.py +17 -3
  61. ccxt/oxfun.py +7 -7
  62. ccxt/phemex.py +4 -3
  63. ccxt/poloniexfutures.py +13 -2
  64. ccxt/pro/__init__.py +1 -1
  65. ccxt/pro/deribit.py +39 -2
  66. ccxt/pro/gate.py +1 -1
  67. ccxt/vertex.py +6 -5
  68. ccxt/whitebit.py +14 -13
  69. ccxt/woo.py +42 -21
  70. ccxt/woofipro.py +19 -6
  71. ccxt/xt.py +5 -3
  72. ccxt-4.4.10.dist-info/METADATA +636 -0
  73. {ccxt-4.4.9.dist-info → ccxt-4.4.10.dist-info}/RECORD +76 -76
  74. ccxt-4.4.9.dist-info/METADATA +0 -636
  75. {ccxt-4.4.9.dist-info → ccxt-4.4.10.dist-info}/LICENSE.txt +0 -0
  76. {ccxt-4.4.9.dist-info → ccxt-4.4.10.dist-info}/WHEEL +0 -0
  77. {ccxt-4.4.9.dist-info → ccxt-4.4.10.dist-info}/top_level.txt +0 -0
@@ -7,7 +7,7 @@ from ccxt.async_support.base.exchange import Exchange
7
7
  from ccxt.abstract.bybit import ImplicitAPI
8
8
  import asyncio
9
9
  import hashlib
10
- from ccxt.base.types import Balances, Conversion, CrossBorrowRate, Currencies, Currency, Greeks, Int, LedgerEntry, Leverage, LeverageTier, LeverageTiers, Market, MarketInterface, Num, Option, OptionChain, Order, OrderBook, OrderRequest, CancellationRequest, OrderSide, OrderType, Position, Str, Strings, Ticker, Tickers, Trade, TradingFeeInterface, TradingFees, Transaction, TransferEntry
10
+ from ccxt.base.types import Balances, Conversion, CrossBorrowRate, Currencies, Currency, Greeks, Int, LedgerEntry, Leverage, LeverageTier, LeverageTiers, Market, MarketInterface, Num, Option, OptionChain, Order, OrderBook, OrderRequest, CancellationRequest, OrderSide, OrderType, Position, Str, Strings, Ticker, Tickers, FundingRate, FundingRates, Trade, TradingFeeInterface, TradingFees, Transaction, TransferEntry
11
11
  from typing import List
12
12
  from ccxt.base.errors import ExchangeError
13
13
  from ccxt.base.errors import AuthenticationError
@@ -96,7 +96,7 @@ class bybit(Exchange, ImplicitAPI):
96
96
  'fetchDepositWithdrawFee': 'emulated',
97
97
  'fetchDepositWithdrawFees': True,
98
98
  'fetchFundingHistory': True,
99
- 'fetchFundingRate': True, # emulated in exchange
99
+ 'fetchFundingRate': 'emulated', # emulated in exchange
100
100
  'fetchFundingRateHistory': True,
101
101
  'fetchFundingRates': True,
102
102
  'fetchGreeks': True,
@@ -2345,7 +2345,8 @@ class bybit(Exchange, ImplicitAPI):
2345
2345
  ohlcvs = self.safe_list(result, 'list', [])
2346
2346
  return self.parse_ohlcvs(ohlcvs, market, timeframe, since, limit)
2347
2347
 
2348
- def parse_funding_rate(self, ticker, market: Market = None):
2348
+ def parse_funding_rate(self, ticker, market: Market = None) -> FundingRate:
2349
+ #
2349
2350
  # {
2350
2351
  # "symbol": "BTCUSDT",
2351
2352
  # "bidPrice": "19255",
@@ -2396,15 +2397,16 @@ class bybit(Exchange, ImplicitAPI):
2396
2397
  'previousFundingRate': None,
2397
2398
  'previousFundingTimestamp': None,
2398
2399
  'previousFundingDatetime': None,
2400
+ 'interval': None,
2399
2401
  }
2400
2402
 
2401
- async def fetch_funding_rates(self, symbols: Strings = None, params={}):
2403
+ async def fetch_funding_rates(self, symbols: Strings = None, params={}) -> FundingRates:
2402
2404
  """
2403
2405
  fetches funding rates for multiple markets
2404
2406
  :see: https://bybit-exchange.github.io/docs/v5/market/tickers
2405
2407
  :param str[] symbols: unified symbols of the markets to fetch the funding rates for, all market funding rates are returned if not assigned
2406
2408
  :param dict [params]: extra parameters specific to the exchange API endpoint
2407
- :returns dict: an array of `funding rate structures <https://docs.ccxt.com/#/?id=funding-rate-structure>`
2409
+ :returns dict[]: a list of `funding rate structures <https://docs.ccxt.com/#/?id=funding-rate-structure>`
2408
2410
  """
2409
2411
  await self.load_markets()
2410
2412
  market = None
@@ -2460,17 +2462,10 @@ class bybit(Exchange, ImplicitAPI):
2460
2462
  # "time": 1663670053454
2461
2463
  # }
2462
2464
  #
2463
- tickerList = self.safe_value(response, 'result', [])
2464
- timestamp = self.safe_integer(response, 'time')
2465
- tickerList = self.safe_value(tickerList, 'list')
2466
- fundingRates: dict = {}
2467
- for i in range(0, len(tickerList)):
2468
- rawTicker = tickerList[i]
2469
- rawTicker['timestamp'] = timestamp # will be removed inside the parser
2470
- ticker = self.parse_funding_rate(tickerList[i], None)
2471
- symbol = ticker['symbol']
2472
- fundingRates[symbol] = ticker
2473
- return self.filter_by_array(fundingRates, 'symbol', symbols)
2465
+ data = self.safe_dict(response, 'result', {})
2466
+ tickerList = self.safe_list(data, 'list', [])
2467
+ result = self.parse_funding_rates(tickerList)
2468
+ return self.filter_by_array(result, 'symbol', symbols)
2474
2469
 
2475
2470
  async def fetch_funding_rate_history(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
2476
2471
  """
@@ -3518,6 +3513,7 @@ class bybit(Exchange, ImplicitAPI):
3518
3513
  # 'orderIv': '0', # Implied volatility; parameters are passed according to the real value; for example, for 10%, 0.1 is passed
3519
3514
  }
3520
3515
  hedged = self.safe_bool(params, 'hedged', False)
3516
+ reduceOnly = self.safe_bool(params, 'reduceOnly')
3521
3517
  triggerPrice = self.safe_value_2(params, 'triggerPrice', 'stopPrice')
3522
3518
  stopLossTriggerPrice = self.safe_value(params, 'stopLossPrice')
3523
3519
  takeProfitTriggerPrice = self.safe_value(params, 'takeProfitPrice')
@@ -3668,6 +3664,9 @@ class bybit(Exchange, ImplicitAPI):
3668
3664
  request['tpOrderType'] = 'Limit'
3669
3665
  request['tpLimitPrice'] = self.get_price(symbol, tpLimitPrice)
3670
3666
  if not market['spot'] and hedged:
3667
+ if reduceOnly:
3668
+ params = self.omit(params, 'reduceOnly')
3669
+ side = 'sell' if (side == 'buy') else 'buy'
3671
3670
  request['positionIdx'] = 1 if (side == 'buy') else 2
3672
3671
  params = self.omit(params, ['stopPrice', 'timeInForce', 'stopLossPrice', 'takeProfitPrice', 'postOnly', 'clientOrderId', 'triggerPrice', 'stopLoss', 'takeProfit', 'trailingAmount', 'trailingTriggerPrice', 'hedged'])
3673
3672
  return self.extend(request, params)
@@ -6345,6 +6344,8 @@ class bybit(Exchange, ImplicitAPI):
6345
6344
  initialMarginString = Precise.string_div(size, Precise.string_mul(entryPrice, leverage))
6346
6345
  maintenanceMarginPercentage = Precise.string_div(maintenanceMarginString, notional)
6347
6346
  marginRatio = Precise.string_div(maintenanceMarginString, collateralString, 4)
6347
+ positionIdx = self.safe_string(position, 'positionIdx')
6348
+ hedged = (positionIdx is not None) and (positionIdx != '0')
6348
6349
  return self.safe_position({
6349
6350
  'info': position,
6350
6351
  'id': None,
@@ -6373,6 +6374,7 @@ class bybit(Exchange, ImplicitAPI):
6373
6374
  'percentage': None,
6374
6375
  'stopLossPrice': self.safe_number_2(position, 'stop_loss', 'stopLoss'),
6375
6376
  'takeProfitPrice': self.safe_number_2(position, 'take_profit', 'takeProfit'),
6377
+ 'hedged': hedged,
6376
6378
  })
6377
6379
 
6378
6380
  async def fetch_leverage(self, symbol: str, params={}) -> Leverage:
@@ -6,7 +6,7 @@
6
6
  from ccxt.async_support.base.exchange import Exchange
7
7
  from ccxt.abstract.coinex import ImplicitAPI
8
8
  import asyncio
9
- from ccxt.base.types import Balances, Currencies, Currency, Int, IsolatedBorrowRate, Leverage, LeverageTier, LeverageTiers, MarginModification, Market, Num, Order, OrderRequest, OrderSide, OrderType, Position, Str, Strings, Ticker, Tickers, Trade, TradingFeeInterface, TradingFees, Transaction, TransferEntry
9
+ from ccxt.base.types import Balances, Currencies, Currency, Int, IsolatedBorrowRate, Leverage, LeverageTier, LeverageTiers, MarginModification, Market, Num, Order, OrderRequest, OrderSide, OrderType, Position, Str, Strings, Ticker, Tickers, FundingRate, FundingRates, Trade, TradingFeeInterface, 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
@@ -4254,7 +4254,7 @@ class coinex(Exchange, ImplicitAPI):
4254
4254
  })
4255
4255
  return result
4256
4256
 
4257
- async def fetch_funding_rate(self, symbol: str, params={}):
4257
+ async def fetch_funding_rate(self, symbol: str, params={}) -> FundingRate:
4258
4258
  """
4259
4259
  fetch the current funding rate
4260
4260
  :see: https://docs.coinex.com/api/v2/futures/market/http/list-market-funding-rate
@@ -4292,7 +4292,7 @@ class coinex(Exchange, ImplicitAPI):
4292
4292
  first = self.safe_dict(data, 0, {})
4293
4293
  return self.parse_funding_rate(first, market)
4294
4294
 
4295
- def parse_funding_rate(self, contract, market: Market = None):
4295
+ def parse_funding_rate(self, contract, market: Market = None) -> FundingRate:
4296
4296
  #
4297
4297
  # fetchFundingRate, fetchFundingRates
4298
4298
  #
@@ -4309,6 +4309,9 @@ class coinex(Exchange, ImplicitAPI):
4309
4309
  #
4310
4310
  currentFundingTimestamp = self.safe_integer(contract, 'latest_funding_time')
4311
4311
  futureFundingTimestamp = self.safe_integer(contract, 'next_funding_time')
4312
+ fundingTimeString = self.safe_string(contract, 'latest_funding_time')
4313
+ nextFundingTimeString = self.safe_string(contract, 'next_funding_time')
4314
+ millisecondsInterval = Precise.string_sub(nextFundingTimeString, fundingTimeString)
4312
4315
  marketId = self.safe_string(contract, 'market')
4313
4316
  return {
4314
4317
  'info': contract,
@@ -4328,11 +4331,22 @@ class coinex(Exchange, ImplicitAPI):
4328
4331
  'previousFundingRate': None,
4329
4332
  'previousFundingTimestamp': None,
4330
4333
  'previousFundingDatetime': None,
4334
+ 'interval': self.parse_funding_interval(millisecondsInterval),
4331
4335
  }
4332
4336
 
4333
- async def fetch_funding_rates(self, symbols: Strings = None, params={}):
4337
+ def parse_funding_interval(self, interval):
4338
+ intervals: dict = {
4339
+ '3600000': '1h',
4340
+ '14400000': '4h',
4341
+ '28800000': '8h',
4342
+ '57600000': '16h',
4343
+ '86400000': '24h',
4344
+ }
4345
+ return self.safe_string(intervals, interval, interval)
4346
+
4347
+ async def fetch_funding_rates(self, symbols: Strings = None, params={}) -> FundingRates:
4334
4348
  """
4335
- fetch the current funding rates
4349
+ fetch the current funding rates for multiple markets
4336
4350
  :see: https://docs.coinex.com/api/v2/futures/market/http/list-market-funding-rate
4337
4351
  :param str[] symbols: unified market symbols
4338
4352
  :param dict [params]: extra parameters specific to the exchange API endpoint
@@ -6,7 +6,7 @@
6
6
  from ccxt.async_support.base.exchange import Exchange
7
7
  from ccxt.abstract.delta import ImplicitAPI
8
8
  import hashlib
9
- from ccxt.base.types import Balances, Currencies, Currency, Greeks, Int, LedgerEntry, Leverage, MarginMode, MarginModification, Market, MarketInterface, Num, Option, Order, OrderBook, OrderSide, OrderType, Position, Str, Strings, Ticker, Tickers, Trade
9
+ from ccxt.base.types import Balances, Currencies, Currency, Greeks, Int, LedgerEntry, Leverage, MarginMode, MarginModification, Market, MarketInterface, Num, Option, Order, OrderBook, OrderSide, OrderType, Position, Str, Strings, Ticker, Tickers, FundingRate, FundingRates, Trade
10
10
  from typing import List
11
11
  from ccxt.base.errors import ExchangeError
12
12
  from ccxt.base.errors import AuthenticationError
@@ -2288,7 +2288,7 @@ class delta(Exchange, ImplicitAPI):
2288
2288
  'info': depositAddress,
2289
2289
  }
2290
2290
 
2291
- async def fetch_funding_rate(self, symbol: str, params={}):
2291
+ async def fetch_funding_rate(self, symbol: str, params={}) -> FundingRate:
2292
2292
  """
2293
2293
  fetch the current funding rate
2294
2294
  :see: https://docs.delta.exchange/#get-ticker-for-a-product-by-symbol
@@ -2352,13 +2352,13 @@ class delta(Exchange, ImplicitAPI):
2352
2352
  result = self.safe_dict(response, 'result', {})
2353
2353
  return self.parse_funding_rate(result, market)
2354
2354
 
2355
- async def fetch_funding_rates(self, symbols: Strings = None, params={}):
2355
+ async def fetch_funding_rates(self, symbols: Strings = None, params={}) -> FundingRates:
2356
2356
  """
2357
2357
  fetch the funding rate for multiple markets
2358
2358
  :see: https://docs.delta.exchange/#get-tickers-for-products
2359
2359
  :param str[]|None symbols: list of unified market symbols
2360
2360
  :param dict [params]: extra parameters specific to the exchange API endpoint
2361
- :returns dict: a dictionary of `funding rates structures <https://docs.ccxt.com/#/?id=funding-rates-structure>`, indexe by market symbols
2361
+ :returns dict[]: a list of `funding rate structures <https://docs.ccxt.com/#/?id=funding-rates-structure>`, indexed by market symbols
2362
2362
  """
2363
2363
  await self.load_markets()
2364
2364
  symbols = self.market_symbols(symbols)
@@ -2417,7 +2417,7 @@ class delta(Exchange, ImplicitAPI):
2417
2417
  result = self.parse_funding_rates(rates)
2418
2418
  return self.filter_by_array(result, 'symbol', symbols)
2419
2419
 
2420
- def parse_funding_rate(self, contract, market: Market = None):
2420
+ def parse_funding_rate(self, contract, market: Market = None) -> FundingRate:
2421
2421
  #
2422
2422
  # {
2423
2423
  # "close": 30600.5,
@@ -2482,6 +2482,7 @@ class delta(Exchange, ImplicitAPI):
2482
2482
  'previousFundingRate': None,
2483
2483
  'previousFundingTimestamp': None,
2484
2484
  'previousFundingDatetime': None,
2485
+ 'interval': None,
2485
2486
  }
2486
2487
 
2487
2488
  async def add_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.deribit import ImplicitAPI
8
8
  import hashlib
9
- from ccxt.base.types import Account, Balances, Currencies, Currency, Greeks, Int, Market, MarketInterface, Num, Option, OptionChain, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, TradingFees, Transaction, TransferEntry
9
+ from ccxt.base.types import Account, Balances, Currencies, Currency, Greeks, Int, Market, MarketInterface, Num, Option, OptionChain, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Tickers, FundingRate, 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
@@ -2852,7 +2852,7 @@ class deribit(Exchange, ImplicitAPI):
2852
2852
  data = self.safe_list(response, 'result', [])
2853
2853
  return self.parse_deposit_withdraw_fees(data, codes, 'currency')
2854
2854
 
2855
- async def fetch_funding_rate(self, symbol: str, params={}):
2855
+ async def fetch_funding_rate(self, symbol: str, params={}) -> FundingRate:
2856
2856
  """
2857
2857
  fetch the current funding rate
2858
2858
  :see: https://docs.deribit.com/#public-get_funding_rate_value
@@ -2932,7 +2932,7 @@ class deribit(Exchange, ImplicitAPI):
2932
2932
  rates.append(rate)
2933
2933
  return self.filter_by_symbol_since_limit(rates, symbol, since, limit)
2934
2934
 
2935
- def parse_funding_rate(self, contract, market: Market = None):
2935
+ def parse_funding_rate(self, contract, market: Market = None) -> FundingRate:
2936
2936
  #
2937
2937
  # {
2938
2938
  # "jsonrpc":"2.0",
@@ -2972,6 +2972,7 @@ class deribit(Exchange, ImplicitAPI):
2972
2972
  'previousFundingRate': None,
2973
2973
  'previousFundingTimestamp': None,
2974
2974
  'previousFundingDatetime': None,
2975
+ 'interval': '8h',
2975
2976
  }
2976
2977
 
2977
2978
  async def fetch_liquidations(self, symbol: str, since: Int = None, limit: Int = None, params={}):
@@ -8,7 +8,7 @@ from ccxt.abstract.digifinex import ImplicitAPI
8
8
  import asyncio
9
9
  import hashlib
10
10
  import json
11
- from ccxt.base.types import Balances, CrossBorrowRate, CrossBorrowRates, Currencies, Currency, Int, LedgerEntry, LeverageTier, LeverageTiers, MarginModification, Market, Num, Order, OrderBook, OrderRequest, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, TradingFeeInterface, Transaction, TransferEntry
11
+ from ccxt.base.types import Balances, CrossBorrowRate, CrossBorrowRates, Currencies, Currency, Int, LedgerEntry, LeverageTier, LeverageTiers, MarginModification, Market, Num, Order, OrderBook, OrderRequest, OrderSide, OrderType, Str, Strings, Ticker, Tickers, FundingRate, Trade, TradingFeeInterface, Transaction, TransferEntry
12
12
  from typing import List
13
13
  from ccxt.base.errors import ExchangeError
14
14
  from ccxt.base.errors import AuthenticationError
@@ -2981,7 +2981,7 @@ class digifinex(Exchange, ImplicitAPI):
2981
2981
  result[code] = borrowRate
2982
2982
  return result
2983
2983
 
2984
- async def fetch_funding_rate(self, symbol: str, params={}):
2984
+ async def fetch_funding_rate(self, symbol: str, params={}) -> FundingRate:
2985
2985
  """
2986
2986
  fetch the current funding rate
2987
2987
  :see: https://docs.digifinex.com/en-ww/swap/v2/rest.html#currentfundingrate
@@ -3012,7 +3012,7 @@ class digifinex(Exchange, ImplicitAPI):
3012
3012
  data = self.safe_value(response, 'data', {})
3013
3013
  return self.parse_funding_rate(data, market)
3014
3014
 
3015
- def parse_funding_rate(self, contract, market: Market = None):
3015
+ def parse_funding_rate(self, contract, market: Market = None) -> FundingRate:
3016
3016
  #
3017
3017
  # {
3018
3018
  # "instrument_id": "BTCUSDTPERP",
@@ -3025,6 +3025,9 @@ class digifinex(Exchange, ImplicitAPI):
3025
3025
  marketId = self.safe_string(contract, 'instrument_id')
3026
3026
  timestamp = self.safe_integer(contract, 'funding_time')
3027
3027
  nextTimestamp = self.safe_integer(contract, 'next_funding_time')
3028
+ fundingTimeString = self.safe_string(contract, 'funding_time')
3029
+ nextFundingTimeString = self.safe_string(contract, 'next_funding_time')
3030
+ millisecondsInterval = Precise.string_sub(nextFundingTimeString, fundingTimeString)
3028
3031
  return {
3029
3032
  'info': contract,
3030
3033
  'symbol': self.safe_symbol(marketId, market),
@@ -3037,14 +3040,25 @@ class digifinex(Exchange, ImplicitAPI):
3037
3040
  'fundingRate': self.safe_number(contract, 'funding_rate'),
3038
3041
  'fundingTimestamp': timestamp,
3039
3042
  'fundingDatetime': self.iso8601(timestamp),
3040
- 'nextFundingRate': self.safe_string(contract, 'next_funding_rate'),
3043
+ 'nextFundingRate': self.safe_number(contract, 'next_funding_rate'),
3041
3044
  'nextFundingTimestamp': nextTimestamp,
3042
3045
  'nextFundingDatetime': self.iso8601(nextTimestamp),
3043
3046
  'previousFundingRate': None,
3044
3047
  'previousFundingTimestamp': None,
3045
3048
  'previousFundingDatetime': None,
3049
+ 'interval': self.parse_funding_interval(millisecondsInterval),
3046
3050
  }
3047
3051
 
3052
+ def parse_funding_interval(self, interval):
3053
+ intervals: dict = {
3054
+ '3600000': '1h',
3055
+ '14400000': '4h',
3056
+ '28800000': '8h',
3057
+ '57600000': '16h',
3058
+ '86400000': '24h',
3059
+ }
3060
+ return self.safe_string(intervals, interval, interval)
3061
+
3048
3062
  async def fetch_funding_rate_history(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
3049
3063
  """
3050
3064
  fetches historical funding rate prices
@@ -7,7 +7,7 @@ from ccxt.async_support.base.exchange import Exchange
7
7
  from ccxt.abstract.gate import ImplicitAPI
8
8
  import asyncio
9
9
  import hashlib
10
- from ccxt.base.types import Balances, Currencies, Currency, FundingHistory, Greeks, Int, LedgerEntry, Leverage, Leverages, LeverageTier, LeverageTiers, MarginModification, Market, MarketInterface, Num, Option, OptionChain, Order, OrderBook, OrderRequest, CancellationRequest, OrderSide, OrderType, Position, Str, Strings, Ticker, Tickers, Trade, TradingFeeInterface, TradingFees, Transaction, TransferEntry
10
+ from ccxt.base.types import Balances, Currencies, Currency, FundingHistory, Greeks, Int, LedgerEntry, Leverage, Leverages, LeverageTier, LeverageTiers, MarginModification, Market, MarketInterface, Num, Option, OptionChain, Order, OrderBook, OrderRequest, CancellationRequest, OrderSide, OrderType, Position, Str, Strings, Ticker, Tickers, FundingRate, FundingRates, Trade, TradingFeeInterface, TradingFees, Transaction, TransferEntry
11
11
  from typing import List
12
12
  from ccxt.base.errors import ExchangeError
13
13
  from ccxt.base.errors import AuthenticationError
@@ -1646,7 +1646,7 @@ class gate(Exchange, ImplicitAPI):
1646
1646
  result[code]['withdraw'] = withdrawAvailable
1647
1647
  return result
1648
1648
 
1649
- async def fetch_funding_rate(self, symbol: str, params={}):
1649
+ async def fetch_funding_rate(self, symbol: str, params={}) -> FundingRate:
1650
1650
  """
1651
1651
  fetch the current funding rate
1652
1652
  :see: https://www.gate.io/docs/developers/apiv4/en/#get-a-single-contract
@@ -1706,13 +1706,13 @@ class gate(Exchange, ImplicitAPI):
1706
1706
  #
1707
1707
  return self.parse_funding_rate(response)
1708
1708
 
1709
- async def fetch_funding_rates(self, symbols: Strings = None, params={}):
1709
+ async def fetch_funding_rates(self, symbols: Strings = None, params={}) -> FundingRates:
1710
1710
  """
1711
1711
  fetch the funding rate for multiple markets
1712
1712
  :see: https://www.gate.io/docs/developers/apiv4/en/#list-all-futures-contracts
1713
1713
  :param str[]|None symbols: list of unified market symbols
1714
1714
  :param dict [params]: extra parameters specific to the exchange API endpoint
1715
- :returns dict: a dictionary of `funding rates structures <https://docs.ccxt.com/#/?id=funding-rates-structure>`, indexe by market symbols
1715
+ :returns dict[]: a list of `funding rate structures <https://docs.ccxt.com/#/?id=funding-rates-structure>`, indexed by market symbols
1716
1716
  """
1717
1717
  await self.load_markets()
1718
1718
  symbols = self.market_symbols(symbols)
@@ -1765,7 +1765,7 @@ class gate(Exchange, ImplicitAPI):
1765
1765
  result = self.parse_funding_rates(response)
1766
1766
  return self.filter_by_array(result, 'symbol', symbols)
1767
1767
 
1768
- def parse_funding_rate(self, contract, market: Market = None):
1768
+ def parse_funding_rate(self, contract, market: Market = None) -> FundingRate:
1769
1769
  #
1770
1770
  # {
1771
1771
  # "name": "BTC_USDT",
@@ -1816,6 +1816,7 @@ class gate(Exchange, ImplicitAPI):
1816
1816
  fundingRate = self.safe_number(contract, 'funding_rate')
1817
1817
  fundingTime = self.safe_timestamp(contract, 'funding_next_apply')
1818
1818
  fundingRateIndicative = self.safe_number(contract, 'funding_rate_indicative')
1819
+ fundingInterval = Precise.string_mul('1000', self.safe_string(contract, 'funding_interval'))
1819
1820
  return {
1820
1821
  'info': contract,
1821
1822
  'symbol': symbol,
@@ -1834,8 +1835,19 @@ class gate(Exchange, ImplicitAPI):
1834
1835
  'previousFundingRate': None,
1835
1836
  'previousFundingTimestamp': None,
1836
1837
  'previousFundingDatetime': None,
1838
+ 'interval': self.parse_funding_interval(fundingInterval),
1837
1839
  }
1838
1840
 
1841
+ def parse_funding_interval(self, interval):
1842
+ intervals: dict = {
1843
+ '3600000': '1h',
1844
+ '14400000': '4h',
1845
+ '28800000': '8h',
1846
+ '57600000': '16h',
1847
+ '86400000': '24h',
1848
+ }
1849
+ return self.safe_string(intervals, interval, interval)
1850
+
1839
1851
  async def fetch_network_deposit_address(self, code: str, params={}):
1840
1852
  await self.load_markets()
1841
1853
  currency = self.currency(code)
@@ -4411,7 +4423,6 @@ class gate(Exchange, ImplicitAPI):
4411
4423
  """
4412
4424
  await self.load_markets()
4413
4425
  until = self.safe_integer(params, 'until')
4414
- params = self.omit(params, 'until')
4415
4426
  market = None
4416
4427
  if symbol is not None:
4417
4428
  market = self.market(symbol)
@@ -4428,30 +4439,38 @@ class gate(Exchange, ImplicitAPI):
4428
4439
  if since is not None:
4429
4440
  request['from'] = self.parse_to_int(since / 1000)
4430
4441
  if until is not None:
4442
+ params = self.omit(params, 'until')
4431
4443
  request['to'] = self.parse_to_int(until / 1000)
4432
4444
  if limit is not None:
4433
4445
  request['limit'] = limit
4434
4446
  response = await self.privateFuturesGetSettleOrdersTimerange(self.extend(request, params))
4435
4447
  return self.parse_orders(response, market, since, limit)
4436
4448
 
4437
- def fetch_orders_by_status_request(self, status, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
4449
+ def prepare_orders_by_status_request(self, status, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
4438
4450
  market = None
4439
4451
  if symbol is not None:
4440
4452
  market = self.market(symbol)
4441
4453
  symbol = market['symbol']
4442
4454
  stop = self.safe_bool_2(params, 'stop', 'trigger')
4443
4455
  params = self.omit(params, ['stop', 'trigger'])
4444
- type, query = self.handle_market_type_and_params('fetchOrdersByStatus', market, params)
4456
+ type: Str = None
4457
+ type, params = self.handle_market_type_and_params('fetchOrdersByStatus', market, params)
4445
4458
  spot = (type == 'spot') or (type == 'margin')
4446
- request, requestParams = self.multi_order_spot_prepare_request(market, stop, query) if spot else self.prepare_request(market, type, query)
4459
+ request: dict = {}
4460
+ request, params = self.multi_order_spot_prepare_request(market, stop, params) if spot else self.prepare_request(market, type, params)
4447
4461
  if status == 'closed':
4448
4462
  status = 'finished'
4449
4463
  request['status'] = status
4450
4464
  if limit is not None:
4451
4465
  request['limit'] = limit
4452
- if since is not None and spot:
4453
- request['from'] = self.parse_to_int(since / 1000)
4454
- lastId, finalParams = self.handle_param_string_2(requestParams, 'lastId', 'last_id')
4466
+ if spot:
4467
+ if since is not None:
4468
+ request['from'] = self.parse_to_int(since / 1000)
4469
+ until = self.safe_integer(params, 'until')
4470
+ if until is not None:
4471
+ params = self.omit(params, 'until')
4472
+ request['to'] = self.parse_to_int(until / 1000)
4473
+ lastId, finalParams = self.handle_param_string_2(params, 'lastId', 'last_id')
4455
4474
  if lastId is not None:
4456
4475
  request['last_id'] = lastId
4457
4476
  return [request, finalParams]
@@ -4467,7 +4486,7 @@ class gate(Exchange, ImplicitAPI):
4467
4486
  res = self.handle_market_type_and_params('fetchOrdersByStatus', market, params)
4468
4487
  type = self.safe_string(res, 0)
4469
4488
  params['type'] = type
4470
- request, requestParams = self.fetch_orders_by_status_request(status, symbol, since, limit, params)
4489
+ request, requestParams = self.prepare_orders_by_status_request(status, symbol, since, limit, params)
4471
4490
  spot = (type == 'spot') or (type == 'margin')
4472
4491
  openSpotOrders = spot and (status == 'open') and not stop
4473
4492
  response = None
@@ -6,7 +6,7 @@
6
6
  from ccxt.async_support.base.exchange import Exchange
7
7
  from ccxt.abstract.hashkey import ImplicitAPI
8
8
  import hashlib
9
- from ccxt.base.types import Account, Balances, Bool, Currencies, Currency, Int, LastPrice, LastPrices, LedgerEntry, Leverage, LeverageTier, LeverageTiers, Market, Num, Order, OrderBook, OrderRequest, OrderSide, OrderType, Position, Str, Strings, Ticker, Tickers, Trade, TradingFeeInterface, TradingFees, Transaction, TransferEntry
9
+ from ccxt.base.types import Account, Balances, Bool, Currencies, Currency, Int, LastPrice, LastPrices, LedgerEntry, Leverage, LeverageTier, LeverageTiers, Market, Num, Order, OrderBook, OrderRequest, OrderSide, OrderType, Position, Str, Strings, Ticker, Tickers, FundingRate, FundingRates, Trade, TradingFeeInterface, 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
@@ -3491,7 +3491,7 @@ class hashkey(Exchange, ImplicitAPI):
3491
3491
  }
3492
3492
  return self.safe_string(types, type, type)
3493
3493
 
3494
- async def fetch_funding_rate(self, symbol: str, params={}):
3494
+ async def fetch_funding_rate(self, symbol: str, params={}) -> FundingRate:
3495
3495
  """
3496
3496
  fetch the current funding rate
3497
3497
  :see: https://hashkeyglobal-apidoc.readme.io/reference/get-futures-funding-rate
@@ -3514,13 +3514,13 @@ class hashkey(Exchange, ImplicitAPI):
3514
3514
  rate = self.safe_dict(response, 0, {})
3515
3515
  return self.parse_funding_rate(rate, market)
3516
3516
 
3517
- async def fetch_funding_rates(self, symbols: Strings = None, params={}):
3517
+ async def fetch_funding_rates(self, symbols: Strings = None, params={}) -> FundingRates:
3518
3518
  """
3519
3519
  fetch the funding rate for multiple markets
3520
3520
  :see: https://hashkeyglobal-apidoc.readme.io/reference/get-futures-funding-rate
3521
3521
  :param str[]|None symbols: list of unified market symbols
3522
3522
  :param dict [params]: extra parameters specific to the exchange API endpoint
3523
- :returns dict: a dictionary of `funding rates structures <https://docs.ccxt.com/#/?id=funding-rates-structure>`, indexe by market symbols
3523
+ :returns dict[]: a list of `funding rate structures <https://docs.ccxt.com/#/?id=funding-rates-structure>`, indexed by market symbols
3524
3524
  """
3525
3525
  await self.load_markets()
3526
3526
  symbols = self.market_symbols(symbols)
@@ -3537,9 +3537,8 @@ class hashkey(Exchange, ImplicitAPI):
3537
3537
  fundingRates = self.parse_funding_rates(response)
3538
3538
  return self.filter_by_array(fundingRates, 'symbol', symbols)
3539
3539
 
3540
- def parse_funding_rate(self, contract, market: Market = None):
3540
+ def parse_funding_rate(self, contract, market: Market = None) -> FundingRate:
3541
3541
  #
3542
- # fetchFundingRates
3543
3542
  # {
3544
3543
  # "symbol": "ETHUSDT-PERPETUAL",
3545
3544
  # "rate": "0.0001",
@@ -3568,6 +3567,7 @@ class hashkey(Exchange, ImplicitAPI):
3568
3567
  'previousFundingRate': None,
3569
3568
  'previousFundingTimestamp': None,
3570
3569
  'previousFundingDatetime': None,
3570
+ 'interval': None,
3571
3571
  }
3572
3572
 
3573
3573
  async def fetch_funding_rate_history(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
@@ -6,7 +6,7 @@
6
6
  from ccxt.async_support.base.exchange import Exchange
7
7
  from ccxt.abstract.hitbtc import ImplicitAPI
8
8
  import hashlib
9
- from ccxt.base.types import Balances, Currencies, Currency, Int, Leverage, MarginMode, MarginModes, MarginModification, Market, Num, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, TradingFeeInterface, TradingFees, Transaction, TransferEntry
9
+ from ccxt.base.types import Balances, Currencies, Currency, Int, Leverage, MarginMode, MarginModes, MarginModification, Market, Num, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Tickers, FundingRate, FundingRates, Trade, TradingFeeInterface, 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
@@ -2536,13 +2536,13 @@ class hitbtc(Exchange, ImplicitAPI):
2536
2536
  #
2537
2537
  return self.parse_transaction(response, currency)
2538
2538
 
2539
- async def fetch_funding_rates(self, symbols: Strings = None, params={}):
2539
+ async def fetch_funding_rates(self, symbols: Strings = None, params={}) -> FundingRates:
2540
2540
  """
2541
2541
  fetches funding rates for multiple markets
2542
2542
  :see: https://api.hitbtc.com/#futures-info
2543
2543
  :param str[] symbols: unified symbols of the markets to fetch the funding rates for, all market funding rates are returned if not assigned
2544
2544
  :param dict [params]: extra parameters specific to the exchange API endpoint
2545
- :returns dict: an array of `funding rate structures <https://docs.ccxt.com/#/?id=funding-rate-structure>`
2545
+ :returns dict[]: a list of `funding rate structures <https://docs.ccxt.com/#/?id=funding-rate-structure>`
2546
2546
  """
2547
2547
  await self.load_markets()
2548
2548
  market = None
@@ -2934,7 +2934,7 @@ class hitbtc(Exchange, ImplicitAPI):
2934
2934
  #
2935
2935
  return self.parse_open_interest(response, market)
2936
2936
 
2937
- async def fetch_funding_rate(self, symbol: str, params={}):
2937
+ async def fetch_funding_rate(self, symbol: str, params={}) -> FundingRate:
2938
2938
  """
2939
2939
  fetch the current funding rate
2940
2940
  :see: https://api.hitbtc.com/#futures-info
@@ -2967,7 +2967,7 @@ class hitbtc(Exchange, ImplicitAPI):
2967
2967
  #
2968
2968
  return self.parse_funding_rate(response, market)
2969
2969
 
2970
- def parse_funding_rate(self, contract, market: Market = None):
2970
+ def parse_funding_rate(self, contract, market: Market = None) -> FundingRate:
2971
2971
  #
2972
2972
  # {
2973
2973
  # "contract_type": "perpetual",
@@ -3003,6 +3003,7 @@ class hitbtc(Exchange, ImplicitAPI):
3003
3003
  'previousFundingRate': None,
3004
3004
  'previousFundingTimestamp': None,
3005
3005
  'previousFundingDatetime': None,
3006
+ 'interval': None,
3006
3007
  }
3007
3008
 
3008
3009
  async def modify_margin_helper(self, symbol: str, amount, type, params={}) -> MarginModification:
ccxt/async_support/htx.py CHANGED
@@ -7,7 +7,7 @@ from ccxt.async_support.base.exchange import Exchange
7
7
  from ccxt.abstract.htx import ImplicitAPI
8
8
  import asyncio
9
9
  import hashlib
10
- from ccxt.base.types import Account, Balances, Currencies, Currency, Int, IsolatedBorrowRate, IsolatedBorrowRates, LedgerEntry, LeverageTier, LeverageTiers, Market, Num, Order, OrderBook, OrderRequest, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, TradingFeeInterface, Transaction, TransferEntry
10
+ from ccxt.base.types import Account, Balances, Currencies, Currency, Int, IsolatedBorrowRate, IsolatedBorrowRates, LedgerEntry, LeverageTier, LeverageTiers, Market, Num, Order, OrderBook, OrderRequest, OrderSide, OrderType, Str, Strings, Ticker, Tickers, FundingRate, FundingRates, Trade, TradingFeeInterface, Transaction, TransferEntry
11
11
  from typing import List
12
12
  from ccxt.base.errors import ExchangeError
13
13
  from ccxt.base.errors import AuthenticationError
@@ -203,7 +203,7 @@ class htx(Exchange, ImplicitAPI):
203
203
  },
204
204
  'www': 'https://www.huobi.com',
205
205
  'referral': {
206
- 'url': 'https://www.huobi.com/en-us/v/register/double-invite/?inviter_id=11343840&invite_code=6rmm2223',
206
+ 'url': 'https://www.htx.com.vc/invite/en-us/1h?invite_code=6rmm2223',
207
207
  'discount': 0.15,
208
208
  },
209
209
  'doc': [
@@ -6383,7 +6383,7 @@ class htx(Exchange, ImplicitAPI):
6383
6383
  sorted = self.sort_by(rates, 'timestamp')
6384
6384
  return self.filter_by_symbol_since_limit(sorted, market['symbol'], since, limit)
6385
6385
 
6386
- def parse_funding_rate(self, contract, market: Market = None):
6386
+ def parse_funding_rate(self, contract, market: Market = None) -> FundingRate:
6387
6387
  #
6388
6388
  # {
6389
6389
  # "status": "ok",
@@ -6402,6 +6402,9 @@ class htx(Exchange, ImplicitAPI):
6402
6402
  nextFundingRate = self.safe_number(contract, 'estimated_rate')
6403
6403
  fundingTimestamp = self.safe_integer(contract, 'funding_time')
6404
6404
  nextFundingTimestamp = self.safe_integer(contract, 'next_funding_time')
6405
+ fundingTimeString = self.safe_string(contract, 'funding_time')
6406
+ nextFundingTimeString = self.safe_string(contract, 'next_funding_time')
6407
+ millisecondsInterval = Precise.string_sub(nextFundingTimeString, fundingTimeString)
6405
6408
  marketId = self.safe_string(contract, 'contract_code')
6406
6409
  symbol = self.safe_symbol(marketId, market)
6407
6410
  return {
@@ -6422,9 +6425,20 @@ class htx(Exchange, ImplicitAPI):
6422
6425
  'previousFundingRate': None,
6423
6426
  'previousFundingTimestamp': None,
6424
6427
  'previousFundingDatetime': None,
6428
+ 'interval': self.parse_funding_interval(millisecondsInterval),
6425
6429
  }
6426
6430
 
6427
- async def fetch_funding_rate(self, symbol: str, params={}):
6431
+ def parse_funding_interval(self, interval):
6432
+ intervals: dict = {
6433
+ '3600000': '1h',
6434
+ '14400000': '4h',
6435
+ '28800000': '8h',
6436
+ '57600000': '16h',
6437
+ '86400000': '24h',
6438
+ }
6439
+ return self.safe_string(intervals, interval, interval)
6440
+
6441
+ async def fetch_funding_rate(self, symbol: str, params={}) -> FundingRate:
6428
6442
  """
6429
6443
  fetch the current funding rate
6430
6444
  :param str symbol: unified market symbol
@@ -6461,12 +6475,12 @@ class htx(Exchange, ImplicitAPI):
6461
6475
  result = self.safe_value(response, 'data', {})
6462
6476
  return self.parse_funding_rate(result, market)
6463
6477
 
6464
- async def fetch_funding_rates(self, symbols: Strings = None, params={}):
6478
+ async def fetch_funding_rates(self, symbols: Strings = None, params={}) -> FundingRates:
6465
6479
  """
6466
6480
  fetch the funding rate for multiple markets
6467
6481
  :param str[]|None symbols: list of unified market symbols
6468
6482
  :param dict [params]: extra parameters specific to the exchange API endpoint
6469
- :returns dict: a dictionary of `funding rates structures <https://docs.ccxt.com/#/?id=funding-rates-structure>`, indexe by market symbols
6483
+ :returns dict[]: a list of `funding rate structures <https://docs.ccxt.com/#/?id=funding-rates-structure>`, indexed by market symbols
6470
6484
  """
6471
6485
  await self.load_markets()
6472
6486
  symbols = self.market_symbols(symbols)
@@ -8097,6 +8111,9 @@ class htx(Exchange, ImplicitAPI):
8097
8111
  async def fetch_settlement_history(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
8098
8112
  """
8099
8113
  Fetches historical settlement records
8114
+ :see: https://huobiapi.github.io/docs/dm/v1/en/#query-historical-settlement-records-of-the-platform-interface
8115
+ :see: https://huobiapi.github.io/docs/coin_margined_swap/v1/en/#query-historical-settlement-records-of-the-platform-interface
8116
+ :see: https://huobiapi.github.io/docs/usdt_swap/v1/en/#general-query-historical-settlement-records-of-the-platform-interface
8100
8117
  :param str symbol: unified symbol of the market to fetch the settlement history for
8101
8118
  :param int [since]: timestamp in ms, value range = current time - 90 days,default = current time - 90 days
8102
8119
  :param int [limit]: page items, default 20, shall not exceed 50