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: