Add option close liquidity gate with 30% bid/mark cap.
Block new opens while flat legs wait; emergency close bypasses the check. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
from datetime import datetime
|
||||
from zoneinfo import ZoneInfo
|
||||
|
||||
from app.sim.liquidity import bid_mark_ok
|
||||
from app.sim.pricing import option_fill, perp_fill
|
||||
from app.strategy.clock import can_open_new, window_key
|
||||
from app.strategy.exits import check_exits
|
||||
@@ -61,3 +62,14 @@ def test_window_always_open() -> None:
|
||||
n2 = datetime(2026, 7, 24, 10, 0, tzinfo=_SH)
|
||||
assert can_open_new(n2) is True
|
||||
assert window_key(n2) == "20260724"
|
||||
|
||||
|
||||
def test_bid_mark_deviation_30pct() -> None:
|
||||
# |7-10|/10 = 30% → 允许(≤30%)
|
||||
ok, _ = bid_mark_ok(bid=7.0, mark=10.0, max_dev_pct=30)
|
||||
assert ok is True
|
||||
ok2, _ = bid_mark_ok(bid=6.9, mark=10.0, max_dev_pct=30)
|
||||
assert ok2 is False
|
||||
ok3, why = bid_mark_ok(bid=None, mark=10.0, max_dev_pct=30)
|
||||
assert ok3 is False
|
||||
assert "买一" in why
|
||||
|
||||
Reference in New Issue
Block a user