ccxt 4.4.21__py2.py3-none-any.whl → 4.4.23__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 (76) hide show
  1. ccxt/__init__.py +3 -1
  2. ccxt/abstract/binance.py +64 -43
  3. ccxt/abstract/binancecoinm.py +64 -43
  4. ccxt/abstract/binanceus.py +64 -43
  5. ccxt/abstract/binanceusdm.py +64 -43
  6. ccxt/abstract/bitflyer.py +1 -0
  7. ccxt/abstract/bitget.py +3 -0
  8. ccxt/abstract/cex.py +28 -29
  9. ccxt/abstract/coincatch.py +94 -0
  10. ccxt/abstract/gate.py +5 -0
  11. ccxt/abstract/gateio.py +5 -0
  12. ccxt/abstract/kucoin.py +1 -0
  13. ccxt/abstract/kucoinfutures.py +1 -0
  14. ccxt/abstract/okx.py +1 -0
  15. ccxt/alpaca.py +1 -0
  16. ccxt/async_support/__init__.py +3 -1
  17. ccxt/async_support/alpaca.py +1 -0
  18. ccxt/async_support/base/exchange.py +7 -1
  19. ccxt/async_support/bigone.py +3 -0
  20. ccxt/async_support/binance.py +183 -63
  21. ccxt/async_support/bitfinex.py +4 -0
  22. ccxt/async_support/bitflyer.py +57 -1
  23. ccxt/async_support/bitget.py +73 -1
  24. ccxt/async_support/bitrue.py +3 -0
  25. ccxt/async_support/bybit.py +76 -3
  26. ccxt/async_support/cex.py +1247 -1322
  27. ccxt/async_support/coinbase.py +1 -1
  28. ccxt/async_support/coinbaseexchange.py +3 -0
  29. ccxt/async_support/coincatch.py +4955 -0
  30. ccxt/async_support/coinex.py +60 -1
  31. ccxt/async_support/cryptocom.py +1 -1
  32. ccxt/async_support/gate.py +97 -2
  33. ccxt/async_support/htx.py +1 -5
  34. ccxt/async_support/hyperliquid.py +10 -8
  35. ccxt/async_support/kucoin.py +27 -57
  36. ccxt/async_support/latoken.py +6 -0
  37. ccxt/async_support/mexc.py +1 -1
  38. ccxt/async_support/oceanex.py +2 -0
  39. ccxt/async_support/okcoin.py +1 -0
  40. ccxt/async_support/okx.py +67 -1
  41. ccxt/async_support/poloniex.py +5 -0
  42. ccxt/base/exchange.py +21 -1
  43. ccxt/base/types.py +9 -0
  44. ccxt/bigone.py +3 -0
  45. ccxt/binance.py +183 -63
  46. ccxt/bitfinex.py +4 -0
  47. ccxt/bitflyer.py +57 -1
  48. ccxt/bitget.py +73 -1
  49. ccxt/bitrue.py +3 -0
  50. ccxt/bybit.py +76 -3
  51. ccxt/cex.py +1246 -1322
  52. ccxt/coinbase.py +1 -1
  53. ccxt/coinbaseexchange.py +3 -0
  54. ccxt/coincatch.py +4955 -0
  55. ccxt/coinex.py +60 -1
  56. ccxt/cryptocom.py +1 -1
  57. ccxt/gate.py +97 -2
  58. ccxt/htx.py +1 -5
  59. ccxt/hyperliquid.py +10 -8
  60. ccxt/kucoin.py +27 -57
  61. ccxt/latoken.py +6 -0
  62. ccxt/mexc.py +1 -1
  63. ccxt/oceanex.py +2 -0
  64. ccxt/okcoin.py +1 -0
  65. ccxt/okx.py +67 -1
  66. ccxt/poloniex.py +5 -0
  67. ccxt/pro/__init__.py +3 -1
  68. ccxt/pro/coincatch.py +1429 -0
  69. ccxt/test/tests_async.py +19 -5
  70. ccxt/test/tests_sync.py +19 -5
  71. ccxt-4.4.23.dist-info/METADATA +636 -0
  72. {ccxt-4.4.21.dist-info → ccxt-4.4.23.dist-info}/RECORD +75 -71
  73. ccxt-4.4.21.dist-info/METADATA +0 -635
  74. {ccxt-4.4.21.dist-info → ccxt-4.4.23.dist-info}/LICENSE.txt +0 -0
  75. {ccxt-4.4.21.dist-info → ccxt-4.4.23.dist-info}/WHEEL +0 -0
  76. {ccxt-4.4.21.dist-info → ccxt-4.4.23.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, 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
9
+ 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
10
10
  from typing import List
11
11
  from ccxt.base.errors import ExchangeError
12
12
  from ccxt.base.errors import AuthenticationError
@@ -105,6 +105,8 @@ class bybit(Exchange, ImplicitAPI):
105
105
  'fetchLedger': True,
106
106
  'fetchLeverage': True,
107
107
  'fetchLeverageTiers': True,
108
+ 'fetchLongShortRatio': False,
109
+ 'fetchLongShortRatioHistory': True,
108
110
  'fetchMarginAdjustmentHistory': False,
109
111
  'fetchMarketLeverageTiers': True,
110
112
  'fetchMarkets': True,
@@ -7085,13 +7087,13 @@ class bybit(Exchange, ImplicitAPI):
7085
7087
 
7086
7088
  def parse_margin_loan(self, info, currency: Currency = None):
7087
7089
  #
7088
- # borrowMargin
7090
+ # borrowCrossMargin
7089
7091
  #
7090
7092
  # {
7091
7093
  # "transactId": "14143"
7092
7094
  # }
7093
7095
  #
7094
- # repayMargin
7096
+ # repayCrossMargin
7095
7097
  #
7096
7098
  # {
7097
7099
  # "repayId": "12128"
@@ -8664,6 +8666,77 @@ class bybit(Exchange, ImplicitAPI):
8664
8666
  'fee': None,
8665
8667
  }
8666
8668
 
8669
+ def fetch_long_short_ratio_history(self, symbol: Str = None, timeframe: Str = None, since: Int = None, limit: Int = None, params={}) -> List[LongShortRatio]:
8670
+ """
8671
+ fetches the long short ratio history for a unified market symbol
8672
+ :see: https://bybit-exchange.github.io/docs/v5/market/long-short-ratio
8673
+ :param str symbol: unified symbol of the market to fetch the long short ratio for
8674
+ :param str [timeframe]: the period for the ratio, default is 24 hours
8675
+ :param int [since]: the earliest time in ms to fetch ratios for
8676
+ :param int [limit]: the maximum number of long short ratio structures to retrieve
8677
+ :param dict [params]: extra parameters specific to the exchange API endpoint
8678
+ :returns dict[]: an array of `long short ratio structures <https://docs.ccxt.com/#/?id=long-short-ratio-structure>`
8679
+ """
8680
+ self.load_markets()
8681
+ market = self.market(symbol)
8682
+ type = None
8683
+ type, params = self.get_bybit_type('fetchLongShortRatioHistory', market, params)
8684
+ if type == 'spot' or type == 'option':
8685
+ raise NotSupported(self.id + ' fetchLongShortRatioHistory() only support linear and inverse markets')
8686
+ if timeframe is None:
8687
+ timeframe = '1d'
8688
+ request: dict = {
8689
+ 'symbol': market['id'],
8690
+ 'period': timeframe,
8691
+ 'category': type,
8692
+ }
8693
+ if limit is not None:
8694
+ request['limit'] = limit
8695
+ response = self.publicGetV5MarketAccountRatio(self.extend(request, params))
8696
+ #
8697
+ # {
8698
+ # "retCode": 0,
8699
+ # "retMsg": "OK",
8700
+ # "result": {
8701
+ # "list": [
8702
+ # {
8703
+ # "symbol": "BTCUSDT",
8704
+ # "buyRatio": "0.5707",
8705
+ # "sellRatio": "0.4293",
8706
+ # "timestamp": "1729123200000"
8707
+ # },
8708
+ # ]
8709
+ # },
8710
+ # "retExtInfo": {},
8711
+ # "time": 1729147842516
8712
+ # }
8713
+ #
8714
+ result = self.safe_dict(response, 'result', {})
8715
+ data = self.safe_list(result, 'list', [])
8716
+ return self.parse_long_short_ratio_history(data, market)
8717
+
8718
+ def parse_long_short_ratio(self, info: dict, market: Market = None) -> LongShortRatio:
8719
+ #
8720
+ # {
8721
+ # "symbol": "BTCUSDT",
8722
+ # "buyRatio": "0.5707",
8723
+ # "sellRatio": "0.4293",
8724
+ # "timestamp": "1729123200000"
8725
+ # }
8726
+ #
8727
+ marketId = self.safe_string(info, 'symbol')
8728
+ timestamp = self.safe_integer_omit_zero(info, 'timestamp')
8729
+ longString = self.safe_string(info, 'buyRatio')
8730
+ shortString = self.safe_string(info, 'sellRatio')
8731
+ return {
8732
+ 'info': info,
8733
+ 'symbol': self.safe_symbol(marketId, market, None, 'contract'),
8734
+ 'timestamp': timestamp,
8735
+ 'datetime': self.iso8601(timestamp),
8736
+ 'timeframe': None,
8737
+ 'longShortRatio': self.parse_to_numeric(Precise.string_div(longString, shortString)),
8738
+ }
8739
+
8667
8740
  def sign(self, path, api='public', method='GET', params={}, headers=None, body=None):
8668
8741
  url = self.implode_hostname(self.urls['api'][api]) + '/' + path
8669
8742
  if api == 'public':