from pymexc import futures, spot from core.exchanges import BaseExchange, common from core.util import logs log = logs.get_logger("mexc") class MEXCExchange(BaseExchange): # def call_method(self, request): # ... def connect(self): self.client = spot.HTTP( api_key=self.account.api_key, api_secret=self.account.api_secret ) def get_account(self): # r = self.client.account_information() r = self.call("account_information") # {'makerCommission': None, 'takerCommission': None, # 'buyerCommission': None, 'sellerCommission': None, # 'canTrade': True, 'canWithdraw': True, 'canDeposit': True, # 'updateTime': None, 'accountType': 'SPOT', 'balances': [], # 'permissions': ['SPOT']} print("ACC INFO", r) return r def get_instruments(self): r = self.call("exchange_info") # {'timezone': 'CST', 'serverTime': 1732007199224, 'rateLimits': [], 'exchangeFilters': [], 'symbols': [{'symbol': 'TRUMP1USDT', 'status': '1', 'baseAsset': 'TRUMP1', 'baseAssetPrecision': 0, 'quoteAsset': 'USDT', 'quotePrecision': 15, 'quoteAssetPrecision': 15, 'baseCommissionPrecision': 0, 'quoteCommissionPrecision': 15, 'orderTypes': ['LIMIT', 'MARKET', 'LIMIT_MAKER'], 'isSpotTradingAllowed': True, 'isMarginTradingAllowed': False, 'quoteAmountPrecision': '1.000000000000000000000000000000', 'baseSizePrecision': '0', 'permissions': ['SPOT'], 'filters': [], 'maxQuoteAmount': '2000000.000000000000000000000000000000', 'makerCommission': '0', 'takerCommission': '0.0002', 'quoteAmountPrecisionMarket': '1.000000000000000000000000000000', 'maxQuoteAmountMarket': '100000.000000000000000000000000000000', 'fullName': 'SIMPSONTRUMP', 'tradeSideType': 1}, {'symbol': 'AESUSDT', 'status': '1', 'baseAsset': 'AES', 'baseAssetPrecision': 2, 'quoteAsset': 'USDT', 'quotePrecision': 7, 'quoteAssetPrecision': 7, 'baseCommissionPrecision': 2, 'quoteCommissionPrecision': 7, 'orderTypes': ['LIMIT', 'MARKET', 'LIMIT_MAKER'], 'isSpotTradingAllowed': True, 'isMarginTradingAllowed': False, 'quoteAmountPrecision': '1.000000000000000000000000000000', 'baseSizePrecision': '0', 'permissions': ['SPOT'], 'filters': [], 'maxQuoteAmount': '2000000.000000000000000000000000000000', 'makerCommission': '0', 'takerCommission': '0.0002', 'quoteAmountPrecisionMarket': '1.000000000000000000000000000000', 'maxQuoteAmountMarket': '100000.000000000000000000000000000000', 'fullName': 'Aree Shards', 'tradeSideType': 1}, {'symbol': 'NCDTUSDT', 'status': '1', 'baseAsset': 'NCDT', 'baseAssetPrecision': 2, 'quoteAsset': 'USDT', 'quotePrecision': 4, 'quoteAssetPrecision': 4, 'baseCommissionPrecision': 2, 'quoteCommissionPrecision': 4, 'orderTypes': ['LIMIT', 'MARKET', 'LIMIT_MAKER'], 'isSpotTradingAllowed': True, 'isMarginTradingAllowed': False, 'quoteAmountPrecision': '1.000000000000000000000000000000', 'baseSizePrecision': '0', 'permissions': ['SPOT'], 'filters': [], 'maxQuoteAmount': '2000000.000000000000000000000000000000', 'makerCommission': '0', 'takerCommission': '0.0002', 'quoteAmountPrecisionMarket': '1.000000000000000000000000000000', 'maxQuoteAmountMarket': '100000.000000000000000000000000000000', 'fullName': 'nuco.cloud', 'tradeSideType': 1}, {'symbol': 'ALEPHUSDT', 'status': '1', 'baseAsset': 'ALEPH', 'baseAssetPrecision': 2, 'quoteAsset': 'USDT', 'quotePrecision': 5, 'quoteAssetPrecision': 5, 'baseCommissionPrecision': 2, 'quoteCommissionPrecision': 5, 'orderTypes': ['LIMIT', 'MARKET', 'LIMIT_MAKER'], 'isSpotTradingAllowed': True, 'isMarginTradingAllowed': False, 'quoteAmountPrecision': '1.000000000000000000000000000000', 'baseSizePrecision': '5', 'permissions': ['SPOT'], 'filters': [], 'maxQuoteAmount': '2000000.000000000000000000000000000000', 'makerCommission': '0', 'takerCommission': '0.0002', 'quoteAmountPrecisionMarket': '1.000000000000000000000000000000', 'maxQuoteAmountMarket': '100000.000000000000000000000000000000', 'fullName': 'Alephim', 'tradeSideType': 1}, {'symbol': 'ORNJUSDT', 'status': '1', 'baseAsset': 'ORNJ', 'baseAssetPrecision': 2, 'quoteAsset': 'USDT', 'quotePrecision': 5, 'quoteAssetPrecision': 5, 'baseCommissionPrecision': 2, 'quoteCommissionPrecision': 5, 'orderTypes': ['LIMIT', 'MARKET', 'LIMIT_MAKER'], 'isSpotTradingAllowed': False, 'isMarginTradingAllowed': False, 'quoteAmountPrecision': '1.000000000000000000000000000000', 'baseSizePrecision': '0', 'permissions': ['SPOT'], 'filters': [], 'maxQuoteAmount': '2000000.000000000000000000000000000000', 'makerCommission': '0', 'takerCommission': '0.0002', 'quoteAmountPrecisionMarket': '1.000000000000000000000000000000', 'maxQuoteAmountMarket': '100000.000000000000000000000000000000', 'fullName': 'Orange', 'tradeSideType': 1}, {'symbol': 'OGNUSDT', 'status': '1', 'baseAsset': 'OGN', 'baseAssetPrecision': 2, 'quoteAsset': 'USDT', 'quotePrecision': 5, 'quoteAssetPrecision': 5, 'baseCommissionPrecision': 2, 'quoteCommissionPrecision': 5, 'orderTypes': ['LIMIT', 'MARKET', 'LIMIT_MAKER'], 'isSpotTradingAllowed': True, 'isMarginTradingAllowed': False, 'quoteAmountPrecision': '1.000000000000000000000000000000', 'baseSizePrecision': '0.01', 'permissions': ['SPOT'], 'filters': [], 'maxQuoteAmount': '2000000.000000000000000000000000000000', 'makerCommission': '0', 'takerCommission': '0.0002', 'quoteAmountPrecisionMarket': '1.000000000000000000000000000000', 'maxQuoteAmountMarket': '100000.000000000000000000000000000000', 'fullName': 'Origin', 'tradeSideType': 1}, {'symbol': 'HCUSDT', 'status': '1', 'baseAsset': 'HC', 'baseAssetPrecision': 2, 'quoteAsset': 'USDT', 'quotePrecision': 5, 'quoteAssetPrecision': 5, 'baseCommissionPrecision': 2, 'quoteCommissionPrecision': 5, 'orderTypes': ['LIMIT', 'MARKET', 'LIMIT_MAKER'], 'isSpotTradingAllowed': True, 'isMarginTradingAllowed': False, 'quoteAmountPrecision': '1.000000000000000000000000000000', 'baseSizePrecision': '0.001', 'permissions': ['SPOT'], 'filters': [], 'maxQuoteAmount': '2000000.000000000000000000000000000000', 'makerCommission': '0', 'takerCommission': '0.0002', 'quoteAmountPrecisionMarket': '1.000000000000000000000000000000', 'maxQuoteAmountMarket': '100000.000000000000000000000000000000', 'fullName': 'Hshare', 'tradeSideType': 1}, return r def get_currencies(self, currencies): ... def get_supported_assets(self, response=None): if not response: response = self.get_instruments() symbols = response["symbols"] supported_assets = [x["symbol"] for x in symbols] return supported_assets def get_balance(self, return_usd=False): ... def get_market_value(self, symbol): raise NotImplementedError def post_trade(self, trade): ... def get_trade_precision(self, symbol): ... def close_trade(self, trade_id, units=None, symbol=None): ... def get_trade(self, trade_id): ... def update_trade(self, trade_id, take_profit_price, stop_loss_price): ... def cancel_trade(self, trade_id): ... def get_position_info(self, symbol): ... def get_all_positions(self): ... def get_all_open_trades(self): ... def close_position(self, side, symbol): ... def close_all_positions(self): ...