fisk/core/exchanges/mexc.py

83 lines
7.1 KiB
Python
Raw Normal View History

2024-12-03 14:12:42 +00:00
from pymexc import futures, spot
2024-11-16 17:31:43 +00:00
from core.exchanges import BaseExchange, common
from core.util import logs
log = logs.get_logger("mexc")
class MEXCExchange(BaseExchange):
2024-12-03 14:12:42 +00:00
# def call_method(self, request):
# ...
2024-11-16 17:31:43 +00:00
def connect(self):
self.client = spot.HTTP(
2024-12-03 14:12:42 +00:00
api_key=self.account.api_key, api_secret=self.account.api_secret
)
2024-11-16 17:31:43 +00:00
def get_account(self):
2024-12-03 14:12:42 +00:00
# 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']}
2024-11-16 17:31:43 +00:00
print("ACC INFO", r)
2024-12-03 14:12:42 +00:00
return r
2024-11-16 17:31:43 +00:00
def get_instruments(self):
2024-12-03 14:12:42 +00:00
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'
return r
2024-11-16 17:31:43 +00:00
def get_currencies(self, currencies):
...
def get_supported_assets(self, response=None):
2024-12-03 14:12:42 +00:00
if not response:
response = self.get_instruments()
symbols = response["symbols"]
supported_assets = [x["symbol"] for x in symbols]
return supported_assets
2024-11-16 17:31:43 +00:00
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):
...