chore: 작업 중 발생한 부수적 변경 사항 및 누락된 파일 전체 커밋
- 프론트엔드 UI 업데이트 (backtest.html, backtest.js) 엔진 라디오 버튼 통합 관련 반영 - Rust 플러그인(kis_rust_core) 및 컴파일 소스코드 추가 - CLI 백테스트 스크립트 수정 및 최신화 - 기타 스크래치 테스트 스크립트, 로그 요약 마크다운(.md) 등 누락 파일 일괄 반영 - 추가적으로 아직 발견되지 않은 엣지 케이스나 렌더링 오류가 포함되어 있을 가능성이 있음
This commit is contained in:
@@ -47,7 +47,7 @@ from kis_trader.backtest.param_search_cli_common import (
|
||||
from kis_trader.backtest.tail_param_search import _results_dir_for_write
|
||||
from kis_trader.strategies.breakout import breakout_backtest_wants_tick_replay, breakout_entry_mode
|
||||
from kis_trader.engine.indicator_cache import attach_indicator_caches_to_params
|
||||
from kis_trader.backtest.breakout_tick_loader import load_breakout_ticks_by_code
|
||||
from kis_trader.backtest.breakout_tick_loader import load_common_ticks_by_code
|
||||
from kis_trader.utils.env import get_env_bool
|
||||
|
||||
logger = logging.getLogger("param_search_optuna")
|
||||
@@ -113,6 +113,9 @@ def prepare_breakout_search_context(
|
||||
grid = grids[mode]
|
||||
|
||||
base_fixed = _bo_fixed_defaults()
|
||||
if os.environ.get("BACKTEST_USE_RUST") == "1":
|
||||
base_fixed["use_rust"] = True
|
||||
|
||||
if mode == "tpe":
|
||||
base_fixed["skip_hts_scan_dupes"] = False
|
||||
apply_session_to_fixed(base_fixed, time_start_hm=time_start_hm, time_end_hm=time_end_hm)
|
||||
@@ -233,7 +236,7 @@ def prepare_breakout_search_context(
|
||||
)
|
||||
logger.info("✅ ls_ws_ticks %s건", f"{tick_rows:,}")
|
||||
else:
|
||||
ticks_by_code, tick_rows = load_breakout_ticks_by_code(
|
||||
ticks_by_code, tick_rows = load_common_ticks_by_code(
|
||||
_tick_db, start_key, end_key, set(codes_candles.keys()),
|
||||
)
|
||||
logger.info("✅ ws_ticks %s건", f"{tick_rows:,}")
|
||||
@@ -334,6 +337,24 @@ def prepare_breakout_search_context(
|
||||
|
||||
cache_holder: Dict[str, Any] = {}
|
||||
attach_indicator_caches_to_params(cache_holder, codes_candles)
|
||||
if universe_by_slot is not None:
|
||||
from kis_trader.backtest.universe_timeline import build_universe_timeline
|
||||
from kis_trader.backtest.breakout_backtest_common import BREAKOUT_STRATEGY_ID, breakout_universe_exit_debounce_sec
|
||||
from kis_trader.backtest.universe_history_source import resolve_backtest_universe_history_source
|
||||
_deb = breakout_universe_exit_debounce_sec()
|
||||
_hs = resolve_backtest_universe_history_source(base_fixed.get("_universe_history_source") or base_fixed.get("universe_history_source"))
|
||||
_tl = build_universe_timeline(
|
||||
strategy_id=BREAKOUT_STRATEGY_ID,
|
||||
start_ymd=start_key[:8], end_ymd=end_key[:8],
|
||||
debounce_sec=_deb, strict=False, strict_lag_minutes=0,
|
||||
history_source=_hs,
|
||||
)
|
||||
if _tl is not None:
|
||||
cache_holder["_universe_timeline"] = _tl
|
||||
|
||||
if ticks_by_code:
|
||||
from kis_trader.backtest.breakout_tick_loader import tick_coverage_stats
|
||||
cache_holder["_tick_meta_cached"] = tick_coverage_stats(codes_candles, ticks_by_code)
|
||||
|
||||
return BreakoutSearchContext(
|
||||
start=start,
|
||||
@@ -407,6 +428,19 @@ def run_breakout_optuna(
|
||||
bind_study_trials(study, n_trials=n_trials, log=logger)
|
||||
n_trials = clamp_optimize_n_trials(study, n_trials, log=logger)
|
||||
|
||||
import uuid
|
||||
rust_session_id = f"optuna_break_{uuid.uuid4().hex[:8]}"
|
||||
try:
|
||||
import kis_rust_core
|
||||
import json
|
||||
candles_json = json.dumps(ctx.codes_candles)
|
||||
kis_rust_core.init_backtest_session_json(
|
||||
rust_session_id,
|
||||
candles_json
|
||||
)
|
||||
except Exception as e:
|
||||
logger.warning(f"Failed to init_rust_session: {e}")
|
||||
|
||||
def objective(trial: optuna.Trial) -> float:
|
||||
if ctx.mode == "tpe":
|
||||
combo = suggest_breakout_params_tpe(
|
||||
@@ -416,6 +450,8 @@ def run_breakout_optuna(
|
||||
)
|
||||
else:
|
||||
combo = suggest_breakout_params(trial, ctx.mode)
|
||||
|
||||
combo["_rust_session_id"] = rust_session_id
|
||||
result = evaluate_breakout_param_combo(
|
||||
combo,
|
||||
base_fixed=ctx.base_fixed,
|
||||
|
||||
Reference in New Issue
Block a user