mexc-exchange-api 0.0.90__py3-none-any.whl → 0.0.92__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/__init__.py CHANGED
@@ -26,7 +26,7 @@ sys.modules['ccxt'] = ccxt_module
26
26
 
27
27
  # ----------------------------------------------------------------------------
28
28
 
29
- __version__ = '4.5.5'
29
+ __version__ = '4.5.7'
30
30
 
31
31
  # ----------------------------------------------------------------------------
32
32
 
@@ -58,6 +58,7 @@ class ImplicitAPI:
58
58
  spot_private_get_mxdeduct_enable = spotPrivateGetMxDeductEnable = Entry('mxDeduct/enable', ['spot', 'private'], 'GET', {'cost': 1})
59
59
  spot_private_get_userdatastream = spotPrivateGetUserDataStream = Entry('userDataStream', ['spot', 'private'], 'GET', {'cost': 1})
60
60
  spot_private_get_selfsymbols = spotPrivateGetSelfSymbols = Entry('selfSymbols', ['spot', 'private'], 'GET', {'cost': 1})
61
+ spot_private_get_asset_internal_transfer_record = spotPrivateGetAssetInternalTransferRecord = Entry('asset/internal/transfer/record', ['spot', 'private'], 'GET', {'cost': 10})
61
62
  spot_private_post_order = spotPrivatePostOrder = Entry('order', ['spot', 'private'], 'POST', {'cost': 1})
62
63
  spot_private_post_order_test = spotPrivatePostOrderTest = Entry('order/test', ['spot', 'private'], 'POST', {'cost': 1})
63
64
  spot_private_post_sub_account_virtualsubaccount = spotPrivatePostSubAccountVirtualSubAccount = Entry('sub-account/virtualSubAccount', ['spot', 'private'], 'POST', {'cost': 1})
@@ -8,7 +8,7 @@ sys.modules['ccxt'] = ccxt_module
8
8
 
9
9
  # -----------------------------------------------------------------------------
10
10
 
11
- __version__ = '4.5.5'
11
+ __version__ = '4.5.7'
12
12
 
13
13
  # -----------------------------------------------------------------------------
14
14
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  # -----------------------------------------------------------------------------
4
4
 
5
- __version__ = '4.5.5'
5
+ __version__ = '4.5.7'
6
6
 
7
7
  # -----------------------------------------------------------------------------
8
8
 
@@ -245,6 +245,7 @@ class mexc(Exchange, ImplicitAPI):
245
245
  'mxDeduct/enable': 1,
246
246
  'userDataStream': 1,
247
247
  'selfSymbols': 1,
248
+ 'asset/internal/transfer/record': 10,
248
249
  },
249
250
  'post': {
250
251
  'order': 1,
@@ -776,6 +777,9 @@ class mexc(Exchange, ImplicitAPI):
776
777
  },
777
778
  'spot': {
778
779
  'extends': 'default',
780
+ 'fetchCurrencies': {
781
+ 'private': True,
782
+ },
779
783
  },
780
784
  'forDerivs': {
781
785
  'extends': 'default',
@@ -1062,7 +1066,7 @@ class mexc(Exchange, ImplicitAPI):
1062
1066
  # therefore we check the keys here
1063
1067
  # and fallback to generating the currencies from the markets
1064
1068
  if not self.check_required_credentials(False):
1065
- return None
1069
+ return {}
1066
1070
  response = await self.spotPrivateGetCapitalConfigGetall(params)
1067
1071
  #
1068
1072
  # {
@@ -5027,7 +5031,7 @@ class mexc(Exchange, ImplicitAPI):
5027
5031
  request: dict = {
5028
5032
  'transact_id': id,
5029
5033
  }
5030
- response = await self.spot2PrivateGetAssetInternalTransferInfo(self.extend(request, query))
5034
+ response = await self.spotPrivateGetAssetInternalTransferRecord(self.extend(request, query))
5031
5035
  #
5032
5036
  # {
5033
5037
  # "code": "200",
@@ -5053,54 +5057,74 @@ class mexc(Exchange, ImplicitAPI):
5053
5057
 
5054
5058
  https://mexcdevelop.github.io/apidocs/spot_v2_en/#get-internal-assets-transfer-records
5055
5059
  https://mexcdevelop.github.io/apidocs/contract_v1_en/#get-the-user-39-s-asset-transfer-records
5060
+ https://www.mexc.com/api-docs/spot-v3/wallet-endpoints#query-user-universal-transfer-history :param str code: unified currency code of the currency transferred
5056
5061
 
5057
- :param str code: unified currency code of the currency transferred
5062
+ @param code
5058
5063
  :param int [since]: the earliest time in ms to fetch transfers for
5059
5064
  :param int [limit]: the maximum number of transfers structures to retrieve
5060
5065
  :param dict [params]: extra parameters specific to the exchange API endpoint
5066
+ :param str [params.fromAccountType]: 'SPOT' for spot wallet, 'FUTURES' for contract wallet
5067
+ :param str [params.toAccountType]: 'SPOT' for spot wallet, 'FUTURES' for contract wallet
5061
5068
  :returns dict[]: a list of `transfer structures <https://docs.ccxt.com/#/?id=transfer-structure>`
5062
5069
  """
5063
- marketType, query = self.handle_market_type_and_params('fetchTransfers', None, params)
5070
+ marketType = None
5071
+ marketType, params = self.handle_market_type_and_params('fetchTransfers', None, params)
5064
5072
  await self.load_markets()
5065
5073
  request: dict = {}
5066
5074
  currency = None
5067
- resultList = None
5068
5075
  if code is not None:
5069
5076
  currency = self.currency(code)
5070
- request['currency'] = currency['id']
5077
+ fromAccountType = None
5078
+ fromAccountType, params = self.handle_option_and_params(params, 'fetchTransfers', 'fromAccountType')
5079
+ accountTypes = {
5080
+ 'spot': 'SPOT',
5081
+ 'swap': 'FUTURES',
5082
+ 'futures': 'FUTURES',
5083
+ 'future': 'FUTURES',
5084
+ 'margin': 'SPOT',
5085
+ }
5086
+ if fromAccountType is not None:
5087
+ request['fromAccountType'] = self.safe_string(accountTypes, fromAccountType, fromAccountType)
5088
+ else:
5089
+ raise ArgumentsRequired(self.id + ' fetchTransfers() requires a fromAccountType parameter, one of "SPOT", "FUTURES"')
5090
+ toAccountType = None
5091
+ toAccountType, params = self.handle_option_and_params(params, 'fetchTransfers', 'toAccountType')
5092
+ if toAccountType is not None:
5093
+ request['toAccountType'] = self.safe_string(accountTypes, toAccountType, toAccountType)
5094
+ else:
5095
+ raise ArgumentsRequired(self.id + ' fetchTransfers() requires a toAccountType parameter, one of "SPOT", "FUTURES"')
5096
+ resultList = []
5071
5097
  if marketType == 'spot':
5072
5098
  if since is not None:
5073
- request['start_time'] = since
5099
+ request['startTime'] = since
5074
5100
  if limit is not None:
5075
- if limit > 50:
5101
+ if limit > 100:
5076
5102
  raise ExchangeError('This exchange supports a maximum limit of 50')
5077
- request['page-size'] = limit
5078
- response = await self.spot2PrivateGetAssetInternalTransferRecord(self.extend(request, query))
5103
+ request['size'] = limit
5104
+ response = await self.spotPrivateGetCapitalTransfer(self.extend(request, params))
5079
5105
  #
5080
- # {
5081
- # "code": "200",
5082
- # "data": {
5083
- # "total_page": "1",
5084
- # "total_size": "5",
5085
- # "result_list": [{
5086
- # "currency": "USDT",
5087
- # "amount": "1",
5088
- # "transact_id": "954877a2ef54499db9b28a7cf9ebcf41",
5089
- # "from": "MAIN",
5090
- # "to": "CONTRACT",
5091
- # "transact_state": "SUCCESS"
5092
- # },
5093
- # ...
5094
- # ]
5095
- # }
5096
- # }
5097
5106
  #
5098
- data = self.safe_value(response, 'data', {})
5099
- resultList = self.safe_value(data, 'result_list', [])
5107
+ # {
5108
+ # "rows": [
5109
+ # {
5110
+ # "tranId": "cdf0d2a618b5458c965baefe6b1d0859",
5111
+ # "clientTranId": null,
5112
+ # "asset": "USDT",
5113
+ # "amount": "1",
5114
+ # "fromAccountType": "FUTURES",
5115
+ # "toAccountType": "SPOT",
5116
+ # "symbol": null,
5117
+ # "status": "SUCCESS",
5118
+ # "timestamp": 1759328309000
5119
+ # }
5120
+ # ],
5121
+ # "total": 1
5122
+ # }
5123
+ resultList = self.safe_list(response, 'rows', [])
5100
5124
  elif marketType == 'swap':
5101
5125
  if limit is not None:
5102
5126
  request['page_size'] = limit
5103
- response = await self.contractPrivateGetAccountTransferRecord(self.extend(request, query))
5127
+ response = await self.contractPrivateGetAccountTransferRecord(self.extend(request, params))
5104
5128
  data = self.safe_value(response, 'data')
5105
5129
  resultList = self.safe_value(data, 'resultList')
5106
5130
  #
@@ -5148,10 +5172,10 @@ class mexc(Exchange, ImplicitAPI):
5148
5172
  accounts: dict = {
5149
5173
  'spot': 'SPOT',
5150
5174
  'swap': 'FUTURES',
5151
- 'margin': 'ISOLATED_MARGIN',
5175
+ 'future': 'FUTURES',
5152
5176
  }
5153
- fromId = self.safe_string(accounts, fromAccount)
5154
- toId = self.safe_string(accounts, toAccount)
5177
+ fromId = self.safe_string(accounts, fromAccount, fromAccount)
5178
+ toId = self.safe_string(accounts, toAccount, toAccount)
5155
5179
  if fromId is None:
5156
5180
  keys = list(accounts.keys())
5157
5181
  raise ExchangeError(self.id + ' fromAccount must be one of ' + ', '.join(keys))
@@ -5209,6 +5233,17 @@ class mexc(Exchange, ImplicitAPI):
5209
5233
  # "createTime": "1648849076000",
5210
5234
  # "updateTime": "1648849076000"
5211
5235
  # }
5236
+ # {
5237
+ # "tranId": "cdf0d2a618b5458c965baefe6b1d0859",
5238
+ # "clientTranId": null,
5239
+ # "asset": "USDT",
5240
+ # "amount": "1",
5241
+ # "fromAccountType": "FUTURES",
5242
+ # "toAccountType": "SPOT",
5243
+ # "symbol": null,
5244
+ # "status": "SUCCESS",
5245
+ # "timestamp": 1759328309000
5246
+ # }
5212
5247
  #
5213
5248
  # transfer
5214
5249
  #
@@ -5216,14 +5251,19 @@ class mexc(Exchange, ImplicitAPI):
5216
5251
  # "tranId": "ebb06123e6a64f4ab234b396c548d57e"
5217
5252
  # }
5218
5253
  #
5219
- currencyId = self.safe_string(transfer, 'currency')
5254
+ currencyId = self.safe_string_2(transfer, 'currency', 'asset')
5220
5255
  id = self.safe_string_n(transfer, ['transact_id', 'txid', 'tranId'])
5221
- timestamp = self.safe_integer(transfer, 'createTime')
5256
+ timestamp = self.safe_integer_2(transfer, 'createTime', 'timestamp')
5222
5257
  datetime = self.iso8601(timestamp) if (timestamp is not None) else None
5223
5258
  direction = self.safe_string(transfer, 'type')
5224
5259
  accountFrom = None
5225
5260
  accountTo = None
5226
- if direction is not None:
5261
+ fromAccountType = self.safe_string(transfer, 'fromAccountType')
5262
+ toAccountType = self.safe_string(transfer, 'toAccountType')
5263
+ if (fromAccountType is not None) and (toAccountType is not None):
5264
+ accountFrom = fromAccountType
5265
+ accountTo = toAccountType
5266
+ elif direction is not None:
5227
5267
  accountFrom = 'MAIN' if (direction == 'IN') else 'CONTRACT'
5228
5268
  accountTo = 'CONTRACT' if (direction == 'IN') else 'MAIN'
5229
5269
  else:
@@ -5238,11 +5278,13 @@ class mexc(Exchange, ImplicitAPI):
5238
5278
  'amount': self.safe_number(transfer, 'amount'),
5239
5279
  'fromAccount': self.parse_account_id(accountFrom),
5240
5280
  'toAccount': self.parse_account_id(accountTo),
5241
- 'status': self.parse_transfer_status(self.safe_string_2(transfer, 'transact_state', 'state')),
5281
+ 'status': self.parse_transfer_status(self.safe_string_n(transfer, ['transact_state', 'state', 'status'])),
5242
5282
  }
5243
5283
 
5244
5284
  def parse_account_id(self, status):
5245
5285
  statuses: dict = {
5286
+ 'SPOT': 'spot',
5287
+ 'FUTURES': 'swap',
5246
5288
  'MAIN': 'spot',
5247
5289
  'CONTRACT': 'swap',
5248
5290
  }
mexc/ccxt/base/errors.py CHANGED
@@ -1,9 +1,3 @@
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
-
7
1
  error_hierarchy = {
8
2
  'BaseError': {
9
3
  'ExchangeError': {
@@ -4,7 +4,7 @@
4
4
 
5
5
  # -----------------------------------------------------------------------------
6
6
 
7
- __version__ = '4.5.5'
7
+ __version__ = '4.5.7'
8
8
 
9
9
  # -----------------------------------------------------------------------------
10
10
 
@@ -311,8 +311,7 @@ class Exchange(object):
311
311
  bidsasks = None
312
312
  base_currencies = None
313
313
  quote_currencies = None
314
- currencies = None
315
-
314
+ currencies = {}
316
315
  options = None # Python does not allow to define properties in run-time with setattr
317
316
  isSandboxModeEnabled = False
318
317
  accounts = None
@@ -2591,6 +2590,22 @@ class Exchange(object):
2591
2590
  # set flag
2592
2591
  self.isSandboxModeEnabled = False
2593
2592
 
2593
+ def enable_demo_trading(self, enable: bool):
2594
+ """
2595
+ enables or disables demo trading mode
2596
+ :param boolean [enable]: True if demo trading should be enabled, False otherwise
2597
+ """
2598
+ if self.isSandboxModeEnabled:
2599
+ raise NotSupported(self.id + ' demo trading does not support in sandbox environment. Please check https://www.binance.com/en/support/faq/detail/9be58f73e5e14338809e3b705b9687dd to see the differences')
2600
+ if enable:
2601
+ self.urls['apiBackupDemoTrading'] = self.urls['api']
2602
+ self.urls['api'] = self.urls['demo']
2603
+ elif 'apiBackupDemoTrading' in self.urls:
2604
+ self.urls['api'] = self.urls['apiBackupDemoTrading']
2605
+ newUrls = self.omit(self.urls, 'apiBackupDemoTrading')
2606
+ self.urls = newUrls
2607
+ self.options['enableDemoTrading'] = enable
2608
+
2594
2609
  def sign(self, path, api: Any = 'public', method='GET', params={}, headers: Any = None, body: Any = None):
2595
2610
  return {}
2596
2611
 
@@ -3009,6 +3024,76 @@ class Exchange(object):
3009
3024
  featureBlock['symbolRequired'] = self.in_array(key, ['createOrder', 'createOrders', 'fetchOHLCV'])
3010
3025
  return featuresObj
3011
3026
 
3027
+ def feature_value(self, symbol: str, methodName: Str = None, paramName: Str = None, subParamName: Str = None, defaultValue: Any = None):
3028
+ """
3029
+ self method is a very deterministic to help users to know what feature is supported by the exchange
3030
+ :param str [symbol]: unified symbol
3031
+ :param str [methodName]: view currently supported methods: https://docs.ccxt.com/#/README?id=features
3032
+ :param str [paramName]: unified param value(check docs for supported param names)
3033
+ :param str [subParamName]: unified sub-param value(eg. stopLoss->triggerPriceType)
3034
+ :param dict [defaultValue]: return default value if no result found
3035
+ :returns dict: returns feature value
3036
+ """
3037
+ market = self.market(symbol)
3038
+ return self.feature_value_by_type(market['type'], market['subType'], methodName, paramName, subParamName, defaultValue)
3039
+
3040
+ def feature_value_by_type(self, marketType: str, subType: Str, methodName: Str = None, paramName: Str = None, subParamName: Str = None, defaultValue: Any = None):
3041
+ """
3042
+ self method is a very deterministic to help users to know what feature is supported by the exchange
3043
+ :param str [marketType]: supported only: "spot", "swap", "future"
3044
+ :param str [subType]: supported only: "linear", "inverse"
3045
+ :param str [methodName]: view currently supported methods: https://docs.ccxt.com/#/README?id=features
3046
+ :param str [paramName]: unified param value(check docs for supported param names)
3047
+ :param str [subParamName]: unified sub-param value(eg. stopLoss->triggerPriceType)
3048
+ :param dict [defaultValue]: return default value if no result found
3049
+ :returns dict: returns feature value
3050
+ """
3051
+ # if exchange does not yet have features manually implemented
3052
+ if self.features is None:
3053
+ return defaultValue
3054
+ # if marketType(e.g. 'option') does not exist in features
3055
+ if not (marketType in self.features):
3056
+ return defaultValue # unsupported marketType, check "exchange.features" for details
3057
+ # if marketType dict None
3058
+ if self.features[marketType] is None:
3059
+ return defaultValue
3060
+ methodsContainer = self.features[marketType]
3061
+ if subType is None:
3062
+ if marketType != 'spot':
3063
+ return defaultValue # subType is required for non-spot markets
3064
+ else:
3065
+ if not (subType in self.features[marketType]):
3066
+ return defaultValue # unsupported subType, check "exchange.features" for details
3067
+ # if subType dict None
3068
+ if self.features[marketType][subType] is None:
3069
+ return defaultValue
3070
+ methodsContainer = self.features[marketType][subType]
3071
+ # if user wanted only marketType and didn't provide methodName, eg: featureIsSupported('spot')
3072
+ if methodName is None:
3073
+ return methodsContainer
3074
+ if not (methodName in methodsContainer):
3075
+ return defaultValue # unsupported method, check "exchange.features" for details')
3076
+ methodDict = methodsContainer[methodName]
3077
+ if methodDict is None:
3078
+ return defaultValue
3079
+ # if user wanted only method and didn't provide `paramName`, eg: featureIsSupported('swap', 'linear', 'createOrder')
3080
+ if paramName is None:
3081
+ return methodDict
3082
+ if not (paramName in methodDict):
3083
+ return defaultValue # unsupported paramName, check "exchange.features" for details')
3084
+ dictionary = self.safe_dict(methodDict, paramName)
3085
+ if dictionary is None:
3086
+ # if the value is not dictionary but a scalar value(or None), return
3087
+ return methodDict[paramName]
3088
+ else:
3089
+ # return, when calling without `subParamName` eg: featureValueByType('spot', None, 'createOrder', 'stopLoss')
3090
+ if subParamName is None:
3091
+ return methodDict[paramName]
3092
+ # raise an exception for unsupported subParamName
3093
+ if not (subParamName in methodDict[paramName]):
3094
+ return defaultValue # unsupported subParamName, check "exchange.features" for details
3095
+ return methodDict[paramName][subParamName]
3096
+
3012
3097
  def orderbook_checksum_message(self, symbol: Str):
3013
3098
  return symbol + ' = False'
3014
3099
 
@@ -3275,7 +3360,11 @@ class Exchange(object):
3275
3360
  marketsSortedById = self.keysort(self.markets_by_id)
3276
3361
  self.symbols = list(marketsSortedBySymbol.keys())
3277
3362
  self.ids = list(marketsSortedById.keys())
3363
+ numCurrencies = 0
3278
3364
  if currencies is not None:
3365
+ keys = list(currencies.keys())
3366
+ numCurrencies = len(keys)
3367
+ if numCurrencies > 0:
3279
3368
  # currencies is always None when called in constructor but not when called from loadMarkets
3280
3369
  self.currencies = self.map_to_safe_map(self.deep_extend(self.currencies, currencies))
3281
3370
  else:
@@ -5659,7 +5748,9 @@ class Exchange(object):
5659
5748
  return self.safe_string(self.commonCurrencies, code, code)
5660
5749
 
5661
5750
  def currency(self, code: str):
5662
- if self.currencies is None:
5751
+ keys = list(self.currencies.keys())
5752
+ numCurrencies = len(keys)
5753
+ if numCurrencies == 0:
5663
5754
  raise ExchangeError(self.id + ' currencies not loaded')
5664
5755
  if isinstance(code, str):
5665
5756
  if code in self.currencies:
mexc/ccxt/mexc.py CHANGED
@@ -244,6 +244,7 @@ class mexc(Exchange, ImplicitAPI):
244
244
  'mxDeduct/enable': 1,
245
245
  'userDataStream': 1,
246
246
  'selfSymbols': 1,
247
+ 'asset/internal/transfer/record': 10,
247
248
  },
248
249
  'post': {
249
250
  'order': 1,
@@ -775,6 +776,9 @@ class mexc(Exchange, ImplicitAPI):
775
776
  },
776
777
  'spot': {
777
778
  'extends': 'default',
779
+ 'fetchCurrencies': {
780
+ 'private': True,
781
+ },
778
782
  },
779
783
  'forDerivs': {
780
784
  'extends': 'default',
@@ -1061,7 +1065,7 @@ class mexc(Exchange, ImplicitAPI):
1061
1065
  # therefore we check the keys here
1062
1066
  # and fallback to generating the currencies from the markets
1063
1067
  if not self.check_required_credentials(False):
1064
- return None
1068
+ return {}
1065
1069
  response = self.spotPrivateGetCapitalConfigGetall(params)
1066
1070
  #
1067
1071
  # {
@@ -5026,7 +5030,7 @@ class mexc(Exchange, ImplicitAPI):
5026
5030
  request: dict = {
5027
5031
  'transact_id': id,
5028
5032
  }
5029
- response = self.spot2PrivateGetAssetInternalTransferInfo(self.extend(request, query))
5033
+ response = self.spotPrivateGetAssetInternalTransferRecord(self.extend(request, query))
5030
5034
  #
5031
5035
  # {
5032
5036
  # "code": "200",
@@ -5052,54 +5056,74 @@ class mexc(Exchange, ImplicitAPI):
5052
5056
 
5053
5057
  https://mexcdevelop.github.io/apidocs/spot_v2_en/#get-internal-assets-transfer-records
5054
5058
  https://mexcdevelop.github.io/apidocs/contract_v1_en/#get-the-user-39-s-asset-transfer-records
5059
+ https://www.mexc.com/api-docs/spot-v3/wallet-endpoints#query-user-universal-transfer-history :param str code: unified currency code of the currency transferred
5055
5060
 
5056
- :param str code: unified currency code of the currency transferred
5061
+ @param code
5057
5062
  :param int [since]: the earliest time in ms to fetch transfers for
5058
5063
  :param int [limit]: the maximum number of transfers structures to retrieve
5059
5064
  :param dict [params]: extra parameters specific to the exchange API endpoint
5065
+ :param str [params.fromAccountType]: 'SPOT' for spot wallet, 'FUTURES' for contract wallet
5066
+ :param str [params.toAccountType]: 'SPOT' for spot wallet, 'FUTURES' for contract wallet
5060
5067
  :returns dict[]: a list of `transfer structures <https://docs.ccxt.com/#/?id=transfer-structure>`
5061
5068
  """
5062
- marketType, query = self.handle_market_type_and_params('fetchTransfers', None, params)
5069
+ marketType = None
5070
+ marketType, params = self.handle_market_type_and_params('fetchTransfers', None, params)
5063
5071
  self.load_markets()
5064
5072
  request: dict = {}
5065
5073
  currency = None
5066
- resultList = None
5067
5074
  if code is not None:
5068
5075
  currency = self.currency(code)
5069
- request['currency'] = currency['id']
5076
+ fromAccountType = None
5077
+ fromAccountType, params = self.handle_option_and_params(params, 'fetchTransfers', 'fromAccountType')
5078
+ accountTypes = {
5079
+ 'spot': 'SPOT',
5080
+ 'swap': 'FUTURES',
5081
+ 'futures': 'FUTURES',
5082
+ 'future': 'FUTURES',
5083
+ 'margin': 'SPOT',
5084
+ }
5085
+ if fromAccountType is not None:
5086
+ request['fromAccountType'] = self.safe_string(accountTypes, fromAccountType, fromAccountType)
5087
+ else:
5088
+ raise ArgumentsRequired(self.id + ' fetchTransfers() requires a fromAccountType parameter, one of "SPOT", "FUTURES"')
5089
+ toAccountType = None
5090
+ toAccountType, params = self.handle_option_and_params(params, 'fetchTransfers', 'toAccountType')
5091
+ if toAccountType is not None:
5092
+ request['toAccountType'] = self.safe_string(accountTypes, toAccountType, toAccountType)
5093
+ else:
5094
+ raise ArgumentsRequired(self.id + ' fetchTransfers() requires a toAccountType parameter, one of "SPOT", "FUTURES"')
5095
+ resultList = []
5070
5096
  if marketType == 'spot':
5071
5097
  if since is not None:
5072
- request['start_time'] = since
5098
+ request['startTime'] = since
5073
5099
  if limit is not None:
5074
- if limit > 50:
5100
+ if limit > 100:
5075
5101
  raise ExchangeError('This exchange supports a maximum limit of 50')
5076
- request['page-size'] = limit
5077
- response = self.spot2PrivateGetAssetInternalTransferRecord(self.extend(request, query))
5102
+ request['size'] = limit
5103
+ response = self.spotPrivateGetCapitalTransfer(self.extend(request, params))
5078
5104
  #
5079
- # {
5080
- # "code": "200",
5081
- # "data": {
5082
- # "total_page": "1",
5083
- # "total_size": "5",
5084
- # "result_list": [{
5085
- # "currency": "USDT",
5086
- # "amount": "1",
5087
- # "transact_id": "954877a2ef54499db9b28a7cf9ebcf41",
5088
- # "from": "MAIN",
5089
- # "to": "CONTRACT",
5090
- # "transact_state": "SUCCESS"
5091
- # },
5092
- # ...
5093
- # ]
5094
- # }
5095
- # }
5096
5105
  #
5097
- data = self.safe_value(response, 'data', {})
5098
- resultList = self.safe_value(data, 'result_list', [])
5106
+ # {
5107
+ # "rows": [
5108
+ # {
5109
+ # "tranId": "cdf0d2a618b5458c965baefe6b1d0859",
5110
+ # "clientTranId": null,
5111
+ # "asset": "USDT",
5112
+ # "amount": "1",
5113
+ # "fromAccountType": "FUTURES",
5114
+ # "toAccountType": "SPOT",
5115
+ # "symbol": null,
5116
+ # "status": "SUCCESS",
5117
+ # "timestamp": 1759328309000
5118
+ # }
5119
+ # ],
5120
+ # "total": 1
5121
+ # }
5122
+ resultList = self.safe_list(response, 'rows', [])
5099
5123
  elif marketType == 'swap':
5100
5124
  if limit is not None:
5101
5125
  request['page_size'] = limit
5102
- response = self.contractPrivateGetAccountTransferRecord(self.extend(request, query))
5126
+ response = self.contractPrivateGetAccountTransferRecord(self.extend(request, params))
5103
5127
  data = self.safe_value(response, 'data')
5104
5128
  resultList = self.safe_value(data, 'resultList')
5105
5129
  #
@@ -5147,10 +5171,10 @@ class mexc(Exchange, ImplicitAPI):
5147
5171
  accounts: dict = {
5148
5172
  'spot': 'SPOT',
5149
5173
  'swap': 'FUTURES',
5150
- 'margin': 'ISOLATED_MARGIN',
5174
+ 'future': 'FUTURES',
5151
5175
  }
5152
- fromId = self.safe_string(accounts, fromAccount)
5153
- toId = self.safe_string(accounts, toAccount)
5176
+ fromId = self.safe_string(accounts, fromAccount, fromAccount)
5177
+ toId = self.safe_string(accounts, toAccount, toAccount)
5154
5178
  if fromId is None:
5155
5179
  keys = list(accounts.keys())
5156
5180
  raise ExchangeError(self.id + ' fromAccount must be one of ' + ', '.join(keys))
@@ -5208,6 +5232,17 @@ class mexc(Exchange, ImplicitAPI):
5208
5232
  # "createTime": "1648849076000",
5209
5233
  # "updateTime": "1648849076000"
5210
5234
  # }
5235
+ # {
5236
+ # "tranId": "cdf0d2a618b5458c965baefe6b1d0859",
5237
+ # "clientTranId": null,
5238
+ # "asset": "USDT",
5239
+ # "amount": "1",
5240
+ # "fromAccountType": "FUTURES",
5241
+ # "toAccountType": "SPOT",
5242
+ # "symbol": null,
5243
+ # "status": "SUCCESS",
5244
+ # "timestamp": 1759328309000
5245
+ # }
5211
5246
  #
5212
5247
  # transfer
5213
5248
  #
@@ -5215,14 +5250,19 @@ class mexc(Exchange, ImplicitAPI):
5215
5250
  # "tranId": "ebb06123e6a64f4ab234b396c548d57e"
5216
5251
  # }
5217
5252
  #
5218
- currencyId = self.safe_string(transfer, 'currency')
5253
+ currencyId = self.safe_string_2(transfer, 'currency', 'asset')
5219
5254
  id = self.safe_string_n(transfer, ['transact_id', 'txid', 'tranId'])
5220
- timestamp = self.safe_integer(transfer, 'createTime')
5255
+ timestamp = self.safe_integer_2(transfer, 'createTime', 'timestamp')
5221
5256
  datetime = self.iso8601(timestamp) if (timestamp is not None) else None
5222
5257
  direction = self.safe_string(transfer, 'type')
5223
5258
  accountFrom = None
5224
5259
  accountTo = None
5225
- if direction is not None:
5260
+ fromAccountType = self.safe_string(transfer, 'fromAccountType')
5261
+ toAccountType = self.safe_string(transfer, 'toAccountType')
5262
+ if (fromAccountType is not None) and (toAccountType is not None):
5263
+ accountFrom = fromAccountType
5264
+ accountTo = toAccountType
5265
+ elif direction is not None:
5226
5266
  accountFrom = 'MAIN' if (direction == 'IN') else 'CONTRACT'
5227
5267
  accountTo = 'CONTRACT' if (direction == 'IN') else 'MAIN'
5228
5268
  else:
@@ -5237,11 +5277,13 @@ class mexc(Exchange, ImplicitAPI):
5237
5277
  'amount': self.safe_number(transfer, 'amount'),
5238
5278
  'fromAccount': self.parse_account_id(accountFrom),
5239
5279
  'toAccount': self.parse_account_id(accountTo),
5240
- 'status': self.parse_transfer_status(self.safe_string_2(transfer, 'transact_state', 'state')),
5280
+ 'status': self.parse_transfer_status(self.safe_string_n(transfer, ['transact_state', 'state', 'status'])),
5241
5281
  }
5242
5282
 
5243
5283
  def parse_account_id(self, status):
5244
5284
  statuses: dict = {
5285
+ 'SPOT': 'spot',
5286
+ 'FUTURES': 'swap',
5245
5287
  'MAIN': 'spot',
5246
5288
  'CONTRACT': 'swap',
5247
5289
  }
mexc/ccxt/pro/__init__.py CHANGED
@@ -8,7 +8,7 @@ sys.modules['ccxt'] = ccxt_module
8
8
 
9
9
  # ----------------------------------------------------------------------------
10
10
 
11
- __version__ = '4.5.5'
11
+ __version__ = '4.5.7'
12
12
 
13
13
  # ----------------------------------------------------------------------------
14
14
 
mexc/ccxt/pro/mexc.py CHANGED
@@ -861,6 +861,7 @@ class mexc(mexcAsync):
861
861
  except Exception as e:
862
862
  del client.subscriptions[messageHash]
863
863
  client.reject(e, messageHash)
864
+ return
864
865
  client.resolve(storedOrderBook, messageHash)
865
866
 
866
867
  def handle_bookside_delta(self, bookside, bidasks):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mexc-exchange-api
3
- Version: 0.0.90
3
+ Version: 0.0.92
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
@@ -251,6 +251,7 @@ You can also construct custom requests to available "implicit" endpoints
251
251
  - `spot_private_get_mxdeduct_enable(request)`
252
252
  - `spot_private_get_userdatastream(request)`
253
253
  - `spot_private_get_selfsymbols(request)`
254
+ - `spot_private_get_asset_internal_transfer_record(request)`
254
255
  - `spot_private_post_order(request)`
255
256
  - `spot_private_post_order_test(request)`
256
257
  - `spot_private_post_sub_account_virtualsubaccount(request)`
@@ -1,11 +1,11 @@
1
1
  mexc/__init__.py,sha256=bFV_Nfz_k-lfB_ImsHGpFnJuVMUXLBRbttugnPV7c4A,222
2
- mexc/ccxt/__init__.py,sha256=VKEE054f-4uZ_4eJC6zaWi6xZs2OW_g01v8qlduLXMw,6126
3
- mexc/ccxt/mexc.py,sha256=Lw1oduV2Yz5Zn_0z-74eP5jTdZ78-vvem4xN5yJklY0,261023
4
- mexc/ccxt/abstract/mexc.py,sha256=oyg0sZFYs1d77F-_9QAatqMSQJ8h-1u1wWb-d1DX2zQ,26434
5
- mexc/ccxt/async_support/__init__.py,sha256=tJsfZg394jJaQ-tNcociRsiO31b_5qdgld4TF0uMtwk,4859
6
- mexc/ccxt/async_support/mexc.py,sha256=0T_xkvZHwCZoI1opouAZL8PkiYRW7BUtz33kxEqozCs,262293
2
+ mexc/ccxt/__init__.py,sha256=SwceHPCJuX7NC7VAF7UobvAGANETCebTrkiWp3VkSsM,6126
3
+ mexc/ccxt/mexc.py,sha256=jMADkRZIqSuX3S0iLEUrN2xJ9gh7teYqM9-l-ld3WoI,263123
4
+ mexc/ccxt/abstract/mexc.py,sha256=whLPllbBePbIrCwhJBWp4M7XPvz4PhheTlbcQExV_aY,26614
5
+ mexc/ccxt/async_support/__init__.py,sha256=kbxuES-cogQz-wWufKoLq6kVzT9VluOQsXIxO-IDESY,4859
6
+ mexc/ccxt/async_support/mexc.py,sha256=H7yNnH9lzQ_7ahs9CvV8cJk7iNpp8iGyDLMjyI1T8f4,264393
7
7
  mexc/ccxt/async_support/base/__init__.py,sha256=aVYSsFi--b4InRs9zDN_wtCpj8odosAB726JdUHavrk,67
8
- mexc/ccxt/async_support/base/exchange.py,sha256=zcjR7MUn8V80r5FKX8ifKeOXMg7cNSuEfxbhZ6PLteY,121432
8
+ mexc/ccxt/async_support/base/exchange.py,sha256=oRegJjkuRKReYdiDlqBdVWelkzXoyKbCTI8lskWBCGw,121432
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
@@ -16,12 +16,12 @@ mexc/ccxt/async_support/base/ws/order_book.py,sha256=uBUaIHhzMRykpmo4BCsdJ-t_Hoz
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
18
  mexc/ccxt/base/decimal_to_precision.py,sha256=3XI30u9YudHbTA438397u5rkdlXa3atxwZEfUus3C4k,6803
19
- mexc/ccxt/base/errors.py,sha256=OGhWNvNtRlJOzFx-n1x3ZjTnaPpfWH0Vc0xACS-MeDw,5012
20
- mexc/ccxt/base/exchange.py,sha256=pEYq-RPWeigwt4gmtNlP-wF7G-KD4NsY28n6YYIvBTE,338594
19
+ mexc/ccxt/base/errors.py,sha256=LdTTHPmxpeFHJze93mGl7I3maqTgN0y_1mJ6coWkXmA,4734
20
+ mexc/ccxt/base/exchange.py,sha256=z1TCuTKRamNgP_fnQGegYtaE8xe9sFz51x8QyeKZmUI,343891
21
21
  mexc/ccxt/base/precise.py,sha256=koce64Yrp6vFbGijJtUt-QQ6XhJgeGTCksZ871FPp_A,8886
22
22
  mexc/ccxt/base/types.py,sha256=Gvbogh9i7pPH7Z18xesYeDPribqqwq8uKpOv-YODFBs,11505
23
- mexc/ccxt/pro/__init__.py,sha256=nyzvWpOUQu1VPzNf916tl41lCMjKFVoZFbO0xWbtb5Q,4173
24
- mexc/ccxt/pro/mexc.py,sha256=C4I8i62DHdIs_yolMkhnbwZGLxBVwd66O_p9CH21VwE,77133
23
+ mexc/ccxt/pro/__init__.py,sha256=sDMWSoDelxaiuPwadS_k1gENqMrIbJNsLRi8nhkUClk,4173
24
+ mexc/ccxt/pro/mexc.py,sha256=F-GKatxBc-Z_R5Bxh_gtUt9gWDLtvSTg7RUGau5wB0s,77152
25
25
  mexc/ccxt/static_dependencies/README.md,sha256=3TCvhhn09_Cqf9BDDpao1V7EfKHDpQ6k9oWRsLFixpU,18
26
26
  mexc/ccxt/static_dependencies/__init__.py,sha256=tzFje8cloqmiIE6kola3EaYC0SnD1izWnri69hzHsSw,168
27
27
  mexc/ccxt/static_dependencies/ecdsa/__init__.py,sha256=Xaj0G79BLtBt2YZcOOMV8qOlQZ7fIJznNiHhiEEZfQA,594
@@ -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.90.dist-info/METADATA,sha256=gGjjhorEV9FAlUFOrEKKE5bYwz3MDHHOsOLBdYmFasA,18072
285
- mexc_exchange_api-0.0.90.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
286
- mexc_exchange_api-0.0.90.dist-info/RECORD,,
284
+ mexc_exchange_api-0.0.92.dist-info/METADATA,sha256=uuFSlD0PSB9r14C9a5WIfNjf0fzlfXchmPtUOdOZDkc,18133
285
+ mexc_exchange_api-0.0.92.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
286
+ mexc_exchange_api-0.0.92.dist-info/RECORD,,