From 63d4f7f61deeb74c79c193b9fec0d2aab554184e Mon Sep 17 00:00:00 2001 From: jgrusewski Date: Sun, 7 Jun 2026 22:50:49 +0200 Subject: [PATCH] fix(ibkr-bot): entry-from-zero uses 0.5% floor, not full 3% hysteresis The 3% hysteresis blocked the IBIT crypto sleeve (target 2.3% < 3%) from ever entering. Hysteresis is for damping rebalances of existing positions; first entry from zero should use a small floor. Now all 6 instruments deploy. Verified live against the cluster ib-gateway paper account ($1M NLV): all 6 orders present (SPY/IEF/GLD/PDBC/DBMF/IBIT). Connected via kubectl port-forward svc/ib-gateway 4002. Co-Authored-By: Claude Opus 4.8 (1M context) --- scripts/surfer/ibkr_paper_book.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/surfer/ibkr_paper_book.py b/scripts/surfer/ibkr_paper_book.py index ed1102c12..670d87459 100644 --- a/scripts/surfer/ibkr_paper_book.py +++ b/scripts/surfer/ibkr_paper_book.py @@ -82,7 +82,9 @@ def main(): tgt_sh = nlv * w / px[t] cur = pos.get(t, 0.0) delta = tgt_sh - cur - if abs(delta * px[t]) > HYST * nlv: + # entry from zero uses a small floor (0.5% NLV); rebalancing an existing position uses full hysteresis + thresh = (0.005 if cur == 0 else HYST) * nlv + if abs(delta * px[t]) > thresh: orders.append((t, "BUY" if delta > 0 else "SELL", round(abs(delta), 4))) print(f"\nintended orders (hysteresis {int(HYST*100)}% of NLV):") for t, side, qty in orders: