mexc-exchange-api 0.0.75__py3-none-any.whl → 0.0.77__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.
mexc/ccxt/__init__.py CHANGED
@@ -26,7 +26,7 @@ sys.modules['ccxt'] = ccxt_module
26
26
 
27
27
  # ----------------------------------------------------------------------------
28
28
 
29
- __version__ = '4.4.95'
29
+ __version__ = '4.4.96'
30
30
 
31
31
  # ----------------------------------------------------------------------------
32
32
 
@@ -8,7 +8,7 @@ sys.modules['ccxt'] = ccxt_module
8
8
 
9
9
  # -----------------------------------------------------------------------------
10
10
 
11
- __version__ = '4.4.95'
11
+ __version__ = '4.4.96'
12
12
 
13
13
  # -----------------------------------------------------------------------------
14
14
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  # -----------------------------------------------------------------------------
4
4
 
5
- __version__ = '4.4.95'
5
+ __version__ = '4.4.96'
6
6
 
7
7
  # -----------------------------------------------------------------------------
8
8
 
@@ -231,6 +231,8 @@ class Exchange(BaseExchange):
231
231
  self.last_json_response = json_response
232
232
  if self.verbose:
233
233
  self.log("\nfetch Response:", self.id, method, url, http_status_code, "ResponseHeaders:", headers, "ResponseBody:", http_response)
234
+ if json_response and not isinstance(json_response, list) and self.returnResponseHeaders:
235
+ json_response['responseHeaders'] = headers
234
236
  self.logger.debug("%s %s, Response: %s %s %s", method, url, http_status_code, headers, http_response)
235
237
 
236
238
  except socket.gaierror as e:
@@ -668,6 +670,9 @@ class Exchange(BaseExchange):
668
670
  async def un_watch_order_book_for_symbols(self, symbols: List[str], params={}):
669
671
  raise NotSupported(self.id + ' unWatchOrderBookForSymbols() is not supported yet')
670
672
 
673
+ async def un_watch_positions(self, symbols: Strings = None, params={}):
674
+ raise NotSupported(self.id + ' unWatchPositions() is not supported yet')
675
+
671
676
  async def fetch_deposit_addresses(self, codes: Strings = None, params={}):
672
677
  raise NotSupported(self.id + ' fetchDepositAddresses() is not supported yet')
673
678
 
@@ -1596,10 +1601,10 @@ class Exchange(BaseExchange):
1596
1601
  """
1597
1602
  raise NotSupported(self.id + ' fetchDepositsWithdrawals() is not supported yet')
1598
1603
 
1599
- async def fetch_deposits(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
1604
+ async def fetch_deposits(self, code: Str = None, since: Int = None, limit: Int = None, params={}):
1600
1605
  raise NotSupported(self.id + ' fetchDeposits() is not supported yet')
1601
1606
 
1602
- async def fetch_withdrawals(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
1607
+ async def fetch_withdrawals(self, code: Str = None, since: Int = None, limit: Int = None, params={}):
1603
1608
  raise NotSupported(self.id + ' fetchWithdrawals() is not supported yet')
1604
1609
 
1605
1610
  async def fetch_deposits_ws(self, code: Str = None, since: Int = None, limit: Int = None, params={}):
@@ -1892,7 +1897,7 @@ class Exchange(BaseExchange):
1892
1897
  calls = 0
1893
1898
  result = []
1894
1899
  errors = 0
1895
- until = self.safe_integer_2(params, 'untill', 'till') # do not omit it from params here
1900
+ until = self.safe_integer_n(params, ['until', 'untill', 'till']) # do not omit it from params here
1896
1901
  maxEntriesPerRequest, params = self.handle_max_entries_per_request_and_params(method, maxEntriesPerRequest, params)
1897
1902
  if (paginationDirection == 'forward'):
1898
1903
  if since is None:
@@ -1,6 +1,8 @@
1
1
  import asyncio
2
2
 
3
-
3
+ # Test by running:
4
+ # - python python/ccxt/pro/test/base/test_close.py
5
+ # - python python/ccxt/pro/test/base/test_future.py
4
6
  class Future(asyncio.Future):
5
7
 
6
8
  def resolve(self, result=None):
@@ -30,14 +32,14 @@ class Future(asyncio.Future):
30
32
  if err:
31
33
  exceptions.append(err)
32
34
  # if any exceptions return with first exception
35
+ if future.cancelled():
36
+ return
33
37
  if len(exceptions) > 0:
34
38
  future.set_exception(exceptions[0])
35
39
  # else return first result
36
40
  elif cancelled:
37
41
  future.cancel()
38
42
  else:
39
- if future.cancelled():
40
- return
41
43
  first_result = list(complete)[0].result()
42
44
  future.set_result(first_result)
43
45
  task.add_done_callback(callback)
@@ -449,6 +449,7 @@ class mexc(Exchange, ImplicitAPI):
449
449
  },
450
450
  },
451
451
  },
452
+ 'useCcxtTradeId': True,
452
453
  'timeframes': {
453
454
  'spot': {
454
455
  '1m': '1m',
@@ -1695,8 +1696,8 @@ class mexc(Exchange, ImplicitAPI):
1695
1696
  'cost': self.safe_string(trade, 'commission'),
1696
1697
  'currency': self.safe_currency_code(feeAsset),
1697
1698
  }
1698
- if id is None:
1699
- id = self.synthetic_trade_id(market, timestamp, side, amountString, priceString, type, takerOrMaker)
1699
+ if id is None and self.safe_bool(self.options, 'useCcxtTradeId', True):
1700
+ id = self.create_ccxt_trade_id(timestamp, side, amountString, priceString, takerOrMaker)
1700
1701
  return self.safe_trade({
1701
1702
  'id': id,
1702
1703
  'order': orderId,
@@ -1713,23 +1714,6 @@ class mexc(Exchange, ImplicitAPI):
1713
1714
  'info': trade,
1714
1715
  }, market)
1715
1716
 
1716
- def synthetic_trade_id(self, market=None, timestamp=None, side=None, amount=None, price=None, orderType=None, takerOrMaker=None):
1717
- # TODO: can be unified method? self approach is being used by multiple exchanges(mexc, woo-coinsbit, dydx, ...)
1718
- id = ''
1719
- if timestamp is not None:
1720
- id = self.number_to_string(timestamp) + '-' + self.safe_string(market, 'id', '_')
1721
- if side is not None:
1722
- id += '-' + side
1723
- if amount is not None:
1724
- id += '-' + self.number_to_string(amount)
1725
- if price is not None:
1726
- id += '-' + self.number_to_string(price)
1727
- if takerOrMaker is not None:
1728
- id += '-' + takerOrMaker
1729
- if orderType is not None:
1730
- id += '-' + orderType
1731
- return id
1732
-
1733
1717
  async def fetch_ohlcv(self, symbol: str, timeframe='1m', since: Int = None, limit: Int = None, params={}) -> List[list]:
1734
1718
  """
1735
1719
 
@@ -4652,11 +4636,14 @@ class mexc(Exchange, ImplicitAPI):
4652
4636
  # "network": "TRX",
4653
4637
  # "status": "5",
4654
4638
  # "address": "TSMcEDDvkqY9dz8RkFnrS86U59GwEZjfvh",
4655
- # "txId": "51a8f49e6f03f2c056e71fe3291aa65e1032880be855b65cecd0595a1b8af95b",
4639
+ # "txId": "51a8f49e6f03f2c056e71fe3291aa65e1032880be855b65cecd0595a1b8af95b:0",
4656
4640
  # "insertTime": "1664805021000",
4657
4641
  # "unlockConfirm": "200",
4658
4642
  # "confirmTimes": "203",
4659
- # "memo": "xxyy1122"
4643
+ # "memo": "xxyy1122",
4644
+ # "transHash": "51a8f49e6f03f2c056e71fe3291aa65e1032880be855b65cecd0595a1b8af95b",
4645
+ # "updateTime": "1664805621000",
4646
+ # "netWork: "TRX"
4660
4647
  # }
4661
4648
  # ]
4662
4649
  #
@@ -4697,7 +4684,7 @@ class mexc(Exchange, ImplicitAPI):
4697
4684
  # [
4698
4685
  # {
4699
4686
  # "id": "adcd1c8322154de691b815eedcd10c42",
4700
- # "txId": "0xc8c918cd69b2246db493ef6225a72ffdc664f15b08da3e25c6879b271d05e9d0",
4687
+ # "txId": "0xc8c918cd69b2246db493ef6225a72ffdc664f15b08da3e25c6879b271d05e9d0:0",
4701
4688
  # "coin": "USDC-MATIC",
4702
4689
  # "network": "MATIC",
4703
4690
  # "address": "0xeE6C7a415995312ED52c53a0f8f03e165e0A5D62",
@@ -4708,7 +4695,11 @@ class mexc(Exchange, ImplicitAPI):
4708
4695
  # "confirmNo": null,
4709
4696
  # "applyTime": "1664882739000",
4710
4697
  # "remark": '',
4711
- # "memo": null
4698
+ # "memo": null,
4699
+ # "explorerUrl": "https://etherscan.io/tx/0xc8c918cd69b2246db493ef6225a72ffdc664f15b08da3e25c6879b271d05e9d0",
4700
+ # "transHash": "0xc8c918cd69b2246db493ef6225a72ffdc664f15b08da3e25c6879b271d05e9d0",
4701
+ # "updateTime": "1664882799000",
4702
+ # "netWork: "MATIC"
4712
4703
  # }
4713
4704
  # ]
4714
4705
  #
@@ -4724,18 +4715,21 @@ class mexc(Exchange, ImplicitAPI):
4724
4715
  # "network": "TRX",
4725
4716
  # "status": "5",
4726
4717
  # "address": "TSMcEDDvkqY9dz8RkFnrS86U59GwEZjfvh",
4727
- # "txId": "51a8f49e6f03f2c056e71fe3291aa65e1032880be855b65cecd0595a1b8af95b",
4718
+ # "txId": "51a8f49e6f03f2c056e71fe3291aa65e1032880be855b65cecd0595a1b8af95b:0",
4728
4719
  # "insertTime": "1664805021000",
4729
4720
  # "unlockConfirm": "200",
4730
4721
  # "confirmTimes": "203",
4731
- # "memo": "xxyy1122"
4722
+ # "memo": "xxyy1122",
4723
+ # "transHash": "51a8f49e6f03f2c056e71fe3291aa65e1032880be855b65cecd0595a1b8af95b",
4724
+ # "updateTime": "1664805621000",
4725
+ # "netWork: "TRX"
4732
4726
  # }
4733
4727
  #
4734
4728
  # fetchWithdrawals
4735
4729
  #
4736
4730
  # {
4737
4731
  # "id": "adcd1c8322154de691b815eedcd10c42",
4738
- # "txId": "0xc8c918cd69b2246db493ef6225a72ffdc664f15b08da3e25c6879b271d05e9d0",
4732
+ # "txId": "0xc8c918cd69b2246db493ef6225a72ffdc664f15b08da3e25c6879b271d05e9d0:0",
4739
4733
  # "coin": "USDC-MATIC",
4740
4734
  # "network": "MATIC",
4741
4735
  # "address": "0xeE6C7a415995312ED52c53a0f8f03e165e0A5D62",
@@ -4745,8 +4739,12 @@ class mexc(Exchange, ImplicitAPI):
4745
4739
  # "transactionFee": "1",
4746
4740
  # "confirmNo": null,
4747
4741
  # "applyTime": "1664882739000",
4748
- # "remark": '',
4749
- # "memo": null
4742
+ # "remark": "",
4743
+ # "memo": null,
4744
+ # "explorerUrl": "https://etherscan.io/tx/0xc8c918cd69b2246db493ef6225a72ffdc664f15b08da3e25c6879b271d05e9d0",
4745
+ # "transHash": "0xc8c918cd69b2246db493ef6225a72ffdc664f15b08da3e25c6879b271d05e9d0",
4746
+ # "updateTime": "1664882799000",
4747
+ # "netWork: "MATIC"
4750
4748
  # }
4751
4749
  #
4752
4750
  # withdraw
@@ -4758,6 +4756,7 @@ class mexc(Exchange, ImplicitAPI):
4758
4756
  id = self.safe_string(transaction, 'id')
4759
4757
  type = 'deposit' if (id is None) else 'withdrawal'
4760
4758
  timestamp = self.safe_integer_2(transaction, 'insertTime', 'applyTime')
4759
+ updated = self.safe_integer(transaction, 'updateTime')
4761
4760
  currencyId = None
4762
4761
  currencyWithNetwork = self.safe_string(transaction, 'coin')
4763
4762
  if currencyWithNetwork is not None:
@@ -4770,7 +4769,7 @@ class mexc(Exchange, ImplicitAPI):
4770
4769
  status = self.parse_transaction_status_by_type(self.safe_string(transaction, 'status'), type)
4771
4770
  amountString = self.safe_string(transaction, 'amount')
4772
4771
  address = self.safe_string(transaction, 'address')
4773
- txid = self.safe_string(transaction, 'txId')
4772
+ txid = self.safe_string_2(transaction, 'transHash', 'txId')
4774
4773
  fee = None
4775
4774
  feeCostString = self.safe_string(transaction, 'transactionFee')
4776
4775
  if feeCostString is not None:
@@ -4798,8 +4797,8 @@ class mexc(Exchange, ImplicitAPI):
4798
4797
  'amount': self.parse_number(amountString),
4799
4798
  'currency': code,
4800
4799
  'status': status,
4801
- 'updated': None,
4802
- 'comment': None,
4800
+ 'updated': updated,
4801
+ 'comment': self.safe_string(transaction, 'remark'),
4803
4802
  'internal': None,
4804
4803
  'fee': fee,
4805
4804
  }
@@ -5705,7 +5704,7 @@ class mexc(Exchange, ImplicitAPI):
5705
5704
  #
5706
5705
  # {success: True, code: '0'}
5707
5706
  #
5708
- return self.parse_leverage(response, market)
5707
+ return self.parse_leverage(response, market) # tmp revert type
5709
5708
 
5710
5709
  def nonce(self):
5711
5710
  return self.milliseconds() - self.safe_integer(self.options, 'timeDifference', 0)
@@ -33,18 +33,24 @@ NO_PADDING = 5
33
33
  PAD_WITH_ZERO = 6
34
34
 
35
35
 
36
- def decimal_to_precision(n, rounding_mode=ROUND, precision=None, counting_mode=DECIMAL_PLACES, padding_mode=NO_PADDING):
37
- assert precision is not None
36
+ def decimal_to_precision(n, rounding_mode=ROUND, numPrecisionDigits=None, counting_mode=DECIMAL_PLACES, padding_mode=NO_PADDING):
37
+ assert numPrecisionDigits is not None, 'numPrecisionDigits should not be None'
38
+
39
+ if isinstance(numPrecisionDigits, str):
40
+ numPrecisionDigits = float(numPrecisionDigits)
41
+ assert isinstance(numPrecisionDigits, float) or isinstance(numPrecisionDigits, decimal.Decimal) or isinstance(numPrecisionDigits, numbers.Integral), 'numPrecisionDigits has an invalid number'
42
+
38
43
  if counting_mode == TICK_SIZE:
39
- assert(isinstance(precision, float) or isinstance(precision, decimal.Decimal) or isinstance(precision, numbers.Integral) or isinstance(precision, str))
44
+ assert numPrecisionDigits > 0, 'negative or zero numPrecisionDigits can not be used with TICK_SIZE precisionMode'
40
45
  else:
41
- assert(isinstance(precision, numbers.Integral))
46
+ assert isinstance(numPrecisionDigits, numbers.Integral)
47
+
42
48
  assert rounding_mode in [TRUNCATE, ROUND]
43
49
  assert counting_mode in [DECIMAL_PLACES, SIGNIFICANT_DIGITS, TICK_SIZE]
44
50
  assert padding_mode in [NO_PADDING, PAD_WITH_ZERO]
51
+ # end of checks
45
52
 
46
- if isinstance(precision, str):
47
- precision = float(precision)
53
+ precision = numPrecisionDigits # "precision" variable name was in signature, but to make function signature similar to php/js, I had to change the argument name to "numPrecisionDigits". however, the below codes use "precision" variable name, so we have to assign that name here (you can change the usage of 'precision' variable name below everywhere, but i've refrained to do that to avoid many changes)
48
54
 
49
55
  context = decimal.getcontext()
50
56
 
@@ -78,12 +84,12 @@ def decimal_to_precision(n, rounding_mode=ROUND, precision=None, counting_mode=D
78
84
  if missing != 0:
79
85
  if rounding_mode == ROUND:
80
86
  if dec > 0:
81
- if missing >= precision / 2:
87
+ if missing >= precision_dec / 2:
82
88
  dec = dec - missing + precision_dec
83
89
  else:
84
90
  dec = dec - missing
85
91
  else:
86
- if missing >= precision / 2:
92
+ if missing >= precision_dec / 2:
87
93
  dec = dec + missing - precision_dec
88
94
  else:
89
95
  dec = dec + missing
@@ -117,7 +123,7 @@ def decimal_to_precision(n, rounding_mode=ROUND, precision=None, counting_mode=D
117
123
  precise = '{:f}'.format(min((below, above), key=lambda x: abs(x - dec)))
118
124
  else:
119
125
  precise = '{:f}'.format(dec.quantize(sigfig))
120
- if precise == ('-0.' + len(precise) * '0')[:2] or precise == '-0':
126
+ if precise.startswith('-0') and all(c in '0.' for c in precise[1:]):
121
127
  precise = precise[1:]
122
128
 
123
129
  elif rounding_mode == TRUNCATE:
@@ -138,7 +144,7 @@ def decimal_to_precision(n, rounding_mode=ROUND, precision=None, counting_mode=D
138
144
  precise = string
139
145
  else:
140
146
  precise = string[:end].ljust(dot, '0')
141
- if precise == ('-0.' + len(precise) * '0')[:3] or precise == '-0':
147
+ if precise.startswith('-0') and all(c in '0.' for c in precise[1:]):
142
148
  precise = precise[1:]
143
149
  precise = precise.rstrip('.')
144
150
 
mexc/ccxt/base/errors.py CHANGED
@@ -1,3 +1,9 @@
1
+ # ----------------------------------------------------------------------------
2
+
3
+ # PLEASE DO NOT EDIT THIS FILE, IT IS GENERATED AND WILL BE OVERWRITTEN:
4
+ # https://github.com/ccxt/ccxt/blob/master/CONTRIBUTING.md#how-to-contribute-code
5
+ # EDIT THE CORRESPONDENT .ts FILE INSTEAD
6
+
1
7
  error_hierarchy = {
2
8
  'BaseError': {
3
9
  'ExchangeError': {
@@ -4,7 +4,7 @@
4
4
 
5
5
  # -----------------------------------------------------------------------------
6
6
 
7
- __version__ = '4.4.95'
7
+ __version__ = '4.4.96'
8
8
 
9
9
  # -----------------------------------------------------------------------------
10
10
 
@@ -229,6 +229,7 @@ class Exchange(object):
229
229
  'chrome100': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.75 Safari/537.36',
230
230
  }
231
231
  headers = None
232
+ returnResponseHeaders = False
232
233
  origin = '*' # CORS origin
233
234
  MAX_VALUE = float('inf')
234
235
  #
@@ -579,6 +580,8 @@ class Exchange(object):
579
580
  if self.verbose:
580
581
  self.log("\nfetch Response:", self.id, method, url, http_status_code, "ResponseHeaders:", headers, "ResponseBody:", http_response)
581
582
  self.logger.debug("%s %s, Response: %s %s %s", method, url, http_status_code, headers, http_response)
583
+ if json_response and not isinstance(json_response, list) and self.returnResponseHeaders:
584
+ json_response['responseHeaders'] = headers
582
585
  response.raise_for_status()
583
586
 
584
587
  except Timeout as e:
@@ -2130,6 +2133,17 @@ class Exchange(object):
2130
2133
  'watchLiquidations': None,
2131
2134
  'watchLiquidationsForSymbols': None,
2132
2135
  'watchMyLiquidations': None,
2136
+ 'unWatchOrders': None,
2137
+ 'unWatchTrades': None,
2138
+ 'unWatchTradesForSymbols': None,
2139
+ 'unWatchOHLCVForSymbols': None,
2140
+ 'unWatchOrderBookForSymbols': None,
2141
+ 'unWatchPositions': None,
2142
+ 'unWatchOrderBook': None,
2143
+ 'unWatchTickers': None,
2144
+ 'unWatchMyTrades': None,
2145
+ 'unWatchTicker': None,
2146
+ 'unWatchOHLCV': None,
2133
2147
  'watchMyLiquidationsForSymbols': None,
2134
2148
  'withdraw': None,
2135
2149
  'ws': None,
@@ -2616,6 +2630,9 @@ class Exchange(object):
2616
2630
  def un_watch_order_book_for_symbols(self, symbols: List[str], params={}):
2617
2631
  raise NotSupported(self.id + ' unWatchOrderBookForSymbols() is not supported yet')
2618
2632
 
2633
+ def un_watch_positions(self, symbols: Strings = None, params={}):
2634
+ raise NotSupported(self.id + ' unWatchPositions() is not supported yet')
2635
+
2619
2636
  def fetch_deposit_addresses(self, codes: Strings = None, params={}):
2620
2637
  raise NotSupported(self.id + ' fetchDepositAddresses() is not supported yet')
2621
2638
 
@@ -3584,18 +3601,7 @@ class Exchange(object):
3584
3601
  symbol = market['symbol'] if (market is not None) else None
3585
3602
  return self.filter_by_symbol_since_limit(results, symbol, since, limit)
3586
3603
 
3587
- def calculate_fee(self, symbol: str, type: str, side: str, amount: float, price: float, takerOrMaker='taker', params={}):
3588
- """
3589
- calculates the presumptive fee that would be charged for an order
3590
- :param str symbol: unified market symbol
3591
- :param str type: 'market' or 'limit'
3592
- :param str side: 'buy' or 'sell'
3593
- :param float amount: how much you want to trade, in units of the base currency on most exchanges, or number of contracts
3594
- :param float price: the price for the order to be filled at, in units of the quote currency
3595
- :param str takerOrMaker: 'taker' or 'maker'
3596
- :param dict params:
3597
- :returns dict: contains the rate, the percentage multiplied to the order amount to obtain the fee amount, and cost, the total value of the fee in units of the quote currency, for the order
3598
- """
3604
+ def calculate_fee_with_rate(self, symbol: str, type: str, side: str, amount: float, price: float, takerOrMaker='taker', feeRate: Num = None, params={}):
3599
3605
  if type == 'market' and takerOrMaker == 'maker':
3600
3606
  raise ArgumentsRequired(self.id + ' calculateFee() - you have provided incompatible arguments - "market" type order can not be "maker". Change either the "type" or the "takerOrMaker" argument to calculate the fee.')
3601
3607
  market = self.markets[symbol]
@@ -3624,7 +3630,7 @@ class Exchange(object):
3624
3630
  # even if `takerOrMaker` argument was set to 'maker', for 'market' orders we should forcefully override it to 'taker'
3625
3631
  if type == 'market':
3626
3632
  takerOrMaker = 'taker'
3627
- rate = self.safe_string(market, takerOrMaker)
3633
+ rate = self.number_to_string(feeRate) if (feeRate is not None) else self.safe_string(market, takerOrMaker)
3628
3634
  cost = Precise.string_mul(cost, rate)
3629
3635
  return {
3630
3636
  'type': takerOrMaker,
@@ -3633,6 +3639,20 @@ class Exchange(object):
3633
3639
  'cost': self.parse_number(cost),
3634
3640
  }
3635
3641
 
3642
+ def calculate_fee(self, symbol: str, type: str, side: str, amount: float, price: float, takerOrMaker='taker', params={}):
3643
+ """
3644
+ calculates the presumptive fee that would be charged for an order
3645
+ :param str symbol: unified market symbol
3646
+ :param str type: 'market' or 'limit'
3647
+ :param str side: 'buy' or 'sell'
3648
+ :param float amount: how much you want to trade, in units of the base currency on most exchanges, or number of contracts
3649
+ :param float price: the price for the order to be filled at, in units of the quote currency
3650
+ :param str takerOrMaker: 'taker' or 'maker'
3651
+ :param dict params:
3652
+ :returns dict: contains the rate, the percentage multiplied to the order amount to obtain the fee amount, and cost, the total value of the fee in units of the quote currency, for the order
3653
+ """
3654
+ return self.calculate_fee_with_rate(symbol, type, side, amount, price, takerOrMaker, None, params)
3655
+
3636
3656
  def safe_liquidation(self, liquidation: dict, market: Market = None):
3637
3657
  contracts = self.safe_string(liquidation, 'contracts')
3638
3658
  contractSize = self.safe_string(market, 'contractSize')
@@ -3672,6 +3692,21 @@ class Exchange(object):
3672
3692
  trade['cost'] = self.parse_number(cost)
3673
3693
  return trade
3674
3694
 
3695
+ def create_ccxt_trade_id(self, timestamp=None, side=None, amount=None, price=None, takerOrMaker=None):
3696
+ # self approach is being used by multiple exchanges(mexc, woo, coinsbit, dydx, ...)
3697
+ id = None
3698
+ if timestamp is not None:
3699
+ id = self.number_to_string(timestamp)
3700
+ if side is not None:
3701
+ id += '-' + side
3702
+ if amount is not None:
3703
+ id += '-' + self.number_to_string(amount)
3704
+ if price is not None:
3705
+ id += '-' + self.number_to_string(price)
3706
+ if takerOrMaker is not None:
3707
+ id += '-' + takerOrMaker
3708
+ return id
3709
+
3675
3710
  def parsed_fee_and_fees(self, container: Any):
3676
3711
  fee = self.safe_dict(container, 'fee')
3677
3712
  fees = self.safe_list(container, 'fees')
@@ -5495,10 +5530,10 @@ class Exchange(object):
5495
5530
  """
5496
5531
  raise NotSupported(self.id + ' fetchDepositsWithdrawals() is not supported yet')
5497
5532
 
5498
- def fetch_deposits(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
5533
+ def fetch_deposits(self, code: Str = None, since: Int = None, limit: Int = None, params={}):
5499
5534
  raise NotSupported(self.id + ' fetchDeposits() is not supported yet')
5500
5535
 
5501
- def fetch_withdrawals(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
5536
+ def fetch_withdrawals(self, code: Str = None, since: Int = None, limit: Int = None, params={}):
5502
5537
  raise NotSupported(self.id + ' fetchWithdrawals() is not supported yet')
5503
5538
 
5504
5539
  def fetch_deposits_ws(self, code: Str = None, since: Int = None, limit: Int = None, params={}):
@@ -6426,7 +6461,7 @@ class Exchange(object):
6426
6461
  calls = 0
6427
6462
  result = []
6428
6463
  errors = 0
6429
- until = self.safe_integer_2(params, 'untill', 'till') # do not omit it from params here
6464
+ until = self.safe_integer_n(params, ['until', 'untill', 'till']) # do not omit it from params here
6430
6465
  maxEntriesPerRequest, params = self.handle_max_entries_per_request_and_params(method, maxEntriesPerRequest, params)
6431
6466
  if (paginationDirection == 'forward'):
6432
6467
  if since is None:
@@ -6988,6 +7023,14 @@ class Exchange(object):
6988
7023
  self.myTrades = None
6989
7024
  elif topic == 'orders' and (self.orders is not None):
6990
7025
  self.orders = None
7026
+ elif topic == 'positions' and (self.positions is not None):
7027
+ self.positions = None
7028
+ clients = list(self.clients.values())
7029
+ for i in range(0, len(clients)):
7030
+ client = clients[i]
7031
+ futures = self.safe_dict(client, 'futures')
7032
+ if (futures is not None) and ('fetchPositionsSnapshot' in futures):
7033
+ del futures['fetchPositionsSnapshot']
6991
7034
  elif topic == 'ticker' and (self.tickers is not None):
6992
7035
  tickerSymbols = list(self.tickers.keys())
6993
7036
  for i in range(0, len(tickerSymbols)):
mexc/ccxt/mexc.py CHANGED
@@ -448,6 +448,7 @@ class mexc(Exchange, ImplicitAPI):
448
448
  },
449
449
  },
450
450
  },
451
+ 'useCcxtTradeId': True,
451
452
  'timeframes': {
452
453
  'spot': {
453
454
  '1m': '1m',
@@ -1694,8 +1695,8 @@ class mexc(Exchange, ImplicitAPI):
1694
1695
  'cost': self.safe_string(trade, 'commission'),
1695
1696
  'currency': self.safe_currency_code(feeAsset),
1696
1697
  }
1697
- if id is None:
1698
- id = self.synthetic_trade_id(market, timestamp, side, amountString, priceString, type, takerOrMaker)
1698
+ if id is None and self.safe_bool(self.options, 'useCcxtTradeId', True):
1699
+ id = self.create_ccxt_trade_id(timestamp, side, amountString, priceString, takerOrMaker)
1699
1700
  return self.safe_trade({
1700
1701
  'id': id,
1701
1702
  'order': orderId,
@@ -1712,23 +1713,6 @@ class mexc(Exchange, ImplicitAPI):
1712
1713
  'info': trade,
1713
1714
  }, market)
1714
1715
 
1715
- def synthetic_trade_id(self, market=None, timestamp=None, side=None, amount=None, price=None, orderType=None, takerOrMaker=None):
1716
- # TODO: can be unified method? self approach is being used by multiple exchanges(mexc, woo-coinsbit, dydx, ...)
1717
- id = ''
1718
- if timestamp is not None:
1719
- id = self.number_to_string(timestamp) + '-' + self.safe_string(market, 'id', '_')
1720
- if side is not None:
1721
- id += '-' + side
1722
- if amount is not None:
1723
- id += '-' + self.number_to_string(amount)
1724
- if price is not None:
1725
- id += '-' + self.number_to_string(price)
1726
- if takerOrMaker is not None:
1727
- id += '-' + takerOrMaker
1728
- if orderType is not None:
1729
- id += '-' + orderType
1730
- return id
1731
-
1732
1716
  def fetch_ohlcv(self, symbol: str, timeframe='1m', since: Int = None, limit: Int = None, params={}) -> List[list]:
1733
1717
  """
1734
1718
 
@@ -4651,11 +4635,14 @@ class mexc(Exchange, ImplicitAPI):
4651
4635
  # "network": "TRX",
4652
4636
  # "status": "5",
4653
4637
  # "address": "TSMcEDDvkqY9dz8RkFnrS86U59GwEZjfvh",
4654
- # "txId": "51a8f49e6f03f2c056e71fe3291aa65e1032880be855b65cecd0595a1b8af95b",
4638
+ # "txId": "51a8f49e6f03f2c056e71fe3291aa65e1032880be855b65cecd0595a1b8af95b:0",
4655
4639
  # "insertTime": "1664805021000",
4656
4640
  # "unlockConfirm": "200",
4657
4641
  # "confirmTimes": "203",
4658
- # "memo": "xxyy1122"
4642
+ # "memo": "xxyy1122",
4643
+ # "transHash": "51a8f49e6f03f2c056e71fe3291aa65e1032880be855b65cecd0595a1b8af95b",
4644
+ # "updateTime": "1664805621000",
4645
+ # "netWork: "TRX"
4659
4646
  # }
4660
4647
  # ]
4661
4648
  #
@@ -4696,7 +4683,7 @@ class mexc(Exchange, ImplicitAPI):
4696
4683
  # [
4697
4684
  # {
4698
4685
  # "id": "adcd1c8322154de691b815eedcd10c42",
4699
- # "txId": "0xc8c918cd69b2246db493ef6225a72ffdc664f15b08da3e25c6879b271d05e9d0",
4686
+ # "txId": "0xc8c918cd69b2246db493ef6225a72ffdc664f15b08da3e25c6879b271d05e9d0:0",
4700
4687
  # "coin": "USDC-MATIC",
4701
4688
  # "network": "MATIC",
4702
4689
  # "address": "0xeE6C7a415995312ED52c53a0f8f03e165e0A5D62",
@@ -4707,7 +4694,11 @@ class mexc(Exchange, ImplicitAPI):
4707
4694
  # "confirmNo": null,
4708
4695
  # "applyTime": "1664882739000",
4709
4696
  # "remark": '',
4710
- # "memo": null
4697
+ # "memo": null,
4698
+ # "explorerUrl": "https://etherscan.io/tx/0xc8c918cd69b2246db493ef6225a72ffdc664f15b08da3e25c6879b271d05e9d0",
4699
+ # "transHash": "0xc8c918cd69b2246db493ef6225a72ffdc664f15b08da3e25c6879b271d05e9d0",
4700
+ # "updateTime": "1664882799000",
4701
+ # "netWork: "MATIC"
4711
4702
  # }
4712
4703
  # ]
4713
4704
  #
@@ -4723,18 +4714,21 @@ class mexc(Exchange, ImplicitAPI):
4723
4714
  # "network": "TRX",
4724
4715
  # "status": "5",
4725
4716
  # "address": "TSMcEDDvkqY9dz8RkFnrS86U59GwEZjfvh",
4726
- # "txId": "51a8f49e6f03f2c056e71fe3291aa65e1032880be855b65cecd0595a1b8af95b",
4717
+ # "txId": "51a8f49e6f03f2c056e71fe3291aa65e1032880be855b65cecd0595a1b8af95b:0",
4727
4718
  # "insertTime": "1664805021000",
4728
4719
  # "unlockConfirm": "200",
4729
4720
  # "confirmTimes": "203",
4730
- # "memo": "xxyy1122"
4721
+ # "memo": "xxyy1122",
4722
+ # "transHash": "51a8f49e6f03f2c056e71fe3291aa65e1032880be855b65cecd0595a1b8af95b",
4723
+ # "updateTime": "1664805621000",
4724
+ # "netWork: "TRX"
4731
4725
  # }
4732
4726
  #
4733
4727
  # fetchWithdrawals
4734
4728
  #
4735
4729
  # {
4736
4730
  # "id": "adcd1c8322154de691b815eedcd10c42",
4737
- # "txId": "0xc8c918cd69b2246db493ef6225a72ffdc664f15b08da3e25c6879b271d05e9d0",
4731
+ # "txId": "0xc8c918cd69b2246db493ef6225a72ffdc664f15b08da3e25c6879b271d05e9d0:0",
4738
4732
  # "coin": "USDC-MATIC",
4739
4733
  # "network": "MATIC",
4740
4734
  # "address": "0xeE6C7a415995312ED52c53a0f8f03e165e0A5D62",
@@ -4744,8 +4738,12 @@ class mexc(Exchange, ImplicitAPI):
4744
4738
  # "transactionFee": "1",
4745
4739
  # "confirmNo": null,
4746
4740
  # "applyTime": "1664882739000",
4747
- # "remark": '',
4748
- # "memo": null
4741
+ # "remark": "",
4742
+ # "memo": null,
4743
+ # "explorerUrl": "https://etherscan.io/tx/0xc8c918cd69b2246db493ef6225a72ffdc664f15b08da3e25c6879b271d05e9d0",
4744
+ # "transHash": "0xc8c918cd69b2246db493ef6225a72ffdc664f15b08da3e25c6879b271d05e9d0",
4745
+ # "updateTime": "1664882799000",
4746
+ # "netWork: "MATIC"
4749
4747
  # }
4750
4748
  #
4751
4749
  # withdraw
@@ -4757,6 +4755,7 @@ class mexc(Exchange, ImplicitAPI):
4757
4755
  id = self.safe_string(transaction, 'id')
4758
4756
  type = 'deposit' if (id is None) else 'withdrawal'
4759
4757
  timestamp = self.safe_integer_2(transaction, 'insertTime', 'applyTime')
4758
+ updated = self.safe_integer(transaction, 'updateTime')
4760
4759
  currencyId = None
4761
4760
  currencyWithNetwork = self.safe_string(transaction, 'coin')
4762
4761
  if currencyWithNetwork is not None:
@@ -4769,7 +4768,7 @@ class mexc(Exchange, ImplicitAPI):
4769
4768
  status = self.parse_transaction_status_by_type(self.safe_string(transaction, 'status'), type)
4770
4769
  amountString = self.safe_string(transaction, 'amount')
4771
4770
  address = self.safe_string(transaction, 'address')
4772
- txid = self.safe_string(transaction, 'txId')
4771
+ txid = self.safe_string_2(transaction, 'transHash', 'txId')
4773
4772
  fee = None
4774
4773
  feeCostString = self.safe_string(transaction, 'transactionFee')
4775
4774
  if feeCostString is not None:
@@ -4797,8 +4796,8 @@ class mexc(Exchange, ImplicitAPI):
4797
4796
  'amount': self.parse_number(amountString),
4798
4797
  'currency': code,
4799
4798
  'status': status,
4800
- 'updated': None,
4801
- 'comment': None,
4799
+ 'updated': updated,
4800
+ 'comment': self.safe_string(transaction, 'remark'),
4802
4801
  'internal': None,
4803
4802
  'fee': fee,
4804
4803
  }
@@ -5704,7 +5703,7 @@ class mexc(Exchange, ImplicitAPI):
5704
5703
  #
5705
5704
  # {success: True, code: '0'}
5706
5705
  #
5707
- return self.parse_leverage(response, market)
5706
+ return self.parse_leverage(response, market) # tmp revert type
5708
5707
 
5709
5708
  def nonce(self):
5710
5709
  return self.milliseconds() - self.safe_integer(self.options, 'timeDifference', 0)
mexc/ccxt/pro/__init__.py CHANGED
@@ -8,7 +8,7 @@ sys.modules['ccxt'] = ccxt_module
8
8
 
9
9
  # ----------------------------------------------------------------------------
10
10
 
11
- __version__ = '4.4.95'
11
+ __version__ = '4.4.96'
12
12
 
13
13
  # ----------------------------------------------------------------------------
14
14
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mexc-exchange-api
3
- Version: 0.0.75
3
+ Version: 0.0.77
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
@@ -190,7 +190,6 @@ You can also construct custom requests to available "implicit" endpoints
190
190
  - `set_leverage(self, leverage: Int, symbol: Str = None, params={})`
191
191
  - `set_margin_mode(self, marginMode: str, symbol: Str = None, params={})`
192
192
  - `set_position_mode(self, hedged: bool, symbol: Str = None, params={})`
193
- - `synthetic_trade_id(self, market=None, timestamp=None, side=None, amount=None, price=None, orderType=None, takerOrMaker=None)`
194
193
  - `transfer(self, code: str, amount: float, fromAccount: str, toAccount: str, params={})`
195
194
  - `withdraw(self, code: str, amount: float, address: str, tag=None, params={})`
196
195
 
@@ -1,26 +1,26 @@
1
1
  mexc/__init__.py,sha256=bFV_Nfz_k-lfB_ImsHGpFnJuVMUXLBRbttugnPV7c4A,222
2
- mexc/ccxt/__init__.py,sha256=k-A0x_55G-tUkvoh0rBVvKsZM1H68rLHplCkRrwRTYs,6044
3
- mexc/ccxt/mexc.py,sha256=h_lRUM7X5-ZKEPKKYNUxBiAlrqgc6YEDjuH8j_KTFw0,258968
2
+ mexc/ccxt/__init__.py,sha256=r9Q0DqWjHTCXMTBRvbmyEOJZC0YUCvO1tA9RFrH4jno,6044
3
+ mexc/ccxt/mexc.py,sha256=yXohafY0UHla1VQMplaIGm-ChAnLSdaEj-SxoH-fX_g,259329
4
4
  mexc/ccxt/abstract/mexc.py,sha256=oyg0sZFYs1d77F-_9QAatqMSQJ8h-1u1wWb-d1DX2zQ,26434
5
- mexc/ccxt/async_support/__init__.py,sha256=WNGM0Wb05ubmJtAldrNuiJxVd2U9FxltLOKU9CqEE_4,4777
6
- mexc/ccxt/async_support/mexc.py,sha256=Q84eiLJUARv6JA2q_0Tpq9JsRqLzNVmf0fmWo5mnMho,260232
5
+ mexc/ccxt/async_support/__init__.py,sha256=WxBIDPAzUBxDUrMPJNb6ePHsct59k1UFmcBIc2JQi1U,4777
6
+ mexc/ccxt/async_support/mexc.py,sha256=D12q3K3txzm7XHgGdz5ebXQOT33D4rZ29Y6jyDre4HU,260593
7
7
  mexc/ccxt/async_support/base/__init__.py,sha256=aVYSsFi--b4InRs9zDN_wtCpj8odosAB726JdUHavrk,67
8
- mexc/ccxt/async_support/base/exchange.py,sha256=rlXug7vYV2ke2rjNRzkakqbw4H7gzN3oUoeSldxBheY,119440
8
+ mexc/ccxt/async_support/base/exchange.py,sha256=5YrTOaoiX9ws39WT_JWs_g3anZAMiPSc1eXiD56Sh0Q,119773
9
9
  mexc/ccxt/async_support/base/throttler.py,sha256=tvDVcdRUVYi8fZRlEcnqtgzcgB_KMUMRs5Pu8tuU-tU,1847
10
10
  mexc/ccxt/async_support/base/ws/__init__.py,sha256=uockzpLuwntKGZbs5EOWFe-Zg-k6Cj7GhNJLc_RX0so,1791
11
11
  mexc/ccxt/async_support/base/ws/cache.py,sha256=xf2VOtfUwloxSlIQ39M1RGZHWQzyS9IGhB5NX6cDcAc,8370
12
12
  mexc/ccxt/async_support/base/ws/client.py,sha256=ekIN5HNgeQgMG3tLZMsE889Aoxs960DLwQnwkTGhdi8,13624
13
13
  mexc/ccxt/async_support/base/ws/functions.py,sha256=qwvEnjtINWL5ZU-dbbeIunjyBxzFqbGWHfVhxqAcKug,1499
14
- mexc/ccxt/async_support/base/ws/future.py,sha256=2zrEB7Xinq14N05jaewNtbR_2ZiE5GQZNQV4CBW7qTA,1337
14
+ mexc/ccxt/async_support/base/ws/future.py,sha256=hjdQ42zkfju5nar0GpTLJ4zXQBtgBU8DzYM5uPFcjsE,1450
15
15
  mexc/ccxt/async_support/base/ws/order_book.py,sha256=uBUaIHhzMRykpmo4BCsdJ-t_HozS6VxhEs8x-Kbj-NI,2894
16
16
  mexc/ccxt/async_support/base/ws/order_book_side.py,sha256=GhnGUt78pJ-AYL_Dq9produGjmBJLCI5FHIRdMz1O-g,6551
17
17
  mexc/ccxt/base/__init__.py,sha256=eTx1OE3HJjspFUQjGm6LBhaQiMKJnXjkdP-JUXknyQ0,1320
18
- mexc/ccxt/base/decimal_to_precision.py,sha256=fgWRBzRTtsf3r2INyS4f7WHlzgjB5YM1ekiwqD21aac,6634
19
- mexc/ccxt/base/errors.py,sha256=Pad-6ugvGUwhoYuKUliX-N7FTrcnKCQGFjsaq2tMn0I,4610
20
- mexc/ccxt/base/exchange.py,sha256=1Hb7swmJX38Qzt6t7TayO0U-jw0cQ5AbACLZoYoM-9I,331665
18
+ mexc/ccxt/base/decimal_to_precision.py,sha256=XQNziSPUz4UqhIvNx0aDx6-3wSSgZBTsMX57rM7WGPM,7330
19
+ mexc/ccxt/base/errors.py,sha256=MvCrL_sAM3de616T6RE0PSxiF2xV6Qqz5b1y1ghidbk,4888
20
+ mexc/ccxt/base/exchange.py,sha256=3LI4McirkCUEz1090jMfedqTtOae-Gqcl94_oeNf23c,333932
21
21
  mexc/ccxt/base/precise.py,sha256=koce64Yrp6vFbGijJtUt-QQ6XhJgeGTCksZ871FPp_A,8886
22
22
  mexc/ccxt/base/types.py,sha256=vMQfFDVntED4YHrRJt0Q98YaM7OtGhK-DkbkqXFTYHc,11485
23
- mexc/ccxt/pro/__init__.py,sha256=YS3K8atBWVLDTQNzqtkm7kgeFxTxwKQqWqWDckPs8TE,4091
23
+ mexc/ccxt/pro/__init__.py,sha256=3D2AtG8OAdcDSeX0bIWrLhKMjjQ-blEGcAuJZCuaoz8,4091
24
24
  mexc/ccxt/pro/mexc.py,sha256=CaDYhXdZ-_bEQuhfx4FIVTA953zTaNnMpdc2wi9WlJw,68628
25
25
  mexc/ccxt/static_dependencies/README.md,sha256=3TCvhhn09_Cqf9BDDpao1V7EfKHDpQ6k9oWRsLFixpU,18
26
26
  mexc/ccxt/static_dependencies/__init__.py,sha256=tzFje8cloqmiIE6kola3EaYC0SnD1izWnri69hzHsSw,168
@@ -281,6 +281,6 @@ mexc/ccxt/static_dependencies/toolz/curried/exceptions.py,sha256=gKFOHDIayAWnX2u
281
281
  mexc/ccxt/static_dependencies/toolz/curried/operator.py,sha256=ML92mknkAwzBl2NCm-4werSUmJEtSHNY9NSzhseNM9s,525
282
282
  mexc/ccxt/static_dependencies/typing_inspect/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
283
283
  mexc/ccxt/static_dependencies/typing_inspect/typing_inspect.py,sha256=5gIWomLPfuDpgd3gX1GlnX0MuXM3VorR4j2W2qXORiQ,28269
284
- mexc_exchange_api-0.0.75.dist-info/METADATA,sha256=rpPd8YRL1fwPbNo41RK2TMENASPIlQLGRTpgfI9IT68,18194
285
- mexc_exchange_api-0.0.75.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
286
- mexc_exchange_api-0.0.75.dist-info/RECORD,,
284
+ mexc_exchange_api-0.0.77.dist-info/METADATA,sha256=WKepCXKYbSI4V4c8yVtsEzdjLiYLfXKpnZCZ21sYi3w,18065
285
+ mexc_exchange_api-0.0.77.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
286
+ mexc_exchange_api-0.0.77.dist-info/RECORD,,