Shorten force-close window to 5m and grey-out open during blocks.
Unify Gate/OKX/Binance: disable the open button with a side note during force-close, cooloff, and daily freeze, and enforce the same gate server-side. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -49,7 +49,8 @@ def test_next_force_close_after_trigger_same_day():
|
||||
|
||||
|
||||
def test_executing_window_and_countdown():
|
||||
now = _ms(2026, 7, 6, 0, 14)
|
||||
# 默认宽限 5 分钟:00:04 仍在执行窗
|
||||
now = _ms(2026, 7, 6, 0, 4)
|
||||
assert is_force_close_executing(0, now_ms=now, tz_name="Asia/Shanghai")
|
||||
assert is_force_close_active_hour(0, now_ms=now, tz_name="Asia/Shanghai")
|
||||
state = build_force_close_state(
|
||||
@@ -57,17 +58,21 @@ def test_executing_window_and_countdown():
|
||||
)
|
||||
assert state["enabled"] is True
|
||||
assert state["active"] is True
|
||||
assert state["executing"] is True
|
||||
assert state["grace_minutes"] == 5
|
||||
assert state["countdown"] == "执行中"
|
||||
assert state["next_at_ms"] == _ms(2026, 7, 7, 0, 0)
|
||||
|
||||
|
||||
def test_not_executing_after_grace_without_positions():
|
||||
now = _ms(2026, 7, 7, 0, 18)
|
||||
# 默认宽限 5 分钟:00:05 起已离开执行窗
|
||||
now = _ms(2026, 7, 7, 0, 5)
|
||||
assert not is_force_close_executing(0, now_ms=now, tz_name="Asia/Shanghai")
|
||||
state = build_force_close_state(
|
||||
True, 0, now_ms=now, tz_name="Asia/Shanghai", has_active_positions=False
|
||||
)
|
||||
assert state["active"] is False
|
||||
assert state["executing"] is False
|
||||
assert state["countdown"] != "执行中"
|
||||
assert state["next_at_ms"] == _ms(2026, 7, 8, 0, 0)
|
||||
|
||||
@@ -85,6 +90,8 @@ def test_format_countdown():
|
||||
|
||||
def test_infer_force_close_from_closed_at():
|
||||
assert is_close_at_force_close_window("2026-07-07 00:00", 0)
|
||||
assert is_close_at_force_close_window("2026-07-07 00:04", 0)
|
||||
assert not is_close_at_force_close_window("2026-07-07 00:05", 0)
|
||||
assert infer_force_close_result("2026-07-07 00:00", enabled=True, bj_hour=0) == "强制清仓"
|
||||
assert infer_force_close_result("2026-07-07 00:20", enabled=True, bj_hour=0) is None
|
||||
|
||||
|
||||
Reference in New Issue
Block a user