Label night-session products and hide day-only symbols at night.
Mark tradable varieties with a night tag; during 21:00-02:30 filter out index futures and other products without night sessions from symbol picker and recommend list. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -45,6 +45,19 @@ def is_trading_session(now: Optional[datetime] = None) -> bool:
|
||||
return False
|
||||
|
||||
|
||||
def is_night_trading_session(now: Optional[datetime] = None) -> bool:
|
||||
"""当前是否处于夜盘时段(21:00–02:30,且整体仍在交易时段内)。"""
|
||||
if not is_trading_session(now):
|
||||
return False
|
||||
d = now or datetime.now(TZ)
|
||||
if d.tzinfo is None:
|
||||
d = d.replace(tzinfo=TZ)
|
||||
else:
|
||||
d = d.astimezone(TZ)
|
||||
t = d.hour * 60 + d.minute
|
||||
return t >= 21 * 60 or t < 2 * 60 + 30
|
||||
|
||||
|
||||
def _session_open_allowed(day: datetime, hour: int, minute: int) -> bool:
|
||||
wd = day.weekday()
|
||||
if (hour, minute) == (9, 0) or (hour, minute) == (13, 30):
|
||||
|
||||
Reference in New Issue
Block a user