mexc-exchange-api 0.0.51__py3-none-any.whl → 0.0.53__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.

Potentially problematic release.


This version of mexc-exchange-api might be problematic. Click here for more details.

mexc/ccxt/base/types.py CHANGED
@@ -308,6 +308,9 @@ class Greeks(TypedDict):
308
308
  theta: Num
309
309
  vega: Num
310
310
  rho: Num
311
+ vanna: Num
312
+ volga: Num
313
+ charm: Num
311
314
  bidSize: Num
312
315
  askSize: Num
313
316
  bidImpliedVolatility: Num
mexc/ccxt/pro/mexc.py CHANGED
@@ -42,6 +42,12 @@ class mexc(mexcAsync):
42
42
  'watchBidsAsks': True,
43
43
  'watchTrades': True,
44
44
  'watchTradesForSymbols': False,
45
+ 'unWatchTicker': True,
46
+ 'unWatchTickers': True,
47
+ 'unWatchBidsAsks': True,
48
+ 'unWatchOHLCV': True,
49
+ 'unWatchOrderBook': True,
50
+ 'unWatchTrades': True,
45
51
  },
46
52
  'urls': {
47
53
  'api': {
@@ -474,12 +480,15 @@ class mexc(mexcAsync):
474
480
  }, market)
475
481
 
476
482
  async def watch_spot_public(self, channel, messageHash, params={}):
483
+ unsubscribed = self.safe_bool(params, 'unsubscribed', False)
484
+ params = self.omit(params, ['unsubscribed'])
477
485
  url = self.urls['api']['ws']['spot']
486
+ method = 'UNSUBSCRIPTION' if (unsubscribed) else 'SUBSCRIPTION'
478
487
  request: dict = {
479
- 'method': 'SUBSCRIPTION',
488
+ 'method': method,
480
489
  'params': [channel],
481
490
  }
482
- return await self.watch(url, messageHash, self.extend(request, params), channel)
491
+ return await self.watch(url, messageHash, self.extend(request, params), messageHash)
483
492
 
484
493
  async def watch_spot_private(self, channel, messageHash, params={}):
485
494
  self.check_required_credentials()
@@ -762,11 +771,6 @@ class mexc(mexcAsync):
762
771
  messageHash = 'orderbook:' + symbol
763
772
  subscription = self.safe_value(client.subscriptions, messageHash)
764
773
  limit = self.safe_integer(subscription, 'limit')
765
- if subscription is True:
766
- # we set client.subscriptions[messageHash] to 1
767
- # once we have received the first delta and initialized the orderbook
768
- client.subscriptions[messageHash] = 1
769
- self.orderbooks[symbol] = self.counted_order_book({})
770
774
  storedOrderBook = self.orderbooks[symbol]
771
775
  nonce = self.safe_integer(storedOrderBook, 'nonce')
772
776
  if nonce is None:
@@ -1354,6 +1358,247 @@ class mexc(mexcAsync):
1354
1358
  self.balance[type] = self.safe_balance(self.balance[type])
1355
1359
  client.resolve(self.balance[type], messageHash)
1356
1360
 
1361
+ async def un_watch_ticker(self, symbol: str, params={}) -> Any:
1362
+ """
1363
+ unWatches a price ticker, a statistical calculation with the information calculated over the past 24 hours for all markets of a specific list
1364
+ :param str symbol: unified symbol of the market to fetch the ticker for
1365
+ :param dict [params]: extra parameters specific to the exchange API endpoint
1366
+ :returns dict: a `ticker structure <https://docs.ccxt.com/#/?id=ticker-structure>`
1367
+ """
1368
+ await self.load_markets()
1369
+ market = self.market(symbol)
1370
+ messageHash = 'unsubscribe:ticker:' + market['symbol']
1371
+ url = None
1372
+ channel = None
1373
+ if market['spot']:
1374
+ miniTicker = False
1375
+ miniTicker, params = self.handle_option_and_params(params, 'watchTicker', 'miniTicker')
1376
+ if miniTicker:
1377
+ channel = 'spot@public.miniTicker.v3.api@' + market['id'] + '@UTC+8'
1378
+ else:
1379
+ channel = 'spot@public.bookTicker.v3.api@' + market['id']
1380
+ url = self.urls['api']['ws']['spot']
1381
+ params['unsubscribed'] = True
1382
+ self.watch_spot_public(channel, messageHash, params)
1383
+ else:
1384
+ channel = 'unsub.ticker'
1385
+ requestParams: dict = {
1386
+ 'symbol': market['id'],
1387
+ }
1388
+ url = self.urls['api']['ws']['swap']
1389
+ self.watch_swap_public(channel, messageHash, requestParams, params)
1390
+ client = self.client(url)
1391
+ self.handle_unsubscriptions(client, [messageHash])
1392
+ return None
1393
+
1394
+ async def un_watch_tickers(self, symbols: Strings = None, params={}) -> Any:
1395
+ """
1396
+ unWatches a price ticker, a statistical calculation with the information calculated over the past 24 hours for all markets of a specific list
1397
+ :param str[] symbols: unified symbol of the market to fetch the ticker for
1398
+ :param dict [params]: extra parameters specific to the exchange API endpoint
1399
+ :returns dict: a `ticker structure <https://docs.ccxt.com/#/?id=ticker-structure>`
1400
+ """
1401
+ await self.load_markets()
1402
+ symbols = self.market_symbols(symbols, None)
1403
+ messageHashes = []
1404
+ firstSymbol = self.safe_string(symbols, 0)
1405
+ market = None
1406
+ if firstSymbol is not None:
1407
+ market = self.market(firstSymbol)
1408
+ type = None
1409
+ type, params = self.handle_market_type_and_params('watchTickers', market, params)
1410
+ isSpot = (type == 'spot')
1411
+ url = self.urls['api']['ws']['spot'] if (isSpot) else self.urls['api']['ws']['swap']
1412
+ request: dict = {}
1413
+ if isSpot:
1414
+ miniTicker = False
1415
+ miniTicker, params = self.handle_option_and_params(params, 'watchTickers', 'miniTicker')
1416
+ topics = []
1417
+ if not miniTicker:
1418
+ if symbols is None:
1419
+ raise ArgumentsRequired(self.id + ' watchTickers required symbols argument for the bookTicker channel')
1420
+ marketIds = self.market_ids(symbols)
1421
+ for i in range(0, len(marketIds)):
1422
+ marketId = marketIds[i]
1423
+ messageHashes.append('unsubscribe:ticker:' + symbols[i])
1424
+ channel = 'spot@public.bookTicker.v3.api@' + marketId
1425
+ topics.append(channel)
1426
+ else:
1427
+ topics.append('spot@public.miniTickers.v3.api@UTC+8')
1428
+ if symbols is None:
1429
+ messageHashes.append('unsubscribe:spot:ticker')
1430
+ else:
1431
+ for i in range(0, len(symbols)):
1432
+ messageHashes.append('unsubscribe:ticker:' + symbols[i])
1433
+ request['method'] = 'UNSUBSCRIPTION'
1434
+ request['params'] = topics
1435
+ else:
1436
+ request['method'] = 'unsub.tickers'
1437
+ request['params'] = {}
1438
+ messageHashes.append('unsubscribe:ticker')
1439
+ client = self.client(url)
1440
+ self.watch_multiple(url, messageHashes, self.extend(request, params), messageHashes)
1441
+ self.handle_unsubscriptions(client, messageHashes)
1442
+ return None
1443
+
1444
+ async def un_watch_bids_asks(self, symbols: Strings = None, params={}) -> Any:
1445
+ """
1446
+ unWatches best bid & ask for symbols
1447
+ :param str[] symbols: unified symbol of the market to fetch the ticker for
1448
+ :param dict [params]: extra parameters specific to the exchange API endpoint
1449
+ :returns dict: a `ticker structure <https://docs.ccxt.com/#/?id=ticker-structure>`
1450
+ """
1451
+ await self.load_markets()
1452
+ symbols = self.market_symbols(symbols, None, True, False, True)
1453
+ marketType = None
1454
+ if symbols is None:
1455
+ raise ArgumentsRequired(self.id + ' watchBidsAsks required symbols argument')
1456
+ markets = self.markets_for_symbols(symbols)
1457
+ marketType, params = self.handle_market_type_and_params('watchBidsAsks', markets[0], params)
1458
+ isSpot = marketType == 'spot'
1459
+ if not isSpot:
1460
+ raise NotSupported(self.id + ' watchBidsAsks only support spot market')
1461
+ messageHashes = []
1462
+ topics = []
1463
+ for i in range(0, len(symbols)):
1464
+ if isSpot:
1465
+ market = self.market(symbols[i])
1466
+ topics.append('spot@public.bookTicker.v3.api@' + market['id'])
1467
+ messageHashes.append('unsubscribe:bidask:' + symbols[i])
1468
+ url = self.urls['api']['ws']['spot']
1469
+ request: dict = {
1470
+ 'method': 'UNSUBSCRIPTION',
1471
+ 'params': topics,
1472
+ }
1473
+ client = self.client(url)
1474
+ self.watch_multiple(url, messageHashes, self.extend(request, params), messageHashes)
1475
+ self.handle_unsubscriptions(client, messageHashes)
1476
+ return None
1477
+
1478
+ async def un_watch_ohlcv(self, symbol: str, timeframe='1m', params={}) -> Any:
1479
+ """
1480
+ unWatches historical candlestick data containing the open, high, low, and close price, and the volume of a market
1481
+ :param str symbol: unified symbol of the market to fetch OHLCV data for
1482
+ :param str timeframe: the length of time each candle represents
1483
+ :param dict [params]: extra parameters specific to the exchange API endpoint
1484
+ :param dict [params.timezone]: if provided, kline intervals are interpreted in that timezone instead of UTC, example '+08:00'
1485
+ :returns int[][]: A list of candles ordered, open, high, low, close, volume
1486
+ """
1487
+ await self.load_markets()
1488
+ market = self.market(symbol)
1489
+ symbol = market['symbol']
1490
+ timeframes = self.safe_value(self.options, 'timeframes', {})
1491
+ timeframeId = self.safe_string(timeframes, timeframe)
1492
+ messageHash = 'unsubscribe:candles:' + symbol + ':' + timeframe
1493
+ url = None
1494
+ if market['spot']:
1495
+ url = self.urls['api']['ws']['spot']
1496
+ channel = 'spot@public.kline.v3.api@' + market['id'] + '@' + timeframeId
1497
+ params['unsubscribed'] = True
1498
+ self.watch_spot_public(channel, messageHash, params)
1499
+ else:
1500
+ url = self.urls['api']['ws']['swap']
1501
+ channel = 'unsub.kline'
1502
+ requestParams: dict = {
1503
+ 'symbol': market['id'],
1504
+ 'interval': timeframeId,
1505
+ }
1506
+ self.watch_swap_public(channel, messageHash, requestParams, params)
1507
+ client = self.client(url)
1508
+ self.handle_unsubscriptions(client, [messageHash])
1509
+ return None
1510
+
1511
+ async def un_watch_order_book(self, symbol: str, params={}) -> Any:
1512
+ """
1513
+ unWatches information on open orders with bid(buy) and ask(sell) prices, volumes and other data
1514
+ :param str symbol: unified array of symbols
1515
+ :param dict [params]: extra parameters specific to the exchange API endpoint
1516
+ :returns dict: A dictionary of `order book structures <https://docs.ccxt.com/#/?id=order-book-structure>` indexed by market symbols
1517
+ """
1518
+ await self.load_markets()
1519
+ market = self.market(symbol)
1520
+ symbol = market['symbol']
1521
+ messageHash = 'unsubscribe:orderbook:' + symbol
1522
+ url = None
1523
+ if market['spot']:
1524
+ url = self.urls['api']['ws']['spot']
1525
+ channel = 'spot@public.increase.depth.v3.api@' + market['id']
1526
+ params['unsubscribed'] = True
1527
+ self.watch_spot_public(channel, messageHash, params)
1528
+ else:
1529
+ url = self.urls['api']['ws']['swap']
1530
+ channel = 'unsub.depth'
1531
+ requestParams: dict = {
1532
+ 'symbol': market['id'],
1533
+ }
1534
+ self.watch_swap_public(channel, messageHash, requestParams, params)
1535
+ client = self.client(url)
1536
+ self.handle_unsubscriptions(client, [messageHash])
1537
+ return None
1538
+
1539
+ async def un_watch_trades(self, symbol: str, params={}) -> Any:
1540
+ """
1541
+ unsubscribes from the trades channel
1542
+ :param str symbol: unified symbol of the market to fetch trades for
1543
+ :param dict [params]: extra parameters specific to the exchange API endpoint
1544
+ :param str [params.name]: the name of the method to call, 'trade' or 'aggTrade', default is 'trade'
1545
+ :returns dict[]: a list of `trade structures <https://docs.ccxt.com/#/?id=public-trades>`
1546
+ """
1547
+ await self.load_markets()
1548
+ market = self.market(symbol)
1549
+ symbol = market['symbol']
1550
+ messageHash = 'unsubscribe:trades:' + symbol
1551
+ url = None
1552
+ if market['spot']:
1553
+ url = self.urls['api']['ws']['spot']
1554
+ channel = 'spot@public.deals.v3.api@' + market['id']
1555
+ params['unsubscribed'] = True
1556
+ self.watch_spot_public(channel, messageHash, params)
1557
+ else:
1558
+ url = self.urls['api']['ws']['swap']
1559
+ channel = 'unsub.deal'
1560
+ requestParams: dict = {
1561
+ 'symbol': market['id'],
1562
+ }
1563
+ self.watch_swap_public(channel, messageHash, requestParams, params)
1564
+ client = self.client(url)
1565
+ self.handle_unsubscriptions(client, [messageHash])
1566
+ return None
1567
+
1568
+ def handle_unsubscriptions(self, client: Client, messageHashes: List[str]):
1569
+ for i in range(0, len(messageHashes)):
1570
+ messageHash = messageHashes[i]
1571
+ subMessageHash = messageHash.replace('unsubscribe:', '')
1572
+ self.clean_unsubscription(client, subMessageHash, messageHash)
1573
+ if messageHash.find('ticker') >= 0:
1574
+ symbol = messageHash.replace('unsubscribe:ticker:', '')
1575
+ if symbol.find('unsubscribe') >= 0:
1576
+ # unWatchTickers
1577
+ symbols = list(self.tickers.keys())
1578
+ for j in range(0, len(symbols)):
1579
+ del self.tickers[symbols[j]]
1580
+ elif symbol in self.tickers:
1581
+ del self.tickers[symbol]
1582
+ elif messageHash.find('bidask') >= 0:
1583
+ symbol = messageHash.replace('unsubscribe:bidask:', '')
1584
+ if symbol in self.bidsasks:
1585
+ del self.bidsasks[symbol]
1586
+ elif messageHash.find('candles') >= 0:
1587
+ splitHashes = messageHash.split(':')
1588
+ symbol = self.safe_string(splitHashes, 2)
1589
+ if len(splitHashes) > 4:
1590
+ symbol += ':' + self.safe_string(splitHashes, 3)
1591
+ if symbol in self.ohlcvs:
1592
+ del self.ohlcvs[symbol]
1593
+ elif messageHash.find('orderbook') >= 0:
1594
+ symbol = messageHash.replace('unsubscribe:orderbook:', '')
1595
+ if symbol in self.orderbooks:
1596
+ del self.orderbooks[symbol]
1597
+ elif messageHash.find('trades') >= 0:
1598
+ symbol = messageHash.replace('unsubscribe:trades:', '')
1599
+ if symbol in self.trades:
1600
+ del self.trades[symbol]
1601
+
1357
1602
  async def authenticate(self, subscriptionHash, params={}):
1358
1603
  # we only need one listenKey since ccxt shares connections
1359
1604
  listenKey = self.safe_string(self.options, 'listenKey')
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mexc-exchange-api
3
- Version: 0.0.51
3
+ Version: 0.0.53
4
4
  Summary: mexc crypto exchange api client
5
5
  Project-URL: Homepage, https://github.com/ccxt/ccxt
6
6
  Project-URL: Issues, https://github.com/ccxt/ccxt
@@ -390,6 +390,12 @@ You can also construct custom requests to available "implicit" endpoints
390
390
  - `watch_my_trades(self, symbol: Str = None, since: Int = None, limit: Int = None, params={})`
391
391
  - `watch_orders(self, symbol: Str = None, since: Int = None, limit: Int = None, params={})`
392
392
  - `watch_balance(self, params={})`
393
+ - `un_watch_ticker(self, symbol: str, params={})`
394
+ - `un_watch_tickers(self, symbols: Strings = None, params={})`
395
+ - `un_watch_bids_asks(self, symbols: Strings = None, params={})`
396
+ - `un_watch_ohlcv(self, symbol: str, timeframe='1m', params={})`
397
+ - `un_watch_order_book(self, symbol: str, params={})`
398
+ - `un_watch_trades(self, symbol: str, params={})`
393
399
  - `authenticate(self, subscriptionHash, params={})`
394
400
  - `keep_alive_listen_key(self, listenKey, params={})`
395
401
 
@@ -21,9 +21,9 @@ mexc/ccxt/base/decimal_to_precision.py,sha256=fgWRBzRTtsf3r2INyS4f7WHlzgjB5YM1ek
21
21
  mexc/ccxt/base/errors.py,sha256=MvCrL_sAM3de616T6RE0PSxiF2xV6Qqz5b1y1ghidbk,4888
22
22
  mexc/ccxt/base/exchange.py,sha256=1y1XgdaAMiN5CyMzmwFXi-qEm3-94gOFaq7m7eyowEw,327221
23
23
  mexc/ccxt/base/precise.py,sha256=koce64Yrp6vFbGijJtUt-QQ6XhJgeGTCksZ871FPp_A,8886
24
- mexc/ccxt/base/types.py,sha256=SfxIKDSsxP7MPHWiOVI965Nr5NSEPpAno5fuveTRi3w,11423
24
+ mexc/ccxt/base/types.py,sha256=IbLO7Ni-plO36xlOdJQFqujSJBq0q9qll009ShZ0M_U,11468
25
25
  mexc/ccxt/pro/__init__.py,sha256=vsCUt_zMlU-fXzdpZdFliB61_WB-j9fQR9PMjTMB4dk,615
26
- mexc/ccxt/pro/mexc.py,sha256=SRaTTx4D4OcZi5Im9wBm6Rh54vZCxeeAcC5rK6NB3wk,56535
26
+ mexc/ccxt/pro/mexc.py,sha256=xn1Xg9a9pV3Axy3zKV46kXMec20tQl7EKuuC9SrpBsw,68511
27
27
  mexc/ccxt/static_dependencies/README.md,sha256=3TCvhhn09_Cqf9BDDpao1V7EfKHDpQ6k9oWRsLFixpU,18
28
28
  mexc/ccxt/static_dependencies/__init__.py,sha256=tzFje8cloqmiIE6kola3EaYC0SnD1izWnri69hzHsSw,168
29
29
  mexc/ccxt/static_dependencies/ecdsa/__init__.py,sha256=Xaj0G79BLtBt2YZcOOMV8qOlQZ7fIJznNiHhiEEZfQA,594
@@ -283,6 +283,6 @@ mexc/ccxt/static_dependencies/toolz/curried/exceptions.py,sha256=gKFOHDIayAWnX2u
283
283
  mexc/ccxt/static_dependencies/toolz/curried/operator.py,sha256=ML92mknkAwzBl2NCm-4werSUmJEtSHNY9NSzhseNM9s,525
284
284
  mexc/ccxt/static_dependencies/typing_inspect/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
285
285
  mexc/ccxt/static_dependencies/typing_inspect/typing_inspect.py,sha256=5gIWomLPfuDpgd3gX1GlnX0MuXM3VorR4j2W2qXORiQ,28269
286
- mexc_exchange_api-0.0.51.dist-info/METADATA,sha256=mmBvirageCwgUm6amxmeRtSNn-Rk_CK3tFlfQEPyU-4,17847
287
- mexc_exchange_api-0.0.51.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
288
- mexc_exchange_api-0.0.51.dist-info/RECORD,,
286
+ mexc_exchange_api-0.0.53.dist-info/METADATA,sha256=9-hd0tNEp782c8Vq08RN42Q11Qcc8enVZjd87r5EKfc,18194
287
+ mexc_exchange_api-0.0.53.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
288
+ mexc_exchange_api-0.0.53.dist-info/RECORD,,