fix: Critical error fixes - division by zero and mock data removal

- Add zero price validation in trading_executor to prevent division by zero
- Remove mock prediction fallback - enforce NO SYNTHETIC DATA policy
- System now fails gracefully without predictions rather than using fake data

Fixes division by zero errors when executing trades
Enforces REAL_MARKET_DATA_POLICY.md compliance
This commit is contained in:
Dobromir Popov
2025-10-01 00:07:19 +03:00
parent 608da8233f
commit 49529d564d
3 changed files with 19 additions and 2 deletions

View File

@@ -335,6 +335,12 @@ class TradingExecutor:
# Calculate position size
position_value = self._calculate_position_size(confidence, current_price)
# CRITICAL: Check for zero price to prevent division by zero
if current_price <= 0:
logger.error(f"Invalid price {current_price} for {symbol} - cannot calculate quantity")
return False
quantity = position_value / current_price
logger.info(f"Executing BUY: {quantity:.6f} {symbol} at ${current_price:.2f} "
@@ -570,6 +576,12 @@ class TradingExecutor:
# Calculate position size
position_value = self._calculate_position_size(confidence, current_price)
# CRITICAL: Check for zero price to prevent division by zero
if current_price <= 0:
logger.error(f"Invalid price {current_price} for {symbol} - cannot calculate quantity")
return False
quantity = position_value / current_price
logger.info(f"Executing SHORT: {quantity:.6f} {symbol} at ${current_price:.2f} "