This commit is contained in:
Dobromir Popov
2025-06-19 16:20:26 +03:00
parent bf55ba5b51
commit d902e01197
2 changed files with 29 additions and 6 deletions

View File

@ -698,14 +698,29 @@ class MEXCInterface(ExchangeInterface):
# MEXC API endpoint for account commission rates
account_info = self._send_private_request('GET', 'account', {})
# Extract commission rates from account info
# Extract commission rates from account info with null safety
# MEXC typically returns commission rates in the account response
maker_commission = account_info.get('makerCommission', 0)
taker_commission = account_info.get('takerCommission', 0)
# Convert from basis points to decimal (MEXC uses basis points: 10 = 0.001%)
maker_rate = maker_commission / 100000 # Convert from basis points
taker_rate = taker_commission / 100000
# Fix: Add null safety checks to prevent division by None
if maker_commission is None:
logger.warning("MEXC API returned None for makerCommission, using fallback")
maker_commission = 0
if taker_commission is None:
logger.warning("MEXC API returned None for takerCommission, using fallback")
taker_commission = 50 # 0.05% fallback
# Convert from basis points to decimal with additional safety
try:
maker_rate = float(maker_commission) / 100000 # Convert from basis points
taker_rate = float(taker_commission) / 100000
except (TypeError, ValueError) as e:
logger.error(f"Error converting commission rates: maker={maker_commission}, taker={taker_commission}, error={e}")
# Use safe fallback values
maker_rate = 0.0000 # 0.00%
taker_rate = 0.0005 # 0.05%
logger.info(f"MEXC: Retrieved trading fees - Maker: {maker_rate*100:.3f}%, Taker: {taker_rate*100:.3f}%")
@ -720,7 +735,7 @@ class MEXCInterface(ExchangeInterface):
except Exception as e:
logger.error(f"Error getting MEXC trading fees: {e}")
# Return fallback values
# Return safe fallback values
return {
'maker_rate': 0.0000, # 0.00% fallback
'taker_rate': 0.0005, # 0.05% fallback

View File

@ -2413,7 +2413,7 @@ class EnhancedTradingOrchestrator(TradingOrchestrator):
# Get the best prediction
best_pred = max(predictions, key=lambda p: p.overall_confidence)
confidence = best_pred.overall_confidence
raw_action = best_pred.action
raw_action = best_pred.overall_action
# Update dynamic thresholds periodically
if hasattr(self, '_last_threshold_update'):
@ -2884,6 +2884,10 @@ class EnhancedTradingOrchestrator(TradingOrchestrator):
async def start_cob_integration(self):
"""Start COB integration for real-time data feed"""
try:
if self.cob_integration is None:
logger.warning("COB integration is disabled (cob_integration=None)")
return
logger.info("Starting COB integration for real-time market microstructure...")
await self.cob_integration.start()
logger.info("COB integration started successfully")
@ -2893,6 +2897,10 @@ class EnhancedTradingOrchestrator(TradingOrchestrator):
async def stop_cob_integration(self):
"""Stop COB integration"""
try:
if self.cob_integration is None:
logger.debug("COB integration is disabled (cob_integration=None)")
return
await self.cob_integration.stop()
logger.info("COB integration stopped")
except Exception as e: