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
@@ -6,7 +6,7 @@
6
6
  from ccxt.async_support.base.exchange import Exchange
7
7
  from ccxt.abstract.bitmex import ImplicitAPI
8
8
  import hashlib
9
- from ccxt.base.types import Balances, Currencies, Currency, Int, LedgerEntry, Leverage, Leverages, Market, MarketType, Num, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, Transaction
9
+ from ccxt.base.types import Balances, Currencies, Currency, Int, LedgerEntry, Leverage, Leverages, Market, MarketType, Num, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Tickers, FundingRate, FundingRates, Trade, Transaction
10
10
  from typing import List
11
11
  from ccxt.base.errors import ExchangeError
12
12
  from ccxt.base.errors import AuthenticationError
@@ -67,7 +67,7 @@ class bitmex(Exchange, ImplicitAPI):
67
67
  'fetchDepositWithdrawFee': 'emulated',
68
68
  'fetchDepositWithdrawFees': True,
69
69
  'fetchFundingHistory': False,
70
- 'fetchFundingRate': False,
70
+ 'fetchFundingRate': 'emulated', # emulated in exchange
71
71
  'fetchFundingRateHistory': True,
72
72
  'fetchFundingRates': True,
73
73
  'fetchIndexOHLCV': False,
@@ -2331,13 +2331,13 @@ class bitmex(Exchange, ImplicitAPI):
2331
2331
  #
2332
2332
  return self.parse_transaction(response, currency)
2333
2333
 
2334
- async def fetch_funding_rates(self, symbols: Strings = None, params={}):
2334
+ async def fetch_funding_rates(self, symbols: Strings = None, params={}) -> FundingRates:
2335
2335
  """
2336
2336
  fetch the funding rate for multiple markets
2337
2337
  :see: https://www.bitmex.com/api/explorer/#not /Instrument/Instrument_getActiveAndIndices
2338
2338
  :param str[]|None symbols: list of unified market symbols
2339
2339
  :param dict [params]: extra parameters specific to the exchange API endpoint
2340
- :returns dict: a dictionary of `funding rates structures <https://docs.ccxt.com/#/?id=funding-rates-structure>`, indexe by market symbols
2340
+ :returns dict[]: a list of `funding rate structures <https://docs.ccxt.com/#/?id=funding-rates-structure>`, indexed by market symbols
2341
2341
  """
2342
2342
  await self.load_markets()
2343
2343
  response = await self.publicGetInstrumentActiveAndIndices(params)
@@ -2354,7 +2354,7 @@ class bitmex(Exchange, ImplicitAPI):
2354
2354
  result = self.parse_funding_rates(filteredResponse)
2355
2355
  return self.filter_by_array(result, 'symbol', symbols)
2356
2356
 
2357
- def parse_funding_rate(self, contract, market: Market = None):
2357
+ def parse_funding_rate(self, contract, market: Market = None) -> FundingRate:
2358
2358
  # see response sample under "fetchMarkets" because same endpoint is being used here
2359
2359
  datetime = self.safe_string(contract, 'timestamp')
2360
2360
  marketId = self.safe_string(contract, 'symbol')
@@ -2369,7 +2369,7 @@ class bitmex(Exchange, ImplicitAPI):
2369
2369
  'timestamp': self.parse8601(datetime),
2370
2370
  'datetime': datetime,
2371
2371
  'fundingRate': self.safe_number(contract, 'fundingRate'),
2372
- 'fundingTimestamp': self.iso8601(fundingDatetime),
2372
+ 'fundingTimestamp': self.parse_to_numeric(self.iso8601(fundingDatetime)),
2373
2373
  'fundingDatetime': fundingDatetime,
2374
2374
  'nextFundingRate': self.safe_number(contract, 'indicativeFundingRate'),
2375
2375
  'nextFundingTimestamp': None,
@@ -2377,6 +2377,7 @@ class bitmex(Exchange, ImplicitAPI):
2377
2377
  'previousFundingRate': None,
2378
2378
  'previousFundingTimestamp': None,
2379
2379
  'previousFundingDatetime': None,
2380
+ 'interval': None,
2380
2381
  }
2381
2382
 
2382
2383
  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.blofin import ImplicitAPI
8
8
  import hashlib
9
- from ccxt.base.types import Balances, Currency, Int, LedgerEntry, Leverage, Leverages, MarginMode, Market, Num, Order, OrderBook, OrderRequest, OrderSide, OrderType, Position, Str, Strings, Ticker, Tickers, Trade, TradingFeeInterface, Transaction, TransferEntry
9
+ from ccxt.base.types import Balances, Currency, Int, LedgerEntry, Leverage, Leverages, MarginMode, Market, Num, Order, OrderBook, OrderRequest, OrderSide, OrderType, Position, Str, Strings, Ticker, Tickers, FundingRate, Trade, TradingFeeInterface, Transaction, TransferEntry
10
10
  from typing import List
11
11
  from ccxt.base.errors import ExchangeError
12
12
  from ccxt.base.errors import AuthenticationError
@@ -768,23 +768,16 @@ class blofin(Exchange, ImplicitAPI):
768
768
  sorted = self.sort_by(rates, 'timestamp')
769
769
  return self.filter_by_symbol_since_limit(sorted, market['symbol'], since, limit)
770
770
 
771
- def parse_funding_rate(self, contract, market: Market = None):
771
+ def parse_funding_rate(self, contract, market: Market = None) -> FundingRate:
772
772
  #
773
773
  # {
774
774
  # "fundingRate": "0.00027815",
775
775
  # "fundingTime": "1634256000000",
776
776
  # "instId": "BTC-USD-SWAP",
777
- # "instType": "SWAP",
778
- # "nextFundingRate": "0.00017",
779
- # "nextFundingTime": "1634284800000"
780
777
  # }
781
778
  #
782
- # in the response above nextFundingRate is actually two funding rates from now
783
- #
784
- nextFundingRateTimestamp = self.safe_integer(contract, 'nextFundingTime')
785
779
  marketId = self.safe_string(contract, 'instId')
786
780
  symbol = self.safe_symbol(marketId, market)
787
- nextFundingRate = self.safe_number(contract, 'nextFundingRate')
788
781
  fundingTime = self.safe_integer(contract, 'fundingTime')
789
782
  # > The current interest is 0.
790
783
  return {
@@ -799,15 +792,16 @@ class blofin(Exchange, ImplicitAPI):
799
792
  'fundingRate': self.safe_number(contract, 'fundingRate'),
800
793
  'fundingTimestamp': fundingTime,
801
794
  'fundingDatetime': self.iso8601(fundingTime),
802
- 'nextFundingRate': nextFundingRate,
803
- 'nextFundingTimestamp': nextFundingRateTimestamp,
804
- 'nextFundingDatetime': self.iso8601(nextFundingRateTimestamp),
795
+ 'nextFundingRate': None,
796
+ 'nextFundingTimestamp': None,
797
+ 'nextFundingDatetime': None,
805
798
  'previousFundingRate': None,
806
799
  'previousFundingTimestamp': None,
807
800
  'previousFundingDatetime': None,
801
+ 'interval': None,
808
802
  }
809
803
 
810
- async def fetch_funding_rate(self, symbol: str, params={}):
804
+ async def fetch_funding_rate(self, symbol: str, params={}) -> FundingRate:
811
805
  """
812
806
  fetch the current funding rate
813
807
  :see: https://blofin.com/docs#get-funding-rate
@@ -831,9 +825,6 @@ class blofin(Exchange, ImplicitAPI):
831
825
  # "fundingRate": "0.00027815",
832
826
  # "fundingTime": "1634256000000",
833
827
  # "instId": "BTC-USD-SWAP",
834
- # "instType": "SWAP",
835
- # "nextFundingRate": "0.00017",
836
- # "nextFundingTime": "1634284800000"
837
828
  # }
838
829
  # ],
839
830
  # "msg": ""
@@ -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
  """
@@ -3517,6 +3512,8 @@ class bybit(Exchange, ImplicitAPI):
3517
3512
  # Valid for option only.
3518
3513
  # 'orderIv': '0', # Implied volatility; parameters are passed according to the real value; for example, for 10%, 0.1 is passed
3519
3514
  }
3515
+ hedged = self.safe_bool(params, 'hedged', False)
3516
+ reduceOnly = self.safe_bool(params, 'reduceOnly')
3520
3517
  triggerPrice = self.safe_value_2(params, 'triggerPrice', 'stopPrice')
3521
3518
  stopLossTriggerPrice = self.safe_value(params, 'stopLossPrice')
3522
3519
  takeProfitTriggerPrice = self.safe_value(params, 'takeProfitPrice')
@@ -3666,7 +3663,12 @@ class bybit(Exchange, ImplicitAPI):
3666
3663
  request['tpslMode'] = 'Partial'
3667
3664
  request['tpOrderType'] = 'Limit'
3668
3665
  request['tpLimitPrice'] = self.get_price(symbol, tpLimitPrice)
3669
- params = self.omit(params, ['stopPrice', 'timeInForce', 'stopLossPrice', 'takeProfitPrice', 'postOnly', 'clientOrderId', 'triggerPrice', 'stopLoss', 'takeProfit', 'trailingAmount', 'trailingTriggerPrice'])
3666
+ if not market['spot'] and hedged:
3667
+ if reduceOnly:
3668
+ params = self.omit(params, 'reduceOnly')
3669
+ side = 'sell' if (side == 'buy') else 'buy'
3670
+ request['positionIdx'] = 1 if (side == 'buy') else 2
3671
+ params = self.omit(params, ['stopPrice', 'timeInForce', 'stopLossPrice', 'takeProfitPrice', 'postOnly', 'clientOrderId', 'triggerPrice', 'stopLoss', 'takeProfit', 'trailingAmount', 'trailingTriggerPrice', 'hedged'])
3670
3672
  return self.extend(request, params)
3671
3673
 
3672
3674
  async def create_orders(self, orders: List[OrderRequest], params={}):
@@ -6342,6 +6344,8 @@ class bybit(Exchange, ImplicitAPI):
6342
6344
  initialMarginString = Precise.string_div(size, Precise.string_mul(entryPrice, leverage))
6343
6345
  maintenanceMarginPercentage = Precise.string_div(maintenanceMarginString, notional)
6344
6346
  marginRatio = Precise.string_div(maintenanceMarginString, collateralString, 4)
6347
+ positionIdx = self.safe_string(position, 'positionIdx')
6348
+ hedged = (positionIdx is not None) and (positionIdx != '0')
6345
6349
  return self.safe_position({
6346
6350
  'info': position,
6347
6351
  'id': None,
@@ -6370,6 +6374,7 @@ class bybit(Exchange, ImplicitAPI):
6370
6374
  'percentage': None,
6371
6375
  'stopLossPrice': self.safe_number_2(position, 'stop_loss', 'stopLoss'),
6372
6376
  'takeProfitPrice': self.safe_number_2(position, 'take_profit', 'takeProfit'),
6377
+ 'hedged': hedged,
6373
6378
  })
6374
6379
 
6375
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
@@ -612,6 +612,8 @@ class gate(Exchange, ImplicitAPI):
612
612
  },
613
613
  # copied from gatev2
614
614
  'commonCurrencies': {
615
+ 'ORT': 'XREATORS',
616
+ 'ASS': 'ASSF',
615
617
  '88MPH': 'MPH',
616
618
  'AXIS': 'AXISDEFI',
617
619
  'BIFI': 'BITCOINFILE',
@@ -646,6 +648,8 @@ class gate(Exchange, ImplicitAPI):
646
648
  },
647
649
  'createMarketBuyOrderRequiresPrice': True,
648
650
  'networks': {
651
+ 'LINEA': 'LINEAETH',
652
+ 'KON': 'KONET',
649
653
  'AVAXC': 'AVAX_C',
650
654
  'BEP20': 'BSC',
651
655
  'EOS': 'EOS',
@@ -1642,7 +1646,7 @@ class gate(Exchange, ImplicitAPI):
1642
1646
  result[code]['withdraw'] = withdrawAvailable
1643
1647
  return result
1644
1648
 
1645
- async def fetch_funding_rate(self, symbol: str, params={}):
1649
+ async def fetch_funding_rate(self, symbol: str, params={}) -> FundingRate:
1646
1650
  """
1647
1651
  fetch the current funding rate
1648
1652
  :see: https://www.gate.io/docs/developers/apiv4/en/#get-a-single-contract
@@ -1702,13 +1706,13 @@ class gate(Exchange, ImplicitAPI):
1702
1706
  #
1703
1707
  return self.parse_funding_rate(response)
1704
1708
 
1705
- async def fetch_funding_rates(self, symbols: Strings = None, params={}):
1709
+ async def fetch_funding_rates(self, symbols: Strings = None, params={}) -> FundingRates:
1706
1710
  """
1707
1711
  fetch the funding rate for multiple markets
1708
1712
  :see: https://www.gate.io/docs/developers/apiv4/en/#list-all-futures-contracts
1709
1713
  :param str[]|None symbols: list of unified market symbols
1710
1714
  :param dict [params]: extra parameters specific to the exchange API endpoint
1711
- :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
1712
1716
  """
1713
1717
  await self.load_markets()
1714
1718
  symbols = self.market_symbols(symbols)
@@ -1761,7 +1765,7 @@ class gate(Exchange, ImplicitAPI):
1761
1765
  result = self.parse_funding_rates(response)
1762
1766
  return self.filter_by_array(result, 'symbol', symbols)
1763
1767
 
1764
- def parse_funding_rate(self, contract, market: Market = None):
1768
+ def parse_funding_rate(self, contract, market: Market = None) -> FundingRate:
1765
1769
  #
1766
1770
  # {
1767
1771
  # "name": "BTC_USDT",
@@ -1812,6 +1816,7 @@ class gate(Exchange, ImplicitAPI):
1812
1816
  fundingRate = self.safe_number(contract, 'funding_rate')
1813
1817
  fundingTime = self.safe_timestamp(contract, 'funding_next_apply')
1814
1818
  fundingRateIndicative = self.safe_number(contract, 'funding_rate_indicative')
1819
+ fundingInterval = Precise.string_mul('1000', self.safe_string(contract, 'funding_interval'))
1815
1820
  return {
1816
1821
  'info': contract,
1817
1822
  'symbol': symbol,
@@ -1830,8 +1835,19 @@ class gate(Exchange, ImplicitAPI):
1830
1835
  'previousFundingRate': None,
1831
1836
  'previousFundingTimestamp': None,
1832
1837
  'previousFundingDatetime': None,
1838
+ 'interval': self.parse_funding_interval(fundingInterval),
1833
1839
  }
1834
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
+
1835
1851
  async def fetch_network_deposit_address(self, code: str, params={}):
1836
1852
  await self.load_markets()
1837
1853
  currency = self.currency(code)
@@ -4394,6 +4410,7 @@ class gate(Exchange, ImplicitAPI):
4394
4410
  :see: https://www.gate.io/docs/developers/apiv4/en/#list-futures-orders-2
4395
4411
  :see: https://www.gate.io/docs/developers/apiv4/en/#list-all-auto-orders-2
4396
4412
  :see: https://www.gate.io/docs/developers/apiv4/en/#list-options-orders
4413
+ :see: https://www.gate.io/docs/developers/apiv4/en/#list-futures-orders-by-time-range
4397
4414
  :param str symbol: unified market symbol of the market orders were made in
4398
4415
  :param int [since]: the earliest time in ms to fetch orders for
4399
4416
  :param int [limit]: the maximum number of order structures to retrieve
@@ -4401,28 +4418,59 @@ class gate(Exchange, ImplicitAPI):
4401
4418
  :param bool [params.stop]: True for fetching stop orders
4402
4419
  :param str [params.type]: spot, swap or future, if not provided self.options['defaultType'] is used
4403
4420
  :param str [params.marginMode]: 'cross' or 'isolated' - marginMode for margin trading if not provided self.options['defaultMarginMode'] is used
4421
+ :param boolean [params.historical]: *swap only* True for using historical endpoint
4404
4422
  :returns Order[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
4405
4423
  """
4406
- return await self.fetch_orders_by_status('finished', symbol, since, limit, params)
4424
+ await self.load_markets()
4425
+ until = self.safe_integer(params, 'until')
4426
+ market = None
4427
+ if symbol is not None:
4428
+ market = self.market(symbol)
4429
+ symbol = market['symbol']
4430
+ res = self.handle_market_type_and_params('fetchClosedOrders', market, params)
4431
+ type = self.safe_string(res, 0)
4432
+ useHistorical = False
4433
+ useHistorical, params = self.handle_option_and_params(params, 'fetchClosedOrders', 'historical', False)
4434
+ if not useHistorical and ((since is None and until is None) or (type != 'swap')):
4435
+ return await self.fetch_orders_by_status('finished', symbol, since, limit, params)
4436
+ params = self.omit(params, 'type')
4437
+ request = {}
4438
+ request, params = self.prepare_request(market, type, params)
4439
+ if since is not None:
4440
+ request['from'] = self.parse_to_int(since / 1000)
4441
+ if until is not None:
4442
+ params = self.omit(params, 'until')
4443
+ request['to'] = self.parse_to_int(until / 1000)
4444
+ if limit is not None:
4445
+ request['limit'] = limit
4446
+ response = await self.privateFuturesGetSettleOrdersTimerange(self.extend(request, params))
4447
+ return self.parse_orders(response, market, since, limit)
4407
4448
 
4408
- 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={}):
4409
4450
  market = None
4410
4451
  if symbol is not None:
4411
4452
  market = self.market(symbol)
4412
4453
  symbol = market['symbol']
4413
4454
  stop = self.safe_bool_2(params, 'stop', 'trigger')
4414
4455
  params = self.omit(params, ['stop', 'trigger'])
4415
- 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)
4416
4458
  spot = (type == 'spot') or (type == 'margin')
4417
- 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)
4418
4461
  if status == 'closed':
4419
4462
  status = 'finished'
4420
4463
  request['status'] = status
4421
4464
  if limit is not None:
4422
4465
  request['limit'] = limit
4423
- if since is not None and spot:
4424
- request['from'] = self.parse_to_int(since / 1000)
4425
- 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')
4426
4474
  if lastId is not None:
4427
4475
  request['last_id'] = lastId
4428
4476
  return [request, finalParams]
@@ -4438,7 +4486,7 @@ class gate(Exchange, ImplicitAPI):
4438
4486
  res = self.handle_market_type_and_params('fetchOrdersByStatus', market, params)
4439
4487
  type = self.safe_string(res, 0)
4440
4488
  params['type'] = type
4441
- 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)
4442
4490
  spot = (type == 'spot') or (type == 'margin')
4443
4491
  openSpotOrders = spot and (status == 'open') and not stop
4444
4492
  response = None