Use more conservative 1e-6 to prevent division by zero.
This commit is contained in:
@@ -358,8 +358,8 @@ def calculate_market_conditions(df, lookback_window=180):
|
||||
df["Log_Return"] = df["Log_Return"].fillna(method="bfill")
|
||||
|
||||
# Recent vs historical volatility ratio
|
||||
recent_vol = max(df["Log_Return"].tail(30).std(), 1e-8) # Prevent division by zero
|
||||
historical_vol = max(df["Log_Return"].tail(lookback_window).std(), 1e-8)
|
||||
recent_vol = max(df["Log_Return"].tail(30).std(), 1e-6) # Prevent division by zero
|
||||
historical_vol = max(df["Log_Return"].tail(lookback_window).std(), 1e-6)
|
||||
metrics["vol_ratio"] = recent_vol / historical_vol
|
||||
|
||||
# Trend strength using log prices
|
||||
|
||||
Reference in New Issue
Block a user