ccxt 4.4.1__py2.py3-none-any.whl → 4.4.2__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.
ccxt/mexc.py CHANGED
@@ -1012,6 +1012,13 @@ class mexc(Exchange, ImplicitAPI):
1012
1012
  return self.array_concat(spotMarket, swapMarket)
1013
1013
 
1014
1014
  def fetch_spot_markets(self, params={}):
1015
+ """
1016
+ * @ignore
1017
+ retrieves data on all spot markets for mexc
1018
+ :see: https://mexcdevelop.github.io/apidocs/spot_v3_en/#exchange-information
1019
+ :param dict [params]: extra parameters specific to the exchange API endpoint
1020
+ :returns dict[]: an array of objects representing market data
1021
+ """
1015
1022
  response = self.spotPublicGetExchangeInfo(params)
1016
1023
  #
1017
1024
  # {
@@ -1127,6 +1134,13 @@ class mexc(Exchange, ImplicitAPI):
1127
1134
  return result
1128
1135
 
1129
1136
  def fetch_swap_markets(self, params={}):
1137
+ """
1138
+ * @ignore
1139
+ retrieves data on all swap markets for mexc
1140
+ :see: https://mexcdevelop.github.io/apidocs/contract_v1_en/#get-the-contract-information
1141
+ :param dict [params]: extra parameters specific to the exchange API endpoint
1142
+ :returns dict[]: an array of objects representing market data
1143
+ """
1130
1144
  response = self.contractPublicGetDetail(params)
1131
1145
  #
1132
1146
  # {
@@ -1666,6 +1680,8 @@ class mexc(Exchange, ImplicitAPI):
1666
1680
  def fetch_tickers(self, symbols: Strings = None, params={}) -> Tickers:
1667
1681
  """
1668
1682
  fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
1683
+ :see: https://mexcdevelop.github.io/apidocs/spot_v3_en/#24hr-ticker-price-change-statistics
1684
+ :see: https://mexcdevelop.github.io/apidocs/contract_v1_en/#get-contract-trend-data
1669
1685
  :param str[]|None symbols: unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
1670
1686
  :param dict [params]: extra parameters specific to the exchange API endpoint
1671
1687
  :returns dict: a dictionary of `ticker structures <https://docs.ccxt.com/#/?id=ticker-structure>`
@@ -1747,6 +1763,8 @@ class mexc(Exchange, ImplicitAPI):
1747
1763
  def fetch_ticker(self, symbol: str, params={}) -> Ticker:
1748
1764
  """
1749
1765
  fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
1766
+ :see: https://mexcdevelop.github.io/apidocs/spot_v3_en/#24hr-ticker-price-change-statistics
1767
+ :see: https://mexcdevelop.github.io/apidocs/contract_v1_en/#get-contract-trend-data
1750
1768
  :param str symbol: unified symbol of the market to fetch the ticker for
1751
1769
  :param dict [params]: extra parameters specific to the exchange API endpoint
1752
1770
  :returns dict: a `ticker structure <https://docs.ccxt.com/#/?id=ticker-structure>`
@@ -1929,6 +1947,7 @@ class mexc(Exchange, ImplicitAPI):
1929
1947
  def fetch_bids_asks(self, symbols: Strings = None, params={}):
1930
1948
  """
1931
1949
  fetches the bid and ask price and volume for multiple markets
1950
+ :see: https://mexcdevelop.github.io/apidocs/spot_v3_en/#symbol-order-book-ticker
1932
1951
  :param str[]|None symbols: unified symbols of the markets to fetch the bids and asks for, all markets are returned if not assigned
1933
1952
  :param dict [params]: extra parameters specific to the exchange API endpoint
1934
1953
  :returns dict: a dictionary of `ticker structures <https://docs.ccxt.com/#/?id=ticker-structure>`
@@ -2052,6 +2071,21 @@ class mexc(Exchange, ImplicitAPI):
2052
2071
  return self.extend(request, params)
2053
2072
 
2054
2073
  def create_spot_order(self, market, type, side, amount, price=None, marginMode=None, params={}):
2074
+ """
2075
+ * @ignore
2076
+ create a trade order
2077
+ :see: https://mexcdevelop.github.io/apidocs/spot_v3_en/#new-order
2078
+ :param str symbol: unified symbol of the market to create an order in
2079
+ :param str type: 'market' or 'limit'
2080
+ :param str side: 'buy' or 'sell'
2081
+ :param float amount: how much of currency you want to trade in units of base currency
2082
+ :param float [price]: the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
2083
+ :param dict [params]: extra parameters specific to the exchange API endpoint
2084
+ :param str [params.marginMode]: only 'isolated' is supported for spot-margin trading
2085
+ :param float [params.triggerPrice]: The price at which a trigger order is triggered at
2086
+ :param bool [params.postOnly]: if True, the order will only be posted if it will be a maker order
2087
+ :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
2088
+ """
2055
2089
  self.load_markets()
2056
2090
  request = self.create_spot_order_request(market, type, side, amount, price, marginMode, params)
2057
2091
  response = self.spotPrivatePostOrder(self.extend(request, params))
@@ -2082,6 +2116,30 @@ class mexc(Exchange, ImplicitAPI):
2082
2116
  return order
2083
2117
 
2084
2118
  def create_swap_order(self, market, type, side, amount, price=None, marginMode=None, params={}):
2119
+ """
2120
+ * @ignore
2121
+ create a trade order
2122
+ :see: https://mexcdevelop.github.io/apidocs/spot_v3_en/#new-order
2123
+ :see: https://mexcdevelop.github.io/apidocs/contract_v1_en/#order-under-maintenance
2124
+ :see: https://mexcdevelop.github.io/apidocs/contract_v1_en/#trigger-order-under-maintenance
2125
+ :param str symbol: unified symbol of the market to create an order in
2126
+ :param str type: 'market' or 'limit'
2127
+ :param str side: 'buy' or 'sell'
2128
+ :param float amount: how much of currency you want to trade in units of base currency
2129
+ :param float [price]: the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
2130
+ :param dict [params]: extra parameters specific to the exchange API endpoint
2131
+ :param str [params.marginMode]: only 'isolated' is supported for spot-margin trading
2132
+ :param float [params.triggerPrice]: The price at which a trigger order is triggered at
2133
+ :param bool [params.postOnly]: if True, the order will only be posted if it will be a maker order
2134
+ :param bool [params.reduceOnly]: indicates if self order is to reduce the size of a position
2135
+ *
2136
+ * EXCHANGE SPECIFIC PARAMETERS
2137
+ :param int [params.leverage]: leverage is necessary on isolated margin
2138
+ :param long [params.positionId]: it is recommended to hasattr(self, fill) parameter when closing a position
2139
+ :param str [params.externalOid]: external order ID
2140
+ :param int [params.positionMode]: 1:hedge, 2:one-way, default: the user's current config
2141
+ :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
2142
+ """
2085
2143
  self.load_markets()
2086
2144
  symbol = market['symbol']
2087
2145
  unavailableContracts = self.safe_value(self.options, 'unavailableContracts', {})
@@ -2230,6 +2288,8 @@ class mexc(Exchange, ImplicitAPI):
2230
2288
  def fetch_order(self, id: str, symbol: Str = None, params={}):
2231
2289
  """
2232
2290
  fetches information on an order made by the user
2291
+ :see: https://mexcdevelop.github.io/apidocs/spot_v3_en/#query-order
2292
+ :see: https://mexcdevelop.github.io/apidocs/contract_v1_en/#query-the-order-based-on-the-order-number
2233
2293
  :param str symbol: unified symbol of the market the order was made in
2234
2294
  :param dict [params]: extra parameters specific to the exchange API endpoint
2235
2295
  :param str [params.marginMode]: only 'isolated' is supported, for spot-margin trading
@@ -4506,7 +4566,7 @@ class mexc(Exchange, ImplicitAPI):
4506
4566
  'entryPrice': entryPrice,
4507
4567
  'collateral': None,
4508
4568
  'side': side,
4509
- 'unrealizedProfit': None,
4569
+ 'unrealizedPnl': None,
4510
4570
  'leverage': self.parse_number(leverage),
4511
4571
  'percentage': None,
4512
4572
  'marginMode': marginType,
ccxt/pro/__init__.py CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  # ----------------------------------------------------------------------------
6
6
 
7
- __version__ = '4.4.1'
7
+ __version__ = '4.4.2'
8
8
 
9
9
  # ----------------------------------------------------------------------------
10
10
 
ccxt/pro/binance.py CHANGED
@@ -14,7 +14,6 @@ from ccxt.base.errors import ArgumentsRequired
14
14
  from ccxt.base.errors import BadRequest
15
15
  from ccxt.base.errors import NotSupported
16
16
  from ccxt.base.errors import ChecksumError
17
- from ccxt.base.errors import UnsubscribeError
18
17
  from ccxt.base.precise import Precise
19
18
 
20
19
 
@@ -952,52 +951,9 @@ class binance(ccxt.async_support.binance):
952
951
  for j in range(0, len(messageHashes)):
953
952
  unsubHash = messageHashes[j]
954
953
  subHash = subMessageHashes[j]
955
- if unsubHash in client.subscriptions:
956
- del client.subscriptions[unsubHash]
957
- if subHash in client.subscriptions:
958
- del client.subscriptions[subHash]
959
- error = UnsubscribeError(self.id + ' ' + subHash)
960
- client.reject(error, subHash)
961
- client.resolve(True, unsubHash)
954
+ self.clean_unsubscription(client, subHash, unsubHash)
962
955
  self.clean_cache(subscription)
963
956
 
964
- def clean_cache(self, subscription: dict):
965
- topic = self.safe_string(subscription, 'topic')
966
- symbols = self.safe_list(subscription, 'symbols', [])
967
- symbolsLength = len(symbols)
968
- if topic == 'ohlcv':
969
- symbolsAndTimeFrames = self.safe_list(subscription, 'symbolsAndTimeframes', [])
970
- for i in range(0, len(symbolsAndTimeFrames)):
971
- symbolAndTimeFrame = symbolsAndTimeFrames[i]
972
- symbol = self.safe_string(symbolAndTimeFrame, 0)
973
- timeframe = self.safe_string(symbolAndTimeFrame, 1)
974
- if timeframe in self.ohlcvs[symbol]:
975
- del self.ohlcvs[symbol][timeframe]
976
- elif symbolsLength > 0:
977
- for i in range(0, len(symbols)):
978
- symbol = symbols[i]
979
- if topic == 'trade':
980
- del self.trades[symbol]
981
- elif topic == 'orderbook':
982
- del self.orderbooks[symbol]
983
- elif topic == 'ticker':
984
- del self.tickers[symbol]
985
- else:
986
- if topic == 'myTrades':
987
- # don't reset self.myTrades directly here
988
- # because in c# we need to use a different object
989
- keys = list(self.myTrades.keys())
990
- for i in range(0, len(keys)):
991
- del self.myTrades[keys[i]]
992
- elif topic == 'orders':
993
- orderSymbols = list(self.orders.keys())
994
- for i in range(0, len(orderSymbols)):
995
- del self.orders[orderSymbols[i]]
996
- elif topic == 'ticker':
997
- tickerSymbols = list(self.tickers.keys())
998
- for i in range(0, len(tickerSymbols)):
999
- del self.tickers[tickerSymbols[i]]
1000
-
1001
957
  async def watch_trades_for_symbols(self, symbols: List[str], since: Int = None, limit: Int = None, params={}) -> List[Trade]:
1002
958
  """
1003
959
  get the list of most recent trades for a list of symbols
@@ -1106,7 +1062,7 @@ class binance(ccxt.async_support.binance):
1106
1062
  'subMessageHashes': subMessageHashes,
1107
1063
  'messageHashes': messageHashes,
1108
1064
  'symbols': symbols,
1109
- 'topic': 'trade',
1065
+ 'topic': 'trades',
1110
1066
  }
1111
1067
  return await self.watch_multiple(url, messageHashes, self.extend(request, query), messageHashes, subscription)
1112
1068
 
@@ -1810,7 +1766,7 @@ class binance(ccxt.async_support.binance):
1810
1766
  result = await self.watch_multi_ticker_helper('watchBidsAsks', 'bookTicker', symbols, params)
1811
1767
  if self.newUpdates:
1812
1768
  return result
1813
- return self.filter_by_array(self.tickers, 'symbol', symbols)
1769
+ return self.filter_by_array(self.bidsasks, 'symbol', symbols)
1814
1770
 
1815
1771
  async def watch_multi_ticker_helper(self, methodName, channelName: str, symbols: Strings = None, params={}):
1816
1772
  await self.load_markets()
ccxt/pro/bitget.py CHANGED
@@ -1876,13 +1876,7 @@ class bitget(ccxt.async_support.bitget):
1876
1876
  if symbol in self.ohlcvs:
1877
1877
  if timeframe in self.ohlcvs[symbol]:
1878
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)
1879
+ self.clean_unsubscription(client, subMessageHash, messageHash)
1886
1880
 
1887
1881
  def handle_un_subscription_status(self, client: Client, message):
1888
1882
  #
ccxt/pro/bitmex.py CHANGED
@@ -66,6 +66,7 @@ class bitmex(ccxt.async_support.bitmex):
66
66
  async def watch_ticker(self, symbol: str, params={}) -> Ticker:
67
67
  """
68
68
  watches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
69
+ :see: https://www.bitmex.com/app/wsAPI#Subscriptions
69
70
  :param str symbol: unified symbol of the market to fetch the ticker for
70
71
  :param dict [params]: extra parameters specific to the exchange API endpoint
71
72
  :returns dict: a `ticker structure <https://docs.ccxt.com/#/?id=ticker-structure>`
@@ -78,6 +79,7 @@ class bitmex(ccxt.async_support.bitmex):
78
79
  async def watch_tickers(self, symbols: Strings = None, params={}) -> Tickers:
79
80
  """
80
81
  watches a price ticker, a statistical calculation with the information calculated over the past 24 hours for all markets of a specific list
82
+ :see: https://www.bitmex.com/app/wsAPI#Subscriptions
81
83
  :param str[] symbols: unified symbol of the market to fetch the ticker for
82
84
  :param dict [params]: extra parameters specific to the exchange API endpoint
83
85
  :returns dict: a `ticker structure <https://docs.ccxt.com/#/?id=ticker-structure>`
@@ -449,6 +451,7 @@ class bitmex(ccxt.async_support.bitmex):
449
451
  async def watch_balance(self, params={}) -> Balances:
450
452
  """
451
453
  watch balance and get the amount of funds available for trading or funds locked in orders
454
+ :see: https://www.bitmex.com/app/wsAPI#Subscriptions
452
455
  :param dict [params]: extra parameters specific to the exchange API endpoint
453
456
  :returns dict: a `balance structure <https://docs.ccxt.com/#/?id=balance-structure>`
454
457
  """
@@ -651,6 +654,7 @@ class bitmex(ccxt.async_support.bitmex):
651
654
  async def watch_trades(self, symbol: str, since: Int = None, limit: Int = None, params={}) -> List[Trade]:
652
655
  """
653
656
  get the list of most recent trades for a particular symbol
657
+ :see: https://www.bitmex.com/app/wsAPI#Subscriptions
654
658
  :param str symbol: unified symbol of the market to fetch trades for
655
659
  :param int [since]: timestamp in ms of the earliest trade to fetch
656
660
  :param int [limit]: the maximum amount of trades to fetch
@@ -697,8 +701,8 @@ class bitmex(ccxt.async_support.bitmex):
697
701
 
698
702
  async def watch_positions(self, symbols: Strings = None, since: Int = None, limit: Int = None, params={}) -> List[Position]:
699
703
  """
700
- :see: https://www.bitmex.com/app/wsAPI
701
704
  watch all open positions
705
+ :see: https://www.bitmex.com/app/wsAPI#Subscriptions
702
706
  :param str[]|None symbols: list of unified market symbols
703
707
  :param dict params: extra parameters specific to the exchange API endpoint
704
708
  :returns dict[]: a list of `position structure <https://docs.ccxt.com/en/latest/manual.html#position-structure>`
@@ -894,6 +898,7 @@ class bitmex(ccxt.async_support.bitmex):
894
898
  async def watch_orders(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}) -> List[Order]:
895
899
  """
896
900
  watches information on multiple orders made by the user
901
+ :see: https://www.bitmex.com/app/wsAPI#Subscriptions
897
902
  :param str symbol: unified market symbol of the market orders were made in
898
903
  :param int [since]: the earliest time in ms to fetch orders for
899
904
  :param int [limit]: the maximum number of order structures to retrieve
@@ -1100,6 +1105,7 @@ class bitmex(ccxt.async_support.bitmex):
1100
1105
  async def watch_my_trades(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}) -> List[Trade]:
1101
1106
  """
1102
1107
  watches information on multiple trades made by the user
1108
+ :see: https://www.bitmex.com/app/wsAPI#Subscriptions
1103
1109
  :param str symbol: unified market symbol of the market trades were made in
1104
1110
  :param int [since]: the earliest time in ms to fetch trades for
1105
1111
  :param int [limit]: the maximum number of trade structures to retrieve
@@ -1209,6 +1215,7 @@ class bitmex(ccxt.async_support.bitmex):
1209
1215
  async def watch_order_book(self, symbol: str, limit: Int = None, params={}) -> OrderBook:
1210
1216
  """
1211
1217
  watches information on open orders with bid(buy) and ask(sell) prices, volumes and other data
1218
+ :see: https://www.bitmex.com/app/wsAPI#OrderBookL2
1212
1219
  :param str symbol: unified symbol of the market to fetch the order book for
1213
1220
  :param int [limit]: the maximum amount of order book entries to return
1214
1221
  :param dict [params]: extra parameters specific to the exchange API endpoint
@@ -1219,6 +1226,7 @@ class bitmex(ccxt.async_support.bitmex):
1219
1226
  async def watch_order_book_for_symbols(self, symbols: List[str], limit: Int = None, params={}) -> OrderBook:
1220
1227
  """
1221
1228
  watches information on open orders with bid(buy) and ask(sell) prices, volumes and other data
1229
+ :see: https://www.bitmex.com/app/wsAPI#OrderBookL2
1222
1230
  :param str[] symbols: unified array of symbols
1223
1231
  :param int [limit]: the maximum amount of order book entries to return
1224
1232
  :param dict [params]: extra parameters specific to the exchange API endpoint
@@ -1255,6 +1263,7 @@ class bitmex(ccxt.async_support.bitmex):
1255
1263
  async def watch_trades_for_symbols(self, symbols: List[str], since: Int = None, limit: Int = None, params={}) -> List[Trade]:
1256
1264
  """
1257
1265
  get the list of most recent trades for a list of symbols
1266
+ :see: https://www.bitmex.com/app/wsAPI#Subscriptions
1258
1267
  :param str[] symbols: unified symbol of the market to fetch trades for
1259
1268
  :param int [since]: timestamp in ms of the earliest trade to fetch
1260
1269
  :param int [limit]: the maximum amount of trades to fetch
@@ -1288,6 +1297,7 @@ class bitmex(ccxt.async_support.bitmex):
1288
1297
  async def watch_ohlcv(self, symbol: str, timeframe='1m', since: Int = None, limit: Int = None, params={}) -> List[list]:
1289
1298
  """
1290
1299
  watches historical candlestick data containing the open, high, low, and close price, and the volume of a market
1300
+ :see: https://www.bitmex.com/app/wsAPI#Subscriptions
1291
1301
  :param str symbol: unified symbol of the market to fetch OHLCV data for
1292
1302
  :param str timeframe: the length of time each candle represents
1293
1303
  :param int [since]: timestamp in ms of the earliest candle to fetch
ccxt/pro/bybit.py CHANGED
@@ -15,7 +15,6 @@ from ccxt.base.errors import ExchangeError
15
15
  from ccxt.base.errors import AuthenticationError
16
16
  from ccxt.base.errors import ArgumentsRequired
17
17
  from ccxt.base.errors import BadRequest
18
- from ccxt.base.errors import UnsubscribeError
19
18
 
20
19
 
21
20
  class bybit(ccxt.async_support.bybit):
@@ -953,7 +952,7 @@ class bybit(ccxt.async_support.bybit):
953
952
  messageHash = 'unsubscribe:trade:' + symbol
954
953
  messageHashes.append(messageHash)
955
954
  subMessageHashes.append('trade:' + symbol)
956
- return await self.un_watch_topics(url, 'trade', symbols, messageHashes, subMessageHashes, topics, params)
955
+ return await self.un_watch_topics(url, 'trades', symbols, messageHashes, subMessageHashes, topics, params)
957
956
 
958
957
  async def un_watch_trades(self, symbol: str, params={}) -> Any:
959
958
  """
@@ -2310,44 +2309,6 @@ class bybit(ccxt.async_support.bybit):
2310
2309
  for j in range(0, len(messageHashes)):
2311
2310
  unsubHash = messageHashes[j]
2312
2311
  subHash = subMessageHashes[j]
2313
- if unsubHash in client.subscriptions:
2314
- del client.subscriptions[unsubHash]
2315
- if subHash in client.subscriptions:
2316
- del client.subscriptions[subHash]
2317
- error = UnsubscribeError(self.id + ' ' + messageHash)
2318
- client.reject(error, subHash)
2319
- client.resolve(True, unsubHash)
2312
+ self.clean_unsubscription(client, subHash, unsubHash)
2320
2313
  self.clean_cache(subscription)
2321
2314
  return message
2322
-
2323
- def clean_cache(self, subscription: dict):
2324
- topic = self.safe_string(subscription, 'topic')
2325
- symbols = self.safe_list(subscription, 'symbols', [])
2326
- symbolsLength = len(symbols)
2327
- if topic == 'ohlcv':
2328
- symbolsAndTimeFrames = self.safe_list(subscription, 'symbolsAndTimeframes', [])
2329
- for i in range(0, len(symbolsAndTimeFrames)):
2330
- symbolAndTimeFrame = symbolsAndTimeFrames[i]
2331
- symbol = self.safe_string(symbolAndTimeFrame, 0)
2332
- timeframe = self.safe_string(symbolAndTimeFrame, 1)
2333
- del self.ohlcvs[symbol][timeframe]
2334
- elif symbolsLength > 0:
2335
- for i in range(0, len(symbols)):
2336
- symbol = symbols[i]
2337
- if topic == 'trade':
2338
- del self.trades[symbol]
2339
- elif topic == 'orderbook':
2340
- del self.orderbooks[symbol]
2341
- elif topic == 'ticker':
2342
- del self.tickers[symbol]
2343
- else:
2344
- if topic == 'myTrades':
2345
- # don't reset self.myTrades directly here
2346
- # because in c# we need to use a different object
2347
- keys = list(self.myTrades.keys())
2348
- for i in range(0, len(keys)):
2349
- del self.myTrades[keys[i]]
2350
- elif topic == 'orders':
2351
- orderSymbols = list(self.orders.keys())
2352
- for i in range(0, len(orderSymbols)):
2353
- del self.orders[orderSymbols[i]]
ccxt/pro/cryptocom.py CHANGED
@@ -14,7 +14,6 @@ from ccxt.base.errors import ExchangeError
14
14
  from ccxt.base.errors import AuthenticationError
15
15
  from ccxt.base.errors import NetworkError
16
16
  from ccxt.base.errors import ChecksumError
17
- from ccxt.base.errors import UnsubscribeError
18
17
 
19
18
 
20
19
  class cryptocom(ccxt.async_support.cryptocom):
@@ -349,7 +348,7 @@ class cryptocom(ccxt.async_support.cryptocom):
349
348
  currentTopic = 'trade' + '.' + market['id']
350
349
  messageHashes.append('unsubscribe:trades:' + market['symbol'])
351
350
  topics.append(currentTopic)
352
- return await self.un_watch_public_multiple('trade', symbols, messageHashes, topics, topics, params)
351
+ return await self.un_watch_public_multiple('trades', symbols, messageHashes, topics, topics, params)
353
352
 
354
353
  def handle_trades(self, client: Client, message):
355
354
  #
@@ -1118,33 +1117,5 @@ class cryptocom(ccxt.async_support.cryptocom):
1118
1117
  for j in range(0, len(messageHashes)):
1119
1118
  unsubHash = messageHashes[j]
1120
1119
  subHash = subMessageHashes[j]
1121
- if unsubHash in client.subscriptions:
1122
- del client.subscriptions[unsubHash]
1123
- if subHash in client.subscriptions:
1124
- del client.subscriptions[subHash]
1125
- error = UnsubscribeError(self.id + ' ' + subHash)
1126
- client.reject(error, subHash)
1127
- client.resolve(True, unsubHash)
1120
+ self.clean_unsubscription(client, subHash, unsubHash)
1128
1121
  self.clean_cache(subscription)
1129
-
1130
- def clean_cache(self, subscription: dict):
1131
- topic = self.safe_string(subscription, 'topic')
1132
- symbols = self.safe_list(subscription, 'symbols', [])
1133
- symbolsLength = len(symbols)
1134
- if topic == 'ohlcv':
1135
- symbolsAndTimeFrames = self.safe_list(subscription, 'symbolsAndTimeframes', [])
1136
- for i in range(0, len(symbolsAndTimeFrames)):
1137
- symbolAndTimeFrame = symbolsAndTimeFrames[i]
1138
- symbol = self.safe_string(symbolAndTimeFrame, 0)
1139
- timeframe = self.safe_string(symbolAndTimeFrame, 1)
1140
- if timeframe in self.ohlcvs[symbol]:
1141
- del self.ohlcvs[symbol][timeframe]
1142
- elif symbolsLength > 0:
1143
- for i in range(0, len(symbols)):
1144
- symbol = symbols[i]
1145
- if topic == 'trade':
1146
- del self.trades[symbol]
1147
- elif topic == 'orderbook':
1148
- del self.orderbooks[symbol]
1149
- elif topic == 'ticker':
1150
- del self.tickers[symbol]
ccxt/pro/gate.py CHANGED
@@ -16,7 +16,6 @@ from ccxt.base.errors import ArgumentsRequired
16
16
  from ccxt.base.errors import BadRequest
17
17
  from ccxt.base.errors import NotSupported
18
18
  from ccxt.base.errors import ChecksumError
19
- from ccxt.base.errors import UnsubscribeError
20
19
  from ccxt.base.precise import Precise
21
20
 
22
21
 
@@ -1539,13 +1538,7 @@ class gate(ccxt.async_support.gate):
1539
1538
  for j in range(0, len(messageHashes)):
1540
1539
  unsubHash = messageHashes[j]
1541
1540
  subHash = subMessageHashes[j]
1542
- if unsubHash in client.subscriptions:
1543
- del client.subscriptions[unsubHash]
1544
- if subHash in client.subscriptions:
1545
- del client.subscriptions[subHash]
1546
- error = UnsubscribeError(self.id + ' ' + messageHash)
1547
- client.reject(error, subHash)
1548
- client.resolve(True, unsubHash)
1541
+ self.clean_unsubscription(client, subHash, unsubHash)
1549
1542
  self.clean_cache(subscription)
1550
1543
 
1551
1544
  def clean_cache(self, subscription: dict):
ccxt/pro/hyperliquid.py CHANGED
@@ -10,7 +10,6 @@ from ccxt.async_support.base.ws.client import Client
10
10
  from typing import List
11
11
  from typing import Any
12
12
  from ccxt.base.errors import ExchangeError
13
- from ccxt.base.errors import UnsubscribeError
14
13
 
15
14
 
16
15
  class hyperliquid(ccxt.async_support.hyperliquid):
@@ -805,13 +804,7 @@ class hyperliquid(ccxt.async_support.hyperliquid):
805
804
  symbol = self.safe_symbol(marketId)
806
805
  subMessageHash = 'orderbook:' + symbol
807
806
  messageHash = 'unsubscribe:' + subMessageHash
808
- if messageHash in client.subscriptions:
809
- del client.subscriptions[messageHash]
810
- if subMessageHash in client.subscriptions:
811
- del client.subscriptions[subMessageHash]
812
- error = UnsubscribeError(self.id + ' ' + subMessageHash)
813
- client.reject(error, subMessageHash)
814
- client.resolve(True, messageHash)
807
+ self.clean_unsubscription(client, subMessageHash, messageHash)
815
808
  if symbol in self.orderbooks:
816
809
  del self.orderbooks[symbol]
817
810
 
@@ -822,13 +815,7 @@ class hyperliquid(ccxt.async_support.hyperliquid):
822
815
  symbol = self.safe_symbol(marketId)
823
816
  subMessageHash = 'trade:' + symbol
824
817
  messageHash = 'unsubscribe:' + subMessageHash
825
- if messageHash in client.subscriptions:
826
- del client.subscriptions[messageHash]
827
- if subMessageHash in client.subscriptions:
828
- del client.subscriptions[subMessageHash]
829
- error = UnsubscribeError(self.id + ' ' + subMessageHash)
830
- client.reject(error, subMessageHash)
831
- client.resolve(True, messageHash)
818
+ self.clean_unsubscription(client, subMessageHash, messageHash)
832
819
  if symbol in self.trades:
833
820
  del self.trades[symbol]
834
821
 
@@ -836,13 +823,7 @@ class hyperliquid(ccxt.async_support.hyperliquid):
836
823
  #
837
824
  subMessageHash = 'tickers'
838
825
  messageHash = 'unsubscribe:' + subMessageHash
839
- if messageHash in client.subscriptions:
840
- del client.subscriptions[messageHash]
841
- if subMessageHash in client.subscriptions:
842
- del client.subscriptions[subMessageHash]
843
- error = UnsubscribeError(self.id + ' ' + subMessageHash)
844
- client.reject(error, subMessageHash)
845
- client.resolve(True, messageHash)
826
+ self.clean_unsubscription(client, subMessageHash, messageHash)
846
827
  symbols = list(self.tickers.keys())
847
828
  for i in range(0, len(symbols)):
848
829
  del self.tickers[symbols[i]]
@@ -855,13 +836,7 @@ class hyperliquid(ccxt.async_support.hyperliquid):
855
836
  timeframe = self.find_timeframe(interval)
856
837
  subMessageHash = 'candles:' + timeframe + ':' + symbol
857
838
  messageHash = 'unsubscribe:' + subMessageHash
858
- if messageHash in client.subscriptions:
859
- del client.subscriptions[messageHash]
860
- if subMessageHash in client.subscriptions:
861
- del client.subscriptions[subMessageHash]
862
- error = UnsubscribeError(self.id + ' ' + subMessageHash)
863
- client.reject(error, subMessageHash)
864
- client.resolve(True, messageHash)
839
+ self.clean_unsubscription(client, subMessageHash, messageHash)
865
840
  if symbol in self.ohlcvs:
866
841
  if timeframe in self.ohlcvs[symbol]:
867
842
  del self.ohlcvs[symbol][timeframe]
ccxt/pro/kucoin.py CHANGED
@@ -11,7 +11,6 @@ from typing import List
11
11
  from typing import Any
12
12
  from ccxt.base.errors import ExchangeError
13
13
  from ccxt.base.errors import ArgumentsRequired
14
- from ccxt.base.errors import UnsubscribeError
15
14
 
16
15
 
17
16
  class kucoin(ccxt.async_support.kucoin):
@@ -502,8 +501,6 @@ class kucoin(ccxt.async_support.kucoin):
502
501
  unWatches trades stream
503
502
  :see: https://www.kucoin.com/docs/websocket/spot-trading/public-channels/match-execution-data
504
503
  :param str symbol: unified symbol of the market to fetch trades for
505
- :param int [since]: timestamp in ms of the earliest trade to fetch
506
- :param int [limit]: the maximum amount of trades to fetch
507
504
  :param dict [params]: extra parameters specific to the exchange API endpoint
508
505
  :returns dict[]: a list of `trade structures <https://docs.ccxt.com/#/?id=public-trades>`
509
506
  """
@@ -851,46 +848,8 @@ class kucoin(ccxt.async_support.kucoin):
851
848
  for i in range(0, len(messageHashes)):
852
849
  messageHash = messageHashes[i]
853
850
  subHash = subMessageHashes[i]
854
- if messageHash in client.subscriptions:
855
- del client.subscriptions[messageHash]
856
- if subHash in client.subscriptions:
857
- del client.subscriptions[subHash]
858
- error = UnsubscribeError(self.id + ' ' + subHash)
859
- client.reject(error, subHash)
860
- client.resolve(True, messageHash)
861
- self.clean_cache(subscription)
862
-
863
- def clean_cache(self, subscription: dict):
864
- topic = self.safe_string(subscription, 'topic')
865
- symbols = self.safe_list(subscription, 'symbols', [])
866
- symbolsLength = len(symbols)
867
- if symbolsLength > 0:
868
- for i in range(0, len(symbols)):
869
- symbol = symbols[i]
870
- if topic == 'trades':
871
- if symbol in self.trades:
872
- del self.trades[symbol]
873
- elif topic == 'orderbook':
874
- if symbol in self.orderbooks:
875
- del self.orderbooks[symbol]
876
- elif topic == 'ticker':
877
- if symbol in self.tickers:
878
- del self.tickers[symbol]
879
- else:
880
- if topic == 'myTrades':
881
- # don't reset self.myTrades directly here
882
- # because in c# we need to use a different object
883
- keys = list(self.myTrades.keys())
884
- for i in range(0, len(keys)):
885
- del self.myTrades[keys[i]]
886
- elif topic == 'orders':
887
- orderSymbols = list(self.orders.keys())
888
- for i in range(0, len(orderSymbols)):
889
- del self.orders[orderSymbols[i]]
890
- elif topic == 'ticker':
891
- tickerSymbols = list(self.tickers.keys())
892
- for i in range(0, len(tickerSymbols)):
893
- del self.tickers[tickerSymbols[i]]
851
+ self.clean_unsubscription(client, subHash, messageHash)
852
+ self.clean_cache(subscription)
894
853
 
895
854
  def handle_system_status(self, client: Client, message):
896
855
  #