ccxt 4.4.21__py2.py3-none-any.whl → 4.4.22__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 (47) hide show
  1. ccxt/__init__.py +1 -1
  2. ccxt/abstract/bitflyer.py +1 -0
  3. ccxt/abstract/bitget.py +3 -0
  4. ccxt/abstract/cex.py +28 -29
  5. ccxt/abstract/gate.py +5 -0
  6. ccxt/abstract/gateio.py +5 -0
  7. ccxt/abstract/kucoin.py +1 -0
  8. ccxt/abstract/kucoinfutures.py +1 -0
  9. ccxt/abstract/okx.py +1 -0
  10. ccxt/alpaca.py +1 -0
  11. ccxt/async_support/__init__.py +1 -1
  12. ccxt/async_support/alpaca.py +1 -0
  13. ccxt/async_support/base/exchange.py +7 -1
  14. ccxt/async_support/bigone.py +3 -0
  15. ccxt/async_support/binance.py +96 -1
  16. ccxt/async_support/bitflyer.py +56 -1
  17. ccxt/async_support/bitget.py +73 -1
  18. ccxt/async_support/bybit.py +74 -1
  19. ccxt/async_support/cex.py +1247 -1326
  20. ccxt/async_support/cryptocom.py +1 -1
  21. ccxt/async_support/gate.py +97 -2
  22. ccxt/async_support/htx.py +1 -5
  23. ccxt/async_support/hyperliquid.py +10 -8
  24. ccxt/async_support/kucoin.py +27 -57
  25. ccxt/async_support/okx.py +67 -1
  26. ccxt/base/exchange.py +21 -1
  27. ccxt/base/types.py +9 -0
  28. ccxt/bigone.py +3 -0
  29. ccxt/binance.py +96 -1
  30. ccxt/bitflyer.py +56 -1
  31. ccxt/bitget.py +73 -1
  32. ccxt/bybit.py +74 -1
  33. ccxt/cex.py +1246 -1326
  34. ccxt/cryptocom.py +1 -1
  35. ccxt/gate.py +97 -2
  36. ccxt/htx.py +1 -5
  37. ccxt/hyperliquid.py +10 -8
  38. ccxt/kucoin.py +27 -57
  39. ccxt/okx.py +67 -1
  40. ccxt/pro/__init__.py +1 -1
  41. ccxt/test/tests_async.py +4 -4
  42. ccxt/test/tests_sync.py +4 -4
  43. {ccxt-4.4.21.dist-info → ccxt-4.4.22.dist-info}/METADATA +5 -5
  44. {ccxt-4.4.21.dist-info → ccxt-4.4.22.dist-info}/RECORD +47 -47
  45. {ccxt-4.4.21.dist-info → ccxt-4.4.22.dist-info}/LICENSE.txt +0 -0
  46. {ccxt-4.4.21.dist-info → ccxt-4.4.22.dist-info}/WHEEL +0 -0
  47. {ccxt-4.4.21.dist-info → ccxt-4.4.22.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, DepositAddress, 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
+ from ccxt.base.types import LongShortRatio, Balances, Conversion, CrossBorrowRate, Currencies, Currency, DepositAddress, 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
@@ -106,6 +106,8 @@ class bybit(Exchange, ImplicitAPI):
106
106
  'fetchLedger': True,
107
107
  'fetchLeverage': True,
108
108
  'fetchLeverageTiers': True,
109
+ 'fetchLongShortRatio': False,
110
+ 'fetchLongShortRatioHistory': True,
109
111
  'fetchMarginAdjustmentHistory': False,
110
112
  'fetchMarketLeverageTiers': True,
111
113
  'fetchMarkets': True,
@@ -8665,6 +8667,77 @@ class bybit(Exchange, ImplicitAPI):
8665
8667
  'fee': None,
8666
8668
  }
8667
8669
 
8670
+ async def fetch_long_short_ratio_history(self, symbol: Str = None, timeframe: Str = None, since: Int = None, limit: Int = None, params={}) -> List[LongShortRatio]:
8671
+ """
8672
+ fetches the long short ratio history for a unified market symbol
8673
+ :see: https://bybit-exchange.github.io/docs/v5/market/long-short-ratio
8674
+ :param str symbol: unified symbol of the market to fetch the long short ratio for
8675
+ :param str [timeframe]: the period for the ratio, default is 24 hours
8676
+ :param int [since]: the earliest time in ms to fetch ratios for
8677
+ :param int [limit]: the maximum number of long short ratio structures to retrieve
8678
+ :param dict [params]: extra parameters specific to the exchange API endpoint
8679
+ :returns dict[]: an array of `long short ratio structures <https://docs.ccxt.com/#/?id=long-short-ratio-structure>`
8680
+ """
8681
+ await self.load_markets()
8682
+ market = self.market(symbol)
8683
+ type = None
8684
+ type, params = self.get_bybit_type('fetchLongShortRatioHistory', market, params)
8685
+ if type == 'spot' or type == 'option':
8686
+ raise NotSupported(self.id + ' fetchLongShortRatioHistory() only support linear and inverse markets')
8687
+ if timeframe is None:
8688
+ timeframe = '1d'
8689
+ request: dict = {
8690
+ 'symbol': market['id'],
8691
+ 'period': timeframe,
8692
+ 'category': type,
8693
+ }
8694
+ if limit is not None:
8695
+ request['limit'] = limit
8696
+ response = await self.publicGetV5MarketAccountRatio(self.extend(request, params))
8697
+ #
8698
+ # {
8699
+ # "retCode": 0,
8700
+ # "retMsg": "OK",
8701
+ # "result": {
8702
+ # "list": [
8703
+ # {
8704
+ # "symbol": "BTCUSDT",
8705
+ # "buyRatio": "0.5707",
8706
+ # "sellRatio": "0.4293",
8707
+ # "timestamp": "1729123200000"
8708
+ # },
8709
+ # ]
8710
+ # },
8711
+ # "retExtInfo": {},
8712
+ # "time": 1729147842516
8713
+ # }
8714
+ #
8715
+ result = self.safe_dict(response, 'result', {})
8716
+ data = self.safe_list(result, 'list', [])
8717
+ return self.parse_long_short_ratio_history(data, market)
8718
+
8719
+ def parse_long_short_ratio(self, info: dict, market: Market = None) -> LongShortRatio:
8720
+ #
8721
+ # {
8722
+ # "symbol": "BTCUSDT",
8723
+ # "buyRatio": "0.5707",
8724
+ # "sellRatio": "0.4293",
8725
+ # "timestamp": "1729123200000"
8726
+ # }
8727
+ #
8728
+ marketId = self.safe_string(info, 'symbol')
8729
+ timestamp = self.safe_integer_omit_zero(info, 'timestamp')
8730
+ longString = self.safe_string(info, 'buyRatio')
8731
+ shortString = self.safe_string(info, 'sellRatio')
8732
+ return {
8733
+ 'info': info,
8734
+ 'symbol': self.safe_symbol(marketId, market, None, 'contract'),
8735
+ 'timestamp': timestamp,
8736
+ 'datetime': self.iso8601(timestamp),
8737
+ 'timeframe': None,
8738
+ 'longShortRatio': self.parse_to_numeric(Precise.string_div(longString, shortString)),
8739
+ }
8740
+
8668
8741
  def sign(self, path, api='public', method='GET', params={}, headers=None, body=None):
8669
8742
  url = self.implode_hostname(self.urls['api'][api]) + '/' + path
8670
8743
  if api == 'public':