From 1698f09ad04bcc84c754486ceb508f49a824c159 Mon Sep 17 00:00:00 2001 From: John Doe Date: Sat, 18 Apr 2026 17:23:15 +0800 Subject: [PATCH] Fix bucket_prob: bounded ranges now use proper Gaussian CDF (was returning 0 for all finite ranges) --- bot_v3.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/bot_v3.py b/bot_v3.py index 9fb2964..86f4c71 100644 --- a/bot_v3.py +++ b/bot_v3.py @@ -81,11 +81,18 @@ def norm_cdf(x): return 0.5 * (1.0 + math.erf(x / math.sqrt(2.0))) def bucket_prob(forecast, t_low, t_high, sigma=2.0): + """ + Gaussian probability that forecast falls in [t_low, t_high]. + Uses error function (math.erf) — no scipy needed. + """ if t_low == -999: return norm_cdf((t_high - float(forecast)) / sigma) if t_high == 999: return 1.0 - norm_cdf((t_low - float(forecast)) / sigma) - return 1.0 if in_bucket(forecast, t_low, t_high) else 0.0 + # Bounded range: P(t_low <= X <= t_high) = CDF(t_high) - CDF(t_low) + z_low = (t_low - float(forecast)) / sigma + z_high = (t_high - float(forecast)) / sigma + return norm_cdf(z_high) - norm_cdf(z_low) def calc_ev(p, price): if price <= 0 or price >= 1: return 0.0