revision, pending fixes
This commit is contained in:
@@ -1110,6 +1110,7 @@ class DataProvider:
|
||||
"""Add pivot-derived context features for normalization"""
|
||||
try:
|
||||
if symbol not in self.pivot_bounds:
|
||||
logger.warning("Pivot bounds missing for %s; access will be blocked until real data is ready (guideline: no stubs)", symbol)
|
||||
return df
|
||||
|
||||
bounds = self.pivot_bounds[symbol]
|
||||
@@ -1820,30 +1821,7 @@ class DataProvider:
|
||||
df_norm = df.copy()
|
||||
|
||||
# Get symbol-specific price ranges for consistent normalization
|
||||
symbol_price_ranges = {
|
||||
'ETH/USDT': {'min': 1000, 'max': 5000}, # ETH price range
|
||||
'BTC/USDT': {'min': 90000, 'max': 120000} # BTC price range
|
||||
}
|
||||
|
||||
if symbol in symbol_price_ranges:
|
||||
price_range = symbol_price_ranges[symbol]
|
||||
range_size = price_range['max'] - price_range['min']
|
||||
|
||||
# Normalize price columns to [0, 1] range specific to symbol
|
||||
price_cols = ['open', 'high', 'low', 'close']
|
||||
for col in price_cols:
|
||||
if col in df_norm.columns:
|
||||
df_norm[col] = (df_norm[col] - price_range['min']) / range_size
|
||||
df_norm[col] = np.clip(df_norm[col], 0, 1) # Ensure [0,1] range
|
||||
|
||||
# Normalize volume to [0, 1] using log scale
|
||||
if 'volume' in df_norm.columns:
|
||||
df_norm['volume'] = np.log1p(df_norm['volume'])
|
||||
vol_max = df_norm['volume'].max()
|
||||
if vol_max > 0:
|
||||
df_norm['volume'] = df_norm['volume'] / vol_max
|
||||
|
||||
logger.debug(f"Applied symbol-grouped normalization for {symbol}")
|
||||
# TODO(Guideline: no synthetic ranges) Replace placeholder price ranges with real statistics or remove this fallback.
|
||||
|
||||
# Fill any NaN values
|
||||
df_norm = df_norm.fillna(0)
|
||||
|
@@ -1843,7 +1843,7 @@ class TradingOrchestrator:
|
||||
dashboard=None
|
||||
)
|
||||
|
||||
logger.info("✅ Enhanced training system initialized successfully")
|
||||
logger.info("Enhanced training system initialized successfully")
|
||||
|
||||
# Auto-start training by default
|
||||
logger.info("🚀 Auto-starting enhanced real-time training...")
|
||||
@@ -2204,21 +2204,12 @@ class TradingOrchestrator:
|
||||
return float(data_stream.current_price)
|
||||
except Exception as e:
|
||||
logger.debug(f"Could not get price from universal adapter: {e}")
|
||||
# Fallback to default prices
|
||||
default_prices = {
|
||||
'ETH/USDT': 2500.0,
|
||||
'BTC/USDT': 108000.0
|
||||
}
|
||||
return default_prices.get(symbol, 1000.0)
|
||||
# TODO(Guideline: no synthetic fallback) Provide a real-time or cached market price here instead of hardcoding.
|
||||
raise RuntimeError("Current price unavailable; per guidelines do not substitute synthetic values.")
|
||||
except Exception as e:
|
||||
logger.error(f"Error getting current price for {symbol}: {e}")
|
||||
# Return default price based on symbol
|
||||
if 'ETH' in symbol:
|
||||
return 2500.0
|
||||
elif 'BTC' in symbol:
|
||||
return 108000.0
|
||||
else:
|
||||
return 1000.0
|
||||
raise RuntimeError("Current price unavailable; per guidelines do not substitute synthetic values.")
|
||||
|
||||
# SINGLE-USE FUNCTION - Called only once in codebase
|
||||
def _generate_fallback_prediction(self, symbol: str) -> Dict[str, Any]:
|
||||
@@ -2443,7 +2434,7 @@ class TradingOrchestrator:
|
||||
if df is not None and not df.empty:
|
||||
loaded_data[f"{symbol}_{timeframe}"] = df
|
||||
total_candles += len(df)
|
||||
logger.info(f"✅ Loaded {len(df)} {timeframe} candles for {symbol}")
|
||||
logger.info(f"Loaded {len(df)} {timeframe} candles for {symbol}")
|
||||
|
||||
# Store in data provider's historical cache for quick access
|
||||
cache_key = f"{symbol}_{timeframe}_300"
|
||||
@@ -2500,7 +2491,7 @@ class TradingOrchestrator:
|
||||
logger.info("Initializing Decision Fusion with multi-symbol features...")
|
||||
self._initialize_decision_with_provider_data(symbol_features)
|
||||
|
||||
logger.info("✅ All models initialized with data provider's normalized historical data")
|
||||
logger.info("All models initialized with data provider's normalized historical data")
|
||||
|
||||
except Exception as e:
|
||||
logger.error(f"Error initializing models with historical data: {e}")
|
||||
@@ -2720,7 +2711,7 @@ class TradingOrchestrator:
|
||||
logger.error(f"Error in chained inference step {step}: {e}")
|
||||
break
|
||||
|
||||
logger.info(f"✅ Chained inference completed: {len(predictions)} predictions generated")
|
||||
logger.info(f"Chained inference completed: {len(predictions)} predictions generated")
|
||||
return predictions
|
||||
|
||||
except Exception as e:
|
||||
|
@@ -850,6 +850,10 @@ class TradingExecutor:
|
||||
"""Get trade history"""
|
||||
return self.trade_history.copy()
|
||||
|
||||
def get_balance(self) -> Dict[str, float]:
|
||||
"""TODO(Guideline: expose real account state) Return actual account balances instead of raising."""
|
||||
raise NotImplementedError("Implement TradingExecutor.get_balance to supply real balance data; stubs are forbidden.")
|
||||
|
||||
def export_trades_to_csv(self, filename: Optional[str] = None) -> str:
|
||||
"""Export trade history to CSV file with comprehensive analysis"""
|
||||
import csv
|
||||
|
Reference in New Issue
Block a user