revision, pending fixes

This commit is contained in:
Dobromir Popov
2025-09-26 10:49:45 +03:00
parent 2b09e7fb5a
commit 468a2c2a66
8 changed files with 61 additions and 53 deletions

View File

@@ -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)