ccxt 4.3.84__py2.py3-none-any.whl → 4.3.86__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 (51) hide show
  1. ccxt/__init__.py +4 -1
  2. ccxt/abstract/cryptocom.py +2 -0
  3. ccxt/abstract/hashkey.py +67 -0
  4. ccxt/abstract/kucoinfutures.py +2 -0
  5. ccxt/async_support/__init__.py +4 -1
  6. ccxt/async_support/base/exchange.py +2 -2
  7. ccxt/async_support/binance.py +4 -2
  8. ccxt/async_support/bitfinex.py +2 -2
  9. ccxt/async_support/bitmex.py +2 -0
  10. ccxt/async_support/bybit.py +16 -14
  11. ccxt/async_support/cryptocom.py +113 -3
  12. ccxt/async_support/hashkey.py +4062 -0
  13. ccxt/async_support/hyperliquid.py +80 -62
  14. ccxt/async_support/indodax.py +29 -8
  15. ccxt/async_support/kraken.py +28 -1
  16. ccxt/async_support/krakenfutures.py +10 -9
  17. ccxt/async_support/kucoinfutures.py +5 -0
  18. ccxt/async_support/mexc.py +2 -2
  19. ccxt/base/errors.py +6 -0
  20. ccxt/base/exchange.py +2 -2
  21. ccxt/binance.py +4 -2
  22. ccxt/bitfinex.py +2 -2
  23. ccxt/bitmex.py +2 -0
  24. ccxt/bybit.py +16 -14
  25. ccxt/cryptocom.py +113 -3
  26. ccxt/hashkey.py +4062 -0
  27. ccxt/hyperliquid.py +80 -62
  28. ccxt/indodax.py +29 -8
  29. ccxt/kraken.py +28 -1
  30. ccxt/krakenfutures.py +10 -9
  31. ccxt/kucoinfutures.py +5 -0
  32. ccxt/mexc.py +2 -2
  33. ccxt/pro/__init__.py +3 -1
  34. ccxt/pro/ascendex.py +41 -5
  35. ccxt/pro/binance.py +1 -1
  36. ccxt/pro/bingx.py +13 -12
  37. ccxt/pro/bitget.py +104 -4
  38. ccxt/pro/hashkey.py +783 -0
  39. ccxt/pro/hyperliquid.py +118 -1
  40. ccxt/pro/mexc.py +13 -7
  41. ccxt/pro/okx.py +21 -3
  42. ccxt/pro/woo.py +1 -0
  43. ccxt/pro/woofipro.py +1 -0
  44. ccxt/pro/xt.py +1 -0
  45. ccxt/test/tests_async.py +13 -30
  46. ccxt/test/tests_sync.py +13 -30
  47. {ccxt-4.3.84.dist-info → ccxt-4.3.86.dist-info}/METADATA +8 -6
  48. {ccxt-4.3.84.dist-info → ccxt-4.3.86.dist-info}/RECORD +51 -47
  49. {ccxt-4.3.84.dist-info → ccxt-4.3.86.dist-info}/LICENSE.txt +0 -0
  50. {ccxt-4.3.84.dist-info → ccxt-4.3.86.dist-info}/WHEEL +0 -0
  51. {ccxt-4.3.84.dist-info → ccxt-4.3.86.dist-info}/top_level.txt +0 -0
ccxt/pro/bitget.py CHANGED
@@ -9,6 +9,7 @@ import hashlib
9
9
  from ccxt.base.types import Balances, Int, Order, OrderBook, Position, Str, Strings, Ticker, Tickers, Trade
10
10
  from ccxt.async_support.base.ws.client import Client
11
11
  from typing import List
12
+ from typing import Any
12
13
  from ccxt.base.errors import ExchangeError
13
14
  from ccxt.base.errors import AuthenticationError
14
15
  from ccxt.base.errors import ArgumentsRequired
@@ -429,6 +430,32 @@ class bitget(ccxt.async_support.bitget):
429
430
  """
430
431
  return await self.watch_order_book_for_symbols([symbol], limit, params)
431
432
 
433
+ async def un_watch_order_book(self, symbol: str, params={}) -> Any:
434
+ """
435
+ unsubscribe from the orderbook channel
436
+ :see: https://www.bitget.com/api-doc/spot/websocket/public/Depth-Channel
437
+ :see: https://www.bitget.com/api-doc/contract/websocket/public/Order-Book-Channel
438
+ :param str symbol: unified symbol of the market to fetch the order book for
439
+ :param int [params.limit]: orderbook limit, default is None
440
+ :returns dict: A dictionary of `order book structures <https://docs.ccxt.com/#/?id=order-book-structure>` indexed by market symbols
441
+ """
442
+ await self.load_markets()
443
+ market = self.market(symbol)
444
+ messageHash = 'unsubscribe:orderbook:' + market['symbol']
445
+ channel = 'books'
446
+ limit = self.safe_integer(params, 'limit')
447
+ if (limit == 1) or (limit == 5) or (limit == 15):
448
+ params = self.omit(params, 'limit')
449
+ channel += str(limit)
450
+ instType = None
451
+ instType, params = self.get_inst_type(market, params)
452
+ args: dict = {
453
+ 'instType': instType,
454
+ 'channel': channel,
455
+ 'instId': market['id'],
456
+ }
457
+ return await self.un_watch_public(messageHash, args, params)
458
+
432
459
  async def watch_order_book_for_symbols(self, symbols: List[str], limit: Int = None, params={}) -> OrderBook:
433
460
  """
434
461
  watches information on open orders with bid(buy) and ask(sell) prices, volumes and other data
@@ -542,10 +569,11 @@ class bitget(ccxt.async_support.bitget):
542
569
  calculatedChecksum = self.crc32(payload, True)
543
570
  responseChecksum = self.safe_integer(rawOrderBook, 'checksum')
544
571
  if calculatedChecksum != responseChecksum:
545
- del client.subscriptions[messageHash]
546
- del self.orderbooks[symbol]
547
- error = ChecksumError(self.id + ' ' + self.orderbook_checksum_message(symbol))
548
- client.reject(error, messageHash)
572
+ # if messageHash in client.subscriptions:
573
+ # # del client.subscriptions[messageHash]
574
+ # # del self.orderbooks[symbol]
575
+ # }
576
+ self.spawn(self.handle_check_sum_error, client, symbol, messageHash)
549
577
  return
550
578
  else:
551
579
  orderbook = self.order_book({})
@@ -554,6 +582,11 @@ class bitget(ccxt.async_support.bitget):
554
582
  self.orderbooks[symbol] = orderbook
555
583
  client.resolve(self.orderbooks[symbol], messageHash)
556
584
 
585
+ async def handle_check_sum_error(self, client: Client, symbol: str, messageHash: str):
586
+ await self.un_watch_order_book(symbol)
587
+ error = ChecksumError(self.id + ' ' + self.orderbook_checksum_message(symbol))
588
+ client.reject(error, messageHash)
589
+
557
590
  def handle_delta(self, bookside, delta):
558
591
  bidAsk = self.parse_bid_ask(delta, 0, 1)
559
592
  # we store the string representations in the orderbook for checksum calculation
@@ -1524,6 +1557,15 @@ class bitget(ccxt.async_support.bitget):
1524
1557
  message = self.extend(request, params)
1525
1558
  return await self.watch(url, messageHash, message, messageHash)
1526
1559
 
1560
+ async def un_watch_public(self, messageHash, args, params={}):
1561
+ url = self.urls['api']['ws']['public']
1562
+ request: dict = {
1563
+ 'op': 'unsubscribe',
1564
+ 'args': [args],
1565
+ }
1566
+ message = self.extend(request, params)
1567
+ return await self.watch(url, messageHash, message, messageHash)
1568
+
1527
1569
  async def watch_public_multiple(self, messageHashes, argsArray, params={}):
1528
1570
  url = self.urls['api']['ws']['public']
1529
1571
  request: dict = {
@@ -1637,6 +1679,17 @@ class bitget(ccxt.async_support.bitget):
1637
1679
  # "event": "subscribe",
1638
1680
  # "arg": {instType: 'SPOT', channel: "account", instId: "default"}
1639
1681
  # }
1682
+ # unsubscribe
1683
+ # {
1684
+ # "op":"unsubscribe",
1685
+ # "args":[
1686
+ # {
1687
+ # "instType":"USDT-FUTURES",
1688
+ # "channel":"ticker",
1689
+ # "instId":"BTCUSDT"
1690
+ # }
1691
+ # ]
1692
+ # }
1640
1693
  #
1641
1694
  if self.handle_error_message(client, message):
1642
1695
  return
@@ -1654,6 +1707,9 @@ class bitget(ccxt.async_support.bitget):
1654
1707
  if event == 'subscribe':
1655
1708
  self.handle_subscription_status(client, message)
1656
1709
  return
1710
+ if event == 'unsubscribe':
1711
+ self.handle_un_subscription_status(client, message)
1712
+ return
1657
1713
  methods: dict = {
1658
1714
  'ticker': self.handle_ticker,
1659
1715
  'trade': self.handle_trades,
@@ -1693,3 +1749,47 @@ class bitget(ccxt.async_support.bitget):
1693
1749
  # }
1694
1750
  #
1695
1751
  return message
1752
+
1753
+ def handle_un_subscription_status(self, client: Client, message):
1754
+ #
1755
+ # {
1756
+ # "op":"unsubscribe",
1757
+ # "args":[
1758
+ # {
1759
+ # "instType":"USDT-FUTURES",
1760
+ # "channel":"ticker",
1761
+ # "instId":"BTCUSDT"
1762
+ # },
1763
+ # {
1764
+ # "instType":"USDT-FUTURES",
1765
+ # "channel":"candle1m",
1766
+ # "instId":"BTCUSDT"
1767
+ # }
1768
+ # ]
1769
+ # }
1770
+ # or
1771
+ # {"event":"unsubscribe","arg":{"instType":"SPOT","channel":"books","instId":"BTCUSDT"}}
1772
+ #
1773
+ argsList = self.safe_list(message, 'args')
1774
+ if argsList is None:
1775
+ argsList = [self.safe_dict(message, 'arg', {})]
1776
+ for i in range(0, len(argsList)):
1777
+ arg = argsList[i]
1778
+ channel = self.safe_string(arg, 'channel')
1779
+ if channel == 'books':
1780
+ # 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)
1795
+ return message