From 41c62e1af235dcad00bdc4ec33e3a27585ba42f0 Mon Sep 17 00:00:00 2001 From: Sam Fredrickson Date: Sun, 17 Nov 2024 15:52:35 -0800 Subject: [PATCH] Use more conservative 1e-6 to prevent division by zero. --- model.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/model.py b/model.py index b090e6d..ecd9039 100644 --- a/model.py +++ b/model.py @@ -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