bugfixes
This commit is contained in:
@ -698,14 +698,29 @@ class MEXCInterface(ExchangeInterface):
|
|||||||
# MEXC API endpoint for account commission rates
|
# MEXC API endpoint for account commission rates
|
||||||
account_info = self._send_private_request('GET', 'account', {})
|
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
|
# MEXC typically returns commission rates in the account response
|
||||||
maker_commission = account_info.get('makerCommission', 0)
|
maker_commission = account_info.get('makerCommission', 0)
|
||||||
taker_commission = account_info.get('takerCommission', 0)
|
taker_commission = account_info.get('takerCommission', 0)
|
||||||
|
|
||||||
# Convert from basis points to decimal (MEXC uses basis points: 10 = 0.001%)
|
# Fix: Add null safety checks to prevent division by None
|
||||||
maker_rate = maker_commission / 100000 # Convert from basis points
|
if maker_commission is None:
|
||||||
taker_rate = taker_commission / 100000
|
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}%")
|
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:
|
except Exception as e:
|
||||||
logger.error(f"Error getting MEXC trading fees: {e}")
|
logger.error(f"Error getting MEXC trading fees: {e}")
|
||||||
# Return fallback values
|
# Return safe fallback values
|
||||||
return {
|
return {
|
||||||
'maker_rate': 0.0000, # 0.00% fallback
|
'maker_rate': 0.0000, # 0.00% fallback
|
||||||
'taker_rate': 0.0005, # 0.05% fallback
|
'taker_rate': 0.0005, # 0.05% fallback
|
||||||
|
@ -2413,7 +2413,7 @@ class EnhancedTradingOrchestrator(TradingOrchestrator):
|
|||||||
# Get the best prediction
|
# Get the best prediction
|
||||||
best_pred = max(predictions, key=lambda p: p.overall_confidence)
|
best_pred = max(predictions, key=lambda p: p.overall_confidence)
|
||||||
confidence = best_pred.overall_confidence
|
confidence = best_pred.overall_confidence
|
||||||
raw_action = best_pred.action
|
raw_action = best_pred.overall_action
|
||||||
|
|
||||||
# Update dynamic thresholds periodically
|
# Update dynamic thresholds periodically
|
||||||
if hasattr(self, '_last_threshold_update'):
|
if hasattr(self, '_last_threshold_update'):
|
||||||
@ -2884,6 +2884,10 @@ class EnhancedTradingOrchestrator(TradingOrchestrator):
|
|||||||
async def start_cob_integration(self):
|
async def start_cob_integration(self):
|
||||||
"""Start COB integration for real-time data feed"""
|
"""Start COB integration for real-time data feed"""
|
||||||
try:
|
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...")
|
logger.info("Starting COB integration for real-time market microstructure...")
|
||||||
await self.cob_integration.start()
|
await self.cob_integration.start()
|
||||||
logger.info("COB integration started successfully")
|
logger.info("COB integration started successfully")
|
||||||
@ -2893,6 +2897,10 @@ class EnhancedTradingOrchestrator(TradingOrchestrator):
|
|||||||
async def stop_cob_integration(self):
|
async def stop_cob_integration(self):
|
||||||
"""Stop COB integration"""
|
"""Stop COB integration"""
|
||||||
try:
|
try:
|
||||||
|
if self.cob_integration is None:
|
||||||
|
logger.debug("COB integration is disabled (cob_integration=None)")
|
||||||
|
return
|
||||||
|
|
||||||
await self.cob_integration.stop()
|
await self.cob_integration.stop()
|
||||||
logger.info("COB integration stopped")
|
logger.info("COB integration stopped")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
Reference in New Issue
Block a user