27 lines
658 B
Python
27 lines
658 B
Python
"""
|
|
세션 HHMM 판별 — 국내(당일 구간) / 해외(자정 넘김 RTH) 공통.
|
|
|
|
국내 기본: start <= hm < end (예: 900~1430)
|
|
해외 야간: wrap_midnight 이고 start > end 이면 hm>=start or hm<end (예: 2230~0500 KST)
|
|
"""
|
|
from __future__ import annotations
|
|
|
|
|
|
def hm_in_trading_window(
|
|
hm: int,
|
|
start_hm: int,
|
|
end_hm: int,
|
|
*,
|
|
wrap_midnight: bool = False,
|
|
) -> bool:
|
|
"""True = 매매 허용 시각."""
|
|
try:
|
|
h = int(hm)
|
|
s = int(start_hm)
|
|
e = int(end_hm)
|
|
except (TypeError, ValueError):
|
|
return False
|
|
if wrap_midnight and s > e:
|
|
return h >= s or h < e
|
|
return s <= h < e
|