feat: 틱/호가 데이터 출처 표출 UI 추가 및 데이터 수집 개선
- 백테스트 및 실거래 시 틱과 호가의 벤더 출처(ob_source, entry_source) 기록 및 추적 강화 (tail_engine.py) - 웹 UI '체결디버그'에 [틱:kis / 호가:ls] 형태로 데이터 출처를 직관적으로 표출 (backtest.js, backtest.html) - LS WebSocket 구독 100건 제한 하드코딩 해제 및 env_config_ext 연동 (ls_ws.py) - 기타 백테스트 웹 및 DB 관련 최적화 적용
This commit is contained in:
@@ -1125,6 +1125,11 @@ def _tail_signal_with_whipsaw(
|
||||
)
|
||||
if prog_rej:
|
||||
return (prog_rej, prog_msg, None)
|
||||
|
||||
ob_snap = params.get("_backtest_orderbook_snapshot")
|
||||
if ob_snap is not None:
|
||||
sig["backtest_ob_source"] = str(getattr(ob_snap, "source", "") or "").strip()
|
||||
|
||||
return (None, None, sig)
|
||||
|
||||
|
||||
@@ -1761,6 +1766,7 @@ def _fill_portfolio_align_entry(
|
||||
"session_low": entry_price,
|
||||
"qty": qty,
|
||||
"entry_source": entry_src,
|
||||
"ob_source": str(pe.get("backtest_ob_source") or ""),
|
||||
}
|
||||
return True, 0, 0
|
||||
|
||||
@@ -2003,6 +2009,7 @@ def run_tail_backtest_portfolio(
|
||||
"entry_bar_key": ent.get("candle_time"),
|
||||
"enroll_et": _enroll,
|
||||
"from_inclusion": True,
|
||||
"backtest_ob_source": sig.get("backtest_ob_source"),
|
||||
}))
|
||||
if incl_cands:
|
||||
incl_cands.sort(key=lambda x: x[0])
|
||||
@@ -2113,6 +2120,7 @@ def run_tail_backtest_portfolio(
|
||||
"session_low": fill,
|
||||
"qty": qty,
|
||||
"entry_source": str(fill_src or "ohlc_low"),
|
||||
"ob_source": str(pl.get("backtest_ob_source") or ""),
|
||||
}
|
||||
ctx["pending_limit"] = None
|
||||
break
|
||||
@@ -2261,6 +2269,7 @@ def run_tail_backtest_portfolio(
|
||||
"qty": pos.get("qty", 1),
|
||||
"entry_source": str(pos.get("entry_source") or ""),
|
||||
"exit_source": str(exit_src or ""),
|
||||
"ob_source": str(pos.get("ob_source") or ""),
|
||||
})
|
||||
ctx["last_exit_dt"][day] = _t2dt(sell_time or t)
|
||||
ctx["daily_cnt"][day] = ctx["daily_cnt"].get(day, 0) + 1
|
||||
@@ -2366,6 +2375,7 @@ def run_tail_backtest_portfolio(
|
||||
"fill_slip": lp_cfg["fill_slip_pct"],
|
||||
"stop": stop_p,
|
||||
"target": target_p,
|
||||
"backtest_ob_source": sig.get("backtest_ob_source"),
|
||||
}))
|
||||
continue
|
||||
|
||||
@@ -2432,6 +2442,7 @@ def run_tail_backtest_portfolio(
|
||||
"target": target_p,
|
||||
"entry_bar_key": ent.get("candle_time"),
|
||||
"enroll_et": _enroll,
|
||||
"backtest_ob_source": sig.get("backtest_ob_source"),
|
||||
}))
|
||||
|
||||
if not candidates:
|
||||
@@ -2634,6 +2645,7 @@ def run_tail_backtest(
|
||||
"qty": position.get("qty", 1),
|
||||
"entry_source": str(position.get("entry_source") or ""),
|
||||
"exit_source": str(_exit_src or ""),
|
||||
"ob_source": str(position.get("ob_source") or ""),
|
||||
})
|
||||
last_exit_dt[day] = _t2dt(sell_time or c["candle_time"])
|
||||
daily_cnt[day] = daily_cnt.get(day, 0) + 1
|
||||
|
||||
Reference in New Issue
Block a user