ccxt 4.3.85__py2.py3-none-any.whl → 4.3.87__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 (49) hide show
  1. ccxt/__init__.py +4 -1
  2. ccxt/abstract/hashkey.py +67 -0
  3. ccxt/async_support/__init__.py +4 -1
  4. ccxt/async_support/base/exchange.py +2 -2
  5. ccxt/async_support/binance.py +4 -2
  6. ccxt/async_support/bingx.py +5 -1
  7. ccxt/async_support/bitfinex.py +2 -2
  8. ccxt/async_support/hashkey.py +4061 -0
  9. ccxt/async_support/hyperliquid.py +80 -62
  10. ccxt/async_support/indodax.py +29 -8
  11. ccxt/async_support/kraken.py +32 -5
  12. ccxt/async_support/krakenfutures.py +10 -9
  13. ccxt/async_support/upbit.py +1 -1
  14. ccxt/base/errors.py +7 -1
  15. ccxt/base/exchange.py +2 -2
  16. ccxt/binance.py +4 -2
  17. ccxt/bingx.py +5 -1
  18. ccxt/bitfinex.py +2 -2
  19. ccxt/hashkey.py +4061 -0
  20. ccxt/hyperliquid.py +80 -62
  21. ccxt/indodax.py +29 -8
  22. ccxt/kraken.py +32 -5
  23. ccxt/krakenfutures.py +10 -9
  24. ccxt/pro/__init__.py +3 -1
  25. ccxt/pro/ascendex.py +41 -5
  26. ccxt/pro/bingx.py +13 -12
  27. ccxt/pro/bitget.py +143 -16
  28. ccxt/pro/hashkey.py +783 -0
  29. ccxt/pro/hyperliquid.py +118 -1
  30. ccxt/pro/mexc.py +13 -7
  31. ccxt/pro/p2b.py +30 -7
  32. ccxt/pro/poloniex.py +32 -3
  33. ccxt/pro/poloniexfutures.py +1 -0
  34. ccxt/pro/probit.py +2 -0
  35. ccxt/pro/upbit.py +44 -3
  36. ccxt/pro/vertex.py +1 -0
  37. ccxt/pro/wazirx.py +3 -0
  38. ccxt/pro/whitebit.py +9 -0
  39. ccxt/pro/woo.py +1 -0
  40. ccxt/pro/woofipro.py +1 -0
  41. ccxt/pro/xt.py +1 -0
  42. ccxt/test/tests_async.py +31 -31
  43. ccxt/test/tests_sync.py +31 -31
  44. ccxt/upbit.py +1 -1
  45. {ccxt-4.3.85.dist-info → ccxt-4.3.87.dist-info}/METADATA +9 -6
  46. {ccxt-4.3.85.dist-info → ccxt-4.3.87.dist-info}/RECORD +49 -45
  47. {ccxt-4.3.85.dist-info → ccxt-4.3.87.dist-info}/LICENSE.txt +0 -0
  48. {ccxt-4.3.85.dist-info → ccxt-4.3.87.dist-info}/WHEEL +0 -0
  49. {ccxt-4.3.85.dist-info → ccxt-4.3.87.dist-info}/top_level.txt +0 -0
ccxt/pro/bitget.py CHANGED
@@ -16,6 +16,7 @@ from ccxt.base.errors import ArgumentsRequired
16
16
  from ccxt.base.errors import BadRequest
17
17
  from ccxt.base.errors import RateLimitExceeded
18
18
  from ccxt.base.errors import ChecksumError
19
+ from ccxt.base.errors import UnsubscribeError
19
20
  from ccxt.base.precise import Precise
20
21
 
21
22
 
@@ -133,6 +134,17 @@ class bitget(ccxt.async_support.bitget):
133
134
  }
134
135
  return await self.watch_public(messageHash, args, params)
135
136
 
137
+ async def un_watch_ticker(self, symbol: str, params={}) -> Any:
138
+ """
139
+ unsubscribe from the ticker channel
140
+ :see: https://www.bitget.com/api-doc/spot/websocket/public/Tickers-Channel
141
+ :see: https://www.bitget.com/api-doc/contract/websocket/public/Tickers-Channel
142
+ :param str symbol: unified symbol of the market to unwatch the ticker for
143
+ :returns any: status of the unwatch request
144
+ """
145
+ await self.load_markets()
146
+ return await self.un_watch_channel(symbol, 'ticker', 'ticker', params)
147
+
136
148
  async def watch_tickers(self, symbols: Strings = None, params={}) -> Tickers:
137
149
  """
138
150
  watches a price ticker, a statistical calculation with the information calculated over the past 24 hours for all markets of a specific list
@@ -338,6 +350,20 @@ class bitget(ccxt.async_support.bitget):
338
350
  limit = ohlcv.getLimit(symbol, limit)
339
351
  return self.filter_by_since_limit(ohlcv, since, limit, 0, True)
340
352
 
353
+ async def un_watch_ohlcv(self, symbol: str, timeframe='1m', params={}) -> Any:
354
+ """
355
+ unsubscribe from the ohlcv channel
356
+ :see: https://www.bitget.com/api-doc/spot/websocket/public/Candlesticks-Channel
357
+ :see: https://www.bitget.com/api-doc/contract/websocket/public/Candlesticks-Channel
358
+ :param str symbol: unified symbol of the market to unwatch the ohlcv for
359
+ :returns dict: A dictionary of `order book structures <https://docs.ccxt.com/#/?id=order-book-structure>` indexed by market symbols
360
+ """
361
+ await self.load_markets()
362
+ timeframes = self.safe_dict(self.options, 'timeframes')
363
+ interval = self.safe_string(timeframes, timeframe)
364
+ channel = 'candle' + interval
365
+ return await self.un_watch_channel(symbol, channel, 'candles:' + timeframe, params)
366
+
341
367
  def handle_ohlcv(self, client: Client, message):
342
368
  #
343
369
  # {
@@ -440,13 +466,17 @@ class bitget(ccxt.async_support.bitget):
440
466
  :returns dict: A dictionary of `order book structures <https://docs.ccxt.com/#/?id=order-book-structure>` indexed by market symbols
441
467
  """
442
468
  await self.load_markets()
443
- market = self.market(symbol)
444
- messageHash = 'unsubscribe:orderbook:' + market['symbol']
445
469
  channel = 'books'
446
470
  limit = self.safe_integer(params, 'limit')
447
471
  if (limit == 1) or (limit == 5) or (limit == 15):
448
472
  params = self.omit(params, 'limit')
449
473
  channel += str(limit)
474
+ return await self.un_watch_channel(symbol, channel, 'orderbook', params)
475
+
476
+ async def un_watch_channel(self, symbol: str, channel: str, messageHashTopic: str, params={}) -> Any:
477
+ await self.load_markets()
478
+ market = self.market(symbol)
479
+ messageHash = 'unsubscribe:' + messageHashTopic + ':' + market['symbol']
450
480
  instType = None
451
481
  instType, params = self.get_inst_type(market, params)
452
482
  args: dict = {
@@ -648,6 +678,17 @@ class bitget(ccxt.async_support.bitget):
648
678
  limit = trades.getLimit(tradeSymbol, limit)
649
679
  return self.filter_by_since_limit(trades, since, limit, 'timestamp', True)
650
680
 
681
+ async def un_watch_trades(self, symbol: str, params={}) -> Any:
682
+ """
683
+ unsubscribe from the trades channel
684
+ :see: https://www.bitget.com/api-doc/spot/websocket/public/Trades-Channel
685
+ :see: https://www.bitget.com/api-doc/contract/websocket/public/New-Trades-Channel
686
+ :param str symbol: unified symbol of the market to unwatch the trades for
687
+ :returns any: status of the unwatch request
688
+ """
689
+ await self.load_markets()
690
+ return await self.un_watch_channel(symbol, 'trade', 'trade', params)
691
+
651
692
  def handle_trades(self, client: Client, message):
652
693
  #
653
694
  # {
@@ -1750,6 +1791,99 @@ class bitget(ccxt.async_support.bitget):
1750
1791
  #
1751
1792
  return message
1752
1793
 
1794
+ def handle_order_book_un_subscription(self, client: Client, message):
1795
+ #
1796
+ # {"event":"unsubscribe","arg":{"instType":"SPOT","channel":"books","instId":"BTCUSDT"}}
1797
+ #
1798
+ arg = self.safe_dict(message, 'arg', {})
1799
+ instType = self.safe_string_lower(arg, 'instType')
1800
+ type = 'spot' if (instType == 'spot') else 'contract'
1801
+ instId = self.safe_string(arg, 'instId')
1802
+ market = self.safe_market(instId, None, None, type)
1803
+ symbol = market['symbol']
1804
+ messageHash = 'unsubscribe:orderbook:' + market['symbol']
1805
+ subMessageHash = 'orderbook:' + symbol
1806
+ if symbol in self.orderbooks:
1807
+ del self.orderbooks[symbol]
1808
+ if subMessageHash in client.subscriptions:
1809
+ del client.subscriptions[subMessageHash]
1810
+ if messageHash in client.subscriptions:
1811
+ del client.subscriptions[messageHash]
1812
+ error = UnsubscribeError(self.id + 'orderbook ' + symbol)
1813
+ client.reject(error, subMessageHash)
1814
+ client.resolve(True, messageHash)
1815
+
1816
+ def handle_trades_un_subscription(self, client: Client, message):
1817
+ #
1818
+ # {"event":"unsubscribe","arg":{"instType":"SPOT","channel":"trade","instId":"BTCUSDT"}}
1819
+ #
1820
+ arg = self.safe_dict(message, 'arg', {})
1821
+ instType = self.safe_string_lower(arg, 'instType')
1822
+ type = 'spot' if (instType == 'spot') else 'contract'
1823
+ instId = self.safe_string(arg, 'instId')
1824
+ market = self.safe_market(instId, None, None, type)
1825
+ symbol = market['symbol']
1826
+ messageHash = 'unsubscribe:trade:' + market['symbol']
1827
+ subMessageHash = 'trade:' + symbol
1828
+ if symbol in self.trades:
1829
+ del self.trades[symbol]
1830
+ if subMessageHash in client.subscriptions:
1831
+ del client.subscriptions[subMessageHash]
1832
+ if messageHash in client.subscriptions:
1833
+ del client.subscriptions[messageHash]
1834
+ error = UnsubscribeError(self.id + 'trades ' + symbol)
1835
+ client.reject(error, subMessageHash)
1836
+ client.resolve(True, messageHash)
1837
+
1838
+ def handle_ticker_un_subscription(self, client: Client, message):
1839
+ #
1840
+ # {"event":"unsubscribe","arg":{"instType":"SPOT","channel":"trade","instId":"BTCUSDT"}}
1841
+ #
1842
+ arg = self.safe_dict(message, 'arg', {})
1843
+ instType = self.safe_string_lower(arg, 'instType')
1844
+ type = 'spot' if (instType == 'spot') else 'contract'
1845
+ instId = self.safe_string(arg, 'instId')
1846
+ market = self.safe_market(instId, None, None, type)
1847
+ symbol = market['symbol']
1848
+ messageHash = 'unsubscribe:ticker:' + market['symbol']
1849
+ subMessageHash = 'ticker:' + symbol
1850
+ if symbol in self.tickers:
1851
+ del self.tickers[symbol]
1852
+ if subMessageHash in client.subscriptions:
1853
+ del client.subscriptions[subMessageHash]
1854
+ if messageHash in client.subscriptions:
1855
+ del client.subscriptions[messageHash]
1856
+ error = UnsubscribeError(self.id + 'ticker ' + symbol)
1857
+ client.reject(error, subMessageHash)
1858
+ client.resolve(True, messageHash)
1859
+
1860
+ def handle_ohlcv_un_subscription(self, client: Client, message):
1861
+ #
1862
+ # {"event":"unsubscribe","arg":{"instType":"SPOT","channel":"candle1m","instId":"BTCUSDT"}}
1863
+ #
1864
+ arg = self.safe_dict(message, 'arg', {})
1865
+ instType = self.safe_string_lower(arg, 'instType')
1866
+ type = 'spot' if (instType == 'spot') else 'contract'
1867
+ instId = self.safe_string(arg, 'instId')
1868
+ channel = self.safe_string(arg, 'channel')
1869
+ interval = channel.replace('candle', '')
1870
+ timeframes = self.safe_value(self.options, 'timeframes')
1871
+ timeframe = self.find_timeframe(interval, timeframes)
1872
+ market = self.safe_market(instId, None, None, type)
1873
+ symbol = market['symbol']
1874
+ messageHash = 'unsubscribe:candles:' + timeframe + ':' + market['symbol']
1875
+ subMessageHash = 'candles:' + timeframe + ':' + symbol
1876
+ if symbol in self.ohlcvs:
1877
+ if timeframe in self.ohlcvs[symbol]:
1878
+ del self.ohlcvs[symbol][timeframe]
1879
+ if subMessageHash in client.subscriptions:
1880
+ del client.subscriptions[subMessageHash]
1881
+ if messageHash in client.subscriptions:
1882
+ del client.subscriptions[messageHash]
1883
+ error = UnsubscribeError(self.id + ' ohlcv ' + timeframe + ' ' + symbol)
1884
+ client.reject(error, subMessageHash)
1885
+ client.resolve(True, messageHash)
1886
+
1753
1887
  def handle_un_subscription_status(self, client: Client, message):
1754
1888
  #
1755
1889
  # {
@@ -1778,18 +1912,11 @@ class bitget(ccxt.async_support.bitget):
1778
1912
  channel = self.safe_string(arg, 'channel')
1779
1913
  if channel == 'books':
1780
1914
  # for now only unWatchOrderBook is supporteod
1781
- instType = self.safe_string_lower(arg, 'instType')
1782
- type = 'spot' if (instType == 'spot') else 'contract'
1783
- instId = self.safe_string(arg, 'instId')
1784
- market = self.safe_market(instId, None, None, type)
1785
- symbol = market['symbol']
1786
- messageHash = 'unsubscribe:orderbook:' + market['symbol']
1787
- subMessageHash = 'orderbook:' + symbol
1788
- if symbol in self.orderbooks:
1789
- del self.orderbooks[symbol]
1790
- if subMessageHash in client.subscriptions:
1791
- del client.subscriptions[subMessageHash]
1792
- if messageHash in client.subscriptions:
1793
- del client.subscriptions[messageHash]
1794
- client.resolve(True, messageHash)
1915
+ self.handle_order_book_un_subscription(client, message)
1916
+ elif channel == 'trade':
1917
+ self.handle_trades_un_subscription(client, message)
1918
+ elif channel == 'ticker':
1919
+ self.handle_ticker_un_subscription(client, message)
1920
+ elif channel.startswith('candle'):
1921
+ self.handle_ohlcv_un_subscription(client, message)
1795
1922
  return message