ls증권 히스토리 구독 넣음
This commit is contained in:
@@ -230,18 +230,33 @@ def build_universe_timeline(
|
||||
debounce_sec: int = 30,
|
||||
strict: bool = False,
|
||||
strict_lag_minutes: int = 1,
|
||||
history_source: str = "kiwoom",
|
||||
) -> Optional[UniverseTimeline]:
|
||||
"""``target_candidates_history`` (strategy_id) → 초단위 유니버스 타임라인."""
|
||||
"""이력 테이블(키움/LS) → 초단위 유니버스 타임라인.
|
||||
|
||||
``history_source``: ``kiwoom`` | ``ls`` — resolve/슬롯 dict 와 **동일 소스**여야
|
||||
scan_at 매수가 라벨과 어긋나지 않는다.
|
||||
"""
|
||||
try:
|
||||
from kis_trader.database.db_manager import get_db
|
||||
from kis_trader.backtest.universe_history_source import (
|
||||
apply_ls_session_filter_to_start,
|
||||
normalize_universe_history_source,
|
||||
resolve_backtest_universe_history_source,
|
||||
)
|
||||
|
||||
hs = resolve_backtest_universe_history_source(history_source)
|
||||
hs = normalize_universe_history_source(hs)
|
||||
ext = get_db()
|
||||
start_time = f"{start_ymd[:4]}-{start_ymd[4:6]}-{start_ymd[6:8]} 00:00:00"
|
||||
start_time = apply_ls_session_filter_to_start(start_time, source=hs)
|
||||
end_time = f"{end_ymd[:4]}-{end_ymd[4:6]}-{end_ymd[6:8]} 23:59:59"
|
||||
events = ext.iter_universe_events(
|
||||
strategy_id=strategy_id,
|
||||
start_time=start_time,
|
||||
end_time=end_time,
|
||||
preserve_insert_order=True,
|
||||
history_source=hs,
|
||||
)
|
||||
normalized = normalize_universe_events(events)
|
||||
if not normalized:
|
||||
|
||||
Reference in New Issue
Block a user