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/bybit.py CHANGED
@@ -6,7 +6,7 @@
6
6
  from ccxt.base.exchange import Exchange
7
7
  from ccxt.abstract.bybit import ImplicitAPI
8
8
  import hashlib
9
- 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
9
+ 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
10
10
  from typing import List
11
11
  from ccxt.base.errors import ExchangeError
12
12
  from ccxt.base.errors import AuthenticationError
@@ -95,7 +95,7 @@ class bybit(Exchange, ImplicitAPI):
95
95
  'fetchDepositWithdrawFee': 'emulated',
96
96
  'fetchDepositWithdrawFees': True,
97
97
  'fetchFundingHistory': True,
98
- 'fetchFundingRate': True, # emulated in exchange
98
+ 'fetchFundingRate': 'emulated', # emulated in exchange
99
99
  'fetchFundingRateHistory': True,
100
100
  'fetchFundingRates': True,
101
101
  'fetchGreeks': True,
@@ -2344,7 +2344,8 @@ class bybit(Exchange, ImplicitAPI):
2344
2344
  ohlcvs = self.safe_list(result, 'list', [])
2345
2345
  return self.parse_ohlcvs(ohlcvs, market, timeframe, since, limit)
2346
2346
 
2347
- def parse_funding_rate(self, ticker, market: Market = None):
2347
+ def parse_funding_rate(self, ticker, market: Market = None) -> FundingRate:
2348
+ #
2348
2349
  # {
2349
2350
  # "symbol": "BTCUSDT",
2350
2351
  # "bidPrice": "19255",
@@ -2395,15 +2396,16 @@ class bybit(Exchange, ImplicitAPI):
2395
2396
  'previousFundingRate': None,
2396
2397
  'previousFundingTimestamp': None,
2397
2398
  'previousFundingDatetime': None,
2399
+ 'interval': None,
2398
2400
  }
2399
2401
 
2400
- def fetch_funding_rates(self, symbols: Strings = None, params={}):
2402
+ def fetch_funding_rates(self, symbols: Strings = None, params={}) -> FundingRates:
2401
2403
  """
2402
2404
  fetches funding rates for multiple markets
2403
2405
  :see: https://bybit-exchange.github.io/docs/v5/market/tickers
2404
2406
  :param str[] symbols: unified symbols of the markets to fetch the funding rates for, all market funding rates are returned if not assigned
2405
2407
  :param dict [params]: extra parameters specific to the exchange API endpoint
2406
- :returns dict: an array of `funding rate structures <https://docs.ccxt.com/#/?id=funding-rate-structure>`
2408
+ :returns dict[]: a list of `funding rate structures <https://docs.ccxt.com/#/?id=funding-rate-structure>`
2407
2409
  """
2408
2410
  self.load_markets()
2409
2411
  market = None
@@ -2459,17 +2461,10 @@ class bybit(Exchange, ImplicitAPI):
2459
2461
  # "time": 1663670053454
2460
2462
  # }
2461
2463
  #
2462
- tickerList = self.safe_value(response, 'result', [])
2463
- timestamp = self.safe_integer(response, 'time')
2464
- tickerList = self.safe_value(tickerList, 'list')
2465
- fundingRates: dict = {}
2466
- for i in range(0, len(tickerList)):
2467
- rawTicker = tickerList[i]
2468
- rawTicker['timestamp'] = timestamp # will be removed inside the parser
2469
- ticker = self.parse_funding_rate(tickerList[i], None)
2470
- symbol = ticker['symbol']
2471
- fundingRates[symbol] = ticker
2472
- return self.filter_by_array(fundingRates, 'symbol', symbols)
2464
+ data = self.safe_dict(response, 'result', {})
2465
+ tickerList = self.safe_list(data, 'list', [])
2466
+ result = self.parse_funding_rates(tickerList)
2467
+ return self.filter_by_array(result, 'symbol', symbols)
2473
2468
 
2474
2469
  def fetch_funding_rate_history(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
2475
2470
  """
@@ -3516,6 +3511,8 @@ class bybit(Exchange, ImplicitAPI):
3516
3511
  # Valid for option only.
3517
3512
  # 'orderIv': '0', # Implied volatility; parameters are passed according to the real value; for example, for 10%, 0.1 is passed
3518
3513
  }
3514
+ hedged = self.safe_bool(params, 'hedged', False)
3515
+ reduceOnly = self.safe_bool(params, 'reduceOnly')
3519
3516
  triggerPrice = self.safe_value_2(params, 'triggerPrice', 'stopPrice')
3520
3517
  stopLossTriggerPrice = self.safe_value(params, 'stopLossPrice')
3521
3518
  takeProfitTriggerPrice = self.safe_value(params, 'takeProfitPrice')
@@ -3665,7 +3662,12 @@ class bybit(Exchange, ImplicitAPI):
3665
3662
  request['tpslMode'] = 'Partial'
3666
3663
  request['tpOrderType'] = 'Limit'
3667
3664
  request['tpLimitPrice'] = self.get_price(symbol, tpLimitPrice)
3668
- params = self.omit(params, ['stopPrice', 'timeInForce', 'stopLossPrice', 'takeProfitPrice', 'postOnly', 'clientOrderId', 'triggerPrice', 'stopLoss', 'takeProfit', 'trailingAmount', 'trailingTriggerPrice'])
3665
+ if not market['spot'] and hedged:
3666
+ if reduceOnly:
3667
+ params = self.omit(params, 'reduceOnly')
3668
+ side = 'sell' if (side == 'buy') else 'buy'
3669
+ request['positionIdx'] = 1 if (side == 'buy') else 2
3670
+ params = self.omit(params, ['stopPrice', 'timeInForce', 'stopLossPrice', 'takeProfitPrice', 'postOnly', 'clientOrderId', 'triggerPrice', 'stopLoss', 'takeProfit', 'trailingAmount', 'trailingTriggerPrice', 'hedged'])
3669
3671
  return self.extend(request, params)
3670
3672
 
3671
3673
  def create_orders(self, orders: List[OrderRequest], params={}):
@@ -6341,6 +6343,8 @@ class bybit(Exchange, ImplicitAPI):
6341
6343
  initialMarginString = Precise.string_div(size, Precise.string_mul(entryPrice, leverage))
6342
6344
  maintenanceMarginPercentage = Precise.string_div(maintenanceMarginString, notional)
6343
6345
  marginRatio = Precise.string_div(maintenanceMarginString, collateralString, 4)
6346
+ positionIdx = self.safe_string(position, 'positionIdx')
6347
+ hedged = (positionIdx is not None) and (positionIdx != '0')
6344
6348
  return self.safe_position({
6345
6349
  'info': position,
6346
6350
  'id': None,
@@ -6369,6 +6373,7 @@ class bybit(Exchange, ImplicitAPI):
6369
6373
  'percentage': None,
6370
6374
  'stopLossPrice': self.safe_number_2(position, 'stop_loss', 'stopLoss'),
6371
6375
  'takeProfitPrice': self.safe_number_2(position, 'take_profit', 'takeProfit'),
6376
+ 'hedged': hedged,
6372
6377
  })
6373
6378
 
6374
6379
  def fetch_leverage(self, symbol: str, params={}) -> Leverage:
ccxt/coinex.py CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  from ccxt.base.exchange import Exchange
7
7
  from ccxt.abstract.coinex import ImplicitAPI
8
- 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
8
+ 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
9
9
  from typing import List
10
10
  from ccxt.base.errors import ExchangeError
11
11
  from ccxt.base.errors import AuthenticationError
@@ -4253,7 +4253,7 @@ class coinex(Exchange, ImplicitAPI):
4253
4253
  })
4254
4254
  return result
4255
4255
 
4256
- def fetch_funding_rate(self, symbol: str, params={}):
4256
+ def fetch_funding_rate(self, symbol: str, params={}) -> FundingRate:
4257
4257
  """
4258
4258
  fetch the current funding rate
4259
4259
  :see: https://docs.coinex.com/api/v2/futures/market/http/list-market-funding-rate
@@ -4291,7 +4291,7 @@ class coinex(Exchange, ImplicitAPI):
4291
4291
  first = self.safe_dict(data, 0, {})
4292
4292
  return self.parse_funding_rate(first, market)
4293
4293
 
4294
- def parse_funding_rate(self, contract, market: Market = None):
4294
+ def parse_funding_rate(self, contract, market: Market = None) -> FundingRate:
4295
4295
  #
4296
4296
  # fetchFundingRate, fetchFundingRates
4297
4297
  #
@@ -4308,6 +4308,9 @@ class coinex(Exchange, ImplicitAPI):
4308
4308
  #
4309
4309
  currentFundingTimestamp = self.safe_integer(contract, 'latest_funding_time')
4310
4310
  futureFundingTimestamp = self.safe_integer(contract, 'next_funding_time')
4311
+ fundingTimeString = self.safe_string(contract, 'latest_funding_time')
4312
+ nextFundingTimeString = self.safe_string(contract, 'next_funding_time')
4313
+ millisecondsInterval = Precise.string_sub(nextFundingTimeString, fundingTimeString)
4311
4314
  marketId = self.safe_string(contract, 'market')
4312
4315
  return {
4313
4316
  'info': contract,
@@ -4327,11 +4330,22 @@ class coinex(Exchange, ImplicitAPI):
4327
4330
  'previousFundingRate': None,
4328
4331
  'previousFundingTimestamp': None,
4329
4332
  'previousFundingDatetime': None,
4333
+ 'interval': self.parse_funding_interval(millisecondsInterval),
4330
4334
  }
4331
4335
 
4332
- def fetch_funding_rates(self, symbols: Strings = None, params={}):
4336
+ def parse_funding_interval(self, interval):
4337
+ intervals: dict = {
4338
+ '3600000': '1h',
4339
+ '14400000': '4h',
4340
+ '28800000': '8h',
4341
+ '57600000': '16h',
4342
+ '86400000': '24h',
4343
+ }
4344
+ return self.safe_string(intervals, interval, interval)
4345
+
4346
+ def fetch_funding_rates(self, symbols: Strings = None, params={}) -> FundingRates:
4333
4347
  """
4334
- fetch the current funding rates
4348
+ fetch the current funding rates for multiple markets
4335
4349
  :see: https://docs.coinex.com/api/v2/futures/market/http/list-market-funding-rate
4336
4350
  :param str[] symbols: unified market symbols
4337
4351
  :param dict [params]: extra parameters specific to the exchange API endpoint
ccxt/delta.py CHANGED
@@ -6,7 +6,7 @@
6
6
  from ccxt.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
- def fetch_funding_rate(self, symbol: str, params={}):
2291
+ 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
- def fetch_funding_rates(self, symbols: Strings = None, params={}):
2355
+ 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
  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
  def add_margin(self, symbol: str, amount: float, params={}) -> MarginModification:
ccxt/deribit.py CHANGED
@@ -6,7 +6,7 @@
6
6
  from ccxt.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
- def fetch_funding_rate(self, symbol: str, params={}):
2855
+ 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
  def fetch_liquidations(self, symbol: str, since: Int = None, limit: Int = None, params={}):
ccxt/digifinex.py CHANGED
@@ -7,7 +7,7 @@ from ccxt.base.exchange import Exchange
7
7
  from ccxt.abstract.digifinex import ImplicitAPI
8
8
  import hashlib
9
9
  import json
10
- 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
10
+ 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
11
11
  from typing import List
12
12
  from ccxt.base.errors import ExchangeError
13
13
  from ccxt.base.errors import AuthenticationError
@@ -2980,7 +2980,7 @@ class digifinex(Exchange, ImplicitAPI):
2980
2980
  result[code] = borrowRate
2981
2981
  return result
2982
2982
 
2983
- def fetch_funding_rate(self, symbol: str, params={}):
2983
+ def fetch_funding_rate(self, symbol: str, params={}) -> FundingRate:
2984
2984
  """
2985
2985
  fetch the current funding rate
2986
2986
  :see: https://docs.digifinex.com/en-ww/swap/v2/rest.html#currentfundingrate
@@ -3011,7 +3011,7 @@ class digifinex(Exchange, ImplicitAPI):
3011
3011
  data = self.safe_value(response, 'data', {})
3012
3012
  return self.parse_funding_rate(data, market)
3013
3013
 
3014
- def parse_funding_rate(self, contract, market: Market = None):
3014
+ def parse_funding_rate(self, contract, market: Market = None) -> FundingRate:
3015
3015
  #
3016
3016
  # {
3017
3017
  # "instrument_id": "BTCUSDTPERP",
@@ -3024,6 +3024,9 @@ class digifinex(Exchange, ImplicitAPI):
3024
3024
  marketId = self.safe_string(contract, 'instrument_id')
3025
3025
  timestamp = self.safe_integer(contract, 'funding_time')
3026
3026
  nextTimestamp = self.safe_integer(contract, 'next_funding_time')
3027
+ fundingTimeString = self.safe_string(contract, 'funding_time')
3028
+ nextFundingTimeString = self.safe_string(contract, 'next_funding_time')
3029
+ millisecondsInterval = Precise.string_sub(nextFundingTimeString, fundingTimeString)
3027
3030
  return {
3028
3031
  'info': contract,
3029
3032
  'symbol': self.safe_symbol(marketId, market),
@@ -3036,14 +3039,25 @@ class digifinex(Exchange, ImplicitAPI):
3036
3039
  'fundingRate': self.safe_number(contract, 'funding_rate'),
3037
3040
  'fundingTimestamp': timestamp,
3038
3041
  'fundingDatetime': self.iso8601(timestamp),
3039
- 'nextFundingRate': self.safe_string(contract, 'next_funding_rate'),
3042
+ 'nextFundingRate': self.safe_number(contract, 'next_funding_rate'),
3040
3043
  'nextFundingTimestamp': nextTimestamp,
3041
3044
  'nextFundingDatetime': self.iso8601(nextTimestamp),
3042
3045
  'previousFundingRate': None,
3043
3046
  'previousFundingTimestamp': None,
3044
3047
  'previousFundingDatetime': None,
3048
+ 'interval': self.parse_funding_interval(millisecondsInterval),
3045
3049
  }
3046
3050
 
3051
+ def parse_funding_interval(self, interval):
3052
+ intervals: dict = {
3053
+ '3600000': '1h',
3054
+ '14400000': '4h',
3055
+ '28800000': '8h',
3056
+ '57600000': '16h',
3057
+ '86400000': '24h',
3058
+ }
3059
+ return self.safe_string(intervals, interval, interval)
3060
+
3047
3061
  def fetch_funding_rate_history(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
3048
3062
  """
3049
3063
  fetches historical funding rate prices
ccxt/gate.py CHANGED
@@ -6,7 +6,7 @@
6
6
  from ccxt.base.exchange import Exchange
7
7
  from ccxt.abstract.gate import ImplicitAPI
8
8
  import hashlib
9
- 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
9
+ 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
10
10
  from typing import List
11
11
  from ccxt.base.errors import ExchangeError
12
12
  from ccxt.base.errors import AuthenticationError
@@ -611,6 +611,8 @@ class gate(Exchange, ImplicitAPI):
611
611
  },
612
612
  # copied from gatev2
613
613
  'commonCurrencies': {
614
+ 'ORT': 'XREATORS',
615
+ 'ASS': 'ASSF',
614
616
  '88MPH': 'MPH',
615
617
  'AXIS': 'AXISDEFI',
616
618
  'BIFI': 'BITCOINFILE',
@@ -645,6 +647,8 @@ class gate(Exchange, ImplicitAPI):
645
647
  },
646
648
  'createMarketBuyOrderRequiresPrice': True,
647
649
  'networks': {
650
+ 'LINEA': 'LINEAETH',
651
+ 'KON': 'KONET',
648
652
  'AVAXC': 'AVAX_C',
649
653
  'BEP20': 'BSC',
650
654
  'EOS': 'EOS',
@@ -1641,7 +1645,7 @@ class gate(Exchange, ImplicitAPI):
1641
1645
  result[code]['withdraw'] = withdrawAvailable
1642
1646
  return result
1643
1647
 
1644
- def fetch_funding_rate(self, symbol: str, params={}):
1648
+ def fetch_funding_rate(self, symbol: str, params={}) -> FundingRate:
1645
1649
  """
1646
1650
  fetch the current funding rate
1647
1651
  :see: https://www.gate.io/docs/developers/apiv4/en/#get-a-single-contract
@@ -1701,13 +1705,13 @@ class gate(Exchange, ImplicitAPI):
1701
1705
  #
1702
1706
  return self.parse_funding_rate(response)
1703
1707
 
1704
- def fetch_funding_rates(self, symbols: Strings = None, params={}):
1708
+ def fetch_funding_rates(self, symbols: Strings = None, params={}) -> FundingRates:
1705
1709
  """
1706
1710
  fetch the funding rate for multiple markets
1707
1711
  :see: https://www.gate.io/docs/developers/apiv4/en/#list-all-futures-contracts
1708
1712
  :param str[]|None symbols: list of unified market symbols
1709
1713
  :param dict [params]: extra parameters specific to the exchange API endpoint
1710
- :returns dict: a dictionary of `funding rates structures <https://docs.ccxt.com/#/?id=funding-rates-structure>`, indexe by market symbols
1714
+ :returns dict[]: a list of `funding rate structures <https://docs.ccxt.com/#/?id=funding-rates-structure>`, indexed by market symbols
1711
1715
  """
1712
1716
  self.load_markets()
1713
1717
  symbols = self.market_symbols(symbols)
@@ -1760,7 +1764,7 @@ class gate(Exchange, ImplicitAPI):
1760
1764
  result = self.parse_funding_rates(response)
1761
1765
  return self.filter_by_array(result, 'symbol', symbols)
1762
1766
 
1763
- def parse_funding_rate(self, contract, market: Market = None):
1767
+ def parse_funding_rate(self, contract, market: Market = None) -> FundingRate:
1764
1768
  #
1765
1769
  # {
1766
1770
  # "name": "BTC_USDT",
@@ -1811,6 +1815,7 @@ class gate(Exchange, ImplicitAPI):
1811
1815
  fundingRate = self.safe_number(contract, 'funding_rate')
1812
1816
  fundingTime = self.safe_timestamp(contract, 'funding_next_apply')
1813
1817
  fundingRateIndicative = self.safe_number(contract, 'funding_rate_indicative')
1818
+ fundingInterval = Precise.string_mul('1000', self.safe_string(contract, 'funding_interval'))
1814
1819
  return {
1815
1820
  'info': contract,
1816
1821
  'symbol': symbol,
@@ -1829,8 +1834,19 @@ class gate(Exchange, ImplicitAPI):
1829
1834
  'previousFundingRate': None,
1830
1835
  'previousFundingTimestamp': None,
1831
1836
  'previousFundingDatetime': None,
1837
+ 'interval': self.parse_funding_interval(fundingInterval),
1832
1838
  }
1833
1839
 
1840
+ def parse_funding_interval(self, interval):
1841
+ intervals: dict = {
1842
+ '3600000': '1h',
1843
+ '14400000': '4h',
1844
+ '28800000': '8h',
1845
+ '57600000': '16h',
1846
+ '86400000': '24h',
1847
+ }
1848
+ return self.safe_string(intervals, interval, interval)
1849
+
1834
1850
  def fetch_network_deposit_address(self, code: str, params={}):
1835
1851
  self.load_markets()
1836
1852
  currency = self.currency(code)
@@ -4393,6 +4409,7 @@ class gate(Exchange, ImplicitAPI):
4393
4409
  :see: https://www.gate.io/docs/developers/apiv4/en/#list-futures-orders-2
4394
4410
  :see: https://www.gate.io/docs/developers/apiv4/en/#list-all-auto-orders-2
4395
4411
  :see: https://www.gate.io/docs/developers/apiv4/en/#list-options-orders
4412
+ :see: https://www.gate.io/docs/developers/apiv4/en/#list-futures-orders-by-time-range
4396
4413
  :param str symbol: unified market symbol of the market orders were made in
4397
4414
  :param int [since]: the earliest time in ms to fetch orders for
4398
4415
  :param int [limit]: the maximum number of order structures to retrieve
@@ -4400,28 +4417,59 @@ class gate(Exchange, ImplicitAPI):
4400
4417
  :param bool [params.stop]: True for fetching stop orders
4401
4418
  :param str [params.type]: spot, swap or future, if not provided self.options['defaultType'] is used
4402
4419
  :param str [params.marginMode]: 'cross' or 'isolated' - marginMode for margin trading if not provided self.options['defaultMarginMode'] is used
4420
+ :param boolean [params.historical]: *swap only* True for using historical endpoint
4403
4421
  :returns Order[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
4404
4422
  """
4405
- return self.fetch_orders_by_status('finished', symbol, since, limit, params)
4423
+ self.load_markets()
4424
+ until = self.safe_integer(params, 'until')
4425
+ market = None
4426
+ if symbol is not None:
4427
+ market = self.market(symbol)
4428
+ symbol = market['symbol']
4429
+ res = self.handle_market_type_and_params('fetchClosedOrders', market, params)
4430
+ type = self.safe_string(res, 0)
4431
+ useHistorical = False
4432
+ useHistorical, params = self.handle_option_and_params(params, 'fetchClosedOrders', 'historical', False)
4433
+ if not useHistorical and ((since is None and until is None) or (type != 'swap')):
4434
+ return self.fetch_orders_by_status('finished', symbol, since, limit, params)
4435
+ params = self.omit(params, 'type')
4436
+ request = {}
4437
+ request, params = self.prepare_request(market, type, params)
4438
+ if since is not None:
4439
+ request['from'] = self.parse_to_int(since / 1000)
4440
+ if until is not None:
4441
+ params = self.omit(params, 'until')
4442
+ request['to'] = self.parse_to_int(until / 1000)
4443
+ if limit is not None:
4444
+ request['limit'] = limit
4445
+ response = self.privateFuturesGetSettleOrdersTimerange(self.extend(request, params))
4446
+ return self.parse_orders(response, market, since, limit)
4406
4447
 
4407
- def fetch_orders_by_status_request(self, status, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
4448
+ def prepare_orders_by_status_request(self, status, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
4408
4449
  market = None
4409
4450
  if symbol is not None:
4410
4451
  market = self.market(symbol)
4411
4452
  symbol = market['symbol']
4412
4453
  stop = self.safe_bool_2(params, 'stop', 'trigger')
4413
4454
  params = self.omit(params, ['stop', 'trigger'])
4414
- type, query = self.handle_market_type_and_params('fetchOrdersByStatus', market, params)
4455
+ type: Str = None
4456
+ type, params = self.handle_market_type_and_params('fetchOrdersByStatus', market, params)
4415
4457
  spot = (type == 'spot') or (type == 'margin')
4416
- request, requestParams = self.multi_order_spot_prepare_request(market, stop, query) if spot else self.prepare_request(market, type, query)
4458
+ request: dict = {}
4459
+ request, params = self.multi_order_spot_prepare_request(market, stop, params) if spot else self.prepare_request(market, type, params)
4417
4460
  if status == 'closed':
4418
4461
  status = 'finished'
4419
4462
  request['status'] = status
4420
4463
  if limit is not None:
4421
4464
  request['limit'] = limit
4422
- if since is not None and spot:
4423
- request['from'] = self.parse_to_int(since / 1000)
4424
- lastId, finalParams = self.handle_param_string_2(requestParams, 'lastId', 'last_id')
4465
+ if spot:
4466
+ if since is not None:
4467
+ request['from'] = self.parse_to_int(since / 1000)
4468
+ until = self.safe_integer(params, 'until')
4469
+ if until is not None:
4470
+ params = self.omit(params, 'until')
4471
+ request['to'] = self.parse_to_int(until / 1000)
4472
+ lastId, finalParams = self.handle_param_string_2(params, 'lastId', 'last_id')
4425
4473
  if lastId is not None:
4426
4474
  request['last_id'] = lastId
4427
4475
  return [request, finalParams]
@@ -4437,7 +4485,7 @@ class gate(Exchange, ImplicitAPI):
4437
4485
  res = self.handle_market_type_and_params('fetchOrdersByStatus', market, params)
4438
4486
  type = self.safe_string(res, 0)
4439
4487
  params['type'] = type
4440
- request, requestParams = self.fetch_orders_by_status_request(status, symbol, since, limit, params)
4488
+ request, requestParams = self.prepare_orders_by_status_request(status, symbol, since, limit, params)
4441
4489
  spot = (type == 'spot') or (type == 'margin')
4442
4490
  openSpotOrders = spot and (status == 'open') and not stop
4443
4491
  response = None
ccxt/hashkey.py CHANGED
@@ -6,7 +6,7 @@
6
6
  from ccxt.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
- def fetch_funding_rate(self, symbol: str, params={}):
3494
+ 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
- def fetch_funding_rates(self, symbols: Strings = None, params={}):
3517
+ 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
  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
  def fetch_funding_rate_history(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
ccxt/hitbtc.py CHANGED
@@ -6,7 +6,7 @@
6
6
  from ccxt.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
- def fetch_funding_rates(self, symbols: Strings = None, params={}):
2539
+ 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
  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
- def fetch_funding_rate(self, symbol: str, params={}):
2937
+ 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
  def modify_margin_helper(self, symbol: str, amount, type, params={}) -> MarginModification: