fix indentations

This commit is contained in:
Dobromir Popov
2025-07-03 03:02:58 +03:00
parent 8bacf3c537
commit 978cecf0c5

View File

@ -49,14 +49,14 @@ class MEXCInterface(ExchangeInterface):
"""Test connection to MEXC API by fetching account info.""" """Test connection to MEXC API by fetching account info."""
if not self.api_key or not self.api_secret: if not self.api_key or not self.api_secret:
logger.error("MEXC API key or secret not set. Cannot connect.") logger.error("MEXC API key or secret not set. Cannot connect.")
return False return False
# Test connection by making a small, authenticated request # Test connection by making a small, authenticated request
try: try:
account_info = self.get_account_info() account_info = self.get_account_info()
if account_info: if account_info:
logger.info("Successfully connected to MEXC API and retrieved account info.") logger.info("Successfully connected to MEXC API and retrieved account info.")
return True return True
else: else:
logger.error("Failed to connect to MEXC API: Could not retrieve account info.") logger.error("Failed to connect to MEXC API: Could not retrieve account info.")
return False return False
@ -182,7 +182,7 @@ class MEXCInterface(ExchangeInterface):
if balance.get('asset') == asset.upper(): if balance.get('asset') == asset.upper():
return float(balance.get('free', 0.0)) return float(balance.get('free', 0.0))
logger.warning(f"Could not retrieve free balance for {asset}") logger.warning(f"Could not retrieve free balance for {asset}")
return 0.0 return 0.0
def get_ticker(self, symbol: str) -> Optional[Dict[str, Any]]: def get_ticker(self, symbol: str) -> Optional[Dict[str, Any]]:
"""Get ticker information for a symbol.""" """Get ticker information for a symbol."""
@ -190,13 +190,13 @@ class MEXCInterface(ExchangeInterface):
endpoint = "ticker/24hr" endpoint = "ticker/24hr"
params = {'symbol': formatted_symbol} params = {'symbol': formatted_symbol}
response = self._send_public_request('GET', endpoint, params) response = self._send_public_request('GET', endpoint, params)
if response: if response:
# MEXC ticker returns a dictionary if single symbol, list if all symbols # MEXC ticker returns a dictionary if single symbol, list if all symbols
if isinstance(response, dict): if isinstance(response, dict):
ticker_data = response ticker_data = response
elif isinstance(response, list) and len(response) > 0: elif isinstance(response, list) and len(response) > 0:
# If the response is a list, try to find the specific symbol # If the response is a list, try to find the specific symbol
found_ticker = next((item for item in response if item.get('symbol') == formatted_symbol), None) found_ticker = next((item for item in response if item.get('symbol') == formatted_symbol), None)
if found_ticker: if found_ticker:
@ -264,7 +264,7 @@ class MEXCInterface(ExchangeInterface):
order_result = self._send_private_request('POST', endpoint, params) order_result = self._send_private_request('POST', endpoint, params)
if order_result: if order_result:
logger.info(f"MEXC: Order placed successfully: {order_result}") logger.info(f"MEXC: Order placed successfully: {order_result}")
return order_result return order_result
else: else:
logger.error(f"MEXC: Error placing order: {order_result}") logger.error(f"MEXC: Error placing order: {order_result}")
return {} return {}
@ -329,7 +329,7 @@ class MEXCInterface(ExchangeInterface):
open_orders = self._send_private_request('GET', endpoint, params) open_orders = self._send_private_request('GET', endpoint, params)
if open_orders and isinstance(open_orders, list): if open_orders and isinstance(open_orders, list):
logger.info(f"MEXC: Retrieved {len(open_orders)} open orders.") logger.info(f"MEXC: Retrieved {len(open_orders)} open orders.")
return open_orders return open_orders
else: else:
logger.error(f"MEXC: Error getting open orders: {open_orders}") logger.error(f"MEXC: Error getting open orders: {open_orders}")
return [] return []