Add weekend open skip, expiry force-close, and Chinese trade labels.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-07-25 10:28:33 +08:00
parent 826362b556
commit b50c134f5b
19 changed files with 525 additions and 52 deletions
+11 -2
View File
@@ -1,4 +1,4 @@
"""日历日分组键(开仓时间窗已取消,由期权剩余时长约束)。"""
"""日历日分组键;可选周末跳过开仓(上海时区)。"""
from __future__ import annotations
@@ -17,13 +17,22 @@ def window_key(now: datetime | None = None) -> str:
return now_sh(now).strftime("%Y%m%d")
def is_weekend(now: datetime | None = None) -> bool:
"""上海时区:周六=5、周日=6。"""
return now_sh(now).weekday() >= 5
def can_open_new(
now: datetime | None = None,
*,
skip_weekends: bool = True,
open_hhmm: str = "16:00",
stop_hhmm: str = "08:00",
) -> bool:
"""开仓窗已取消,始终允许(仍受期权剩余时长/杠杆筛选)"""
"""是否允许新开仓。开仓窗已取消;可选跳过周六日。持仓平仓不受此限制"""
_ = open_hhmm, stop_hhmm
if skip_weekends and is_weekend(now):
return False
return True