ls증권 히스토리 구독 넣음

This commit is contained in:
Your Name
2026-07-30 18:05:07 +09:00
parent 61bec4bd1d
commit 67eab24603
1593 changed files with 135733 additions and 1232 deletions

View File

@@ -3,8 +3,12 @@
백테 틱 청산 공통 — 실매 폴링(STRATEGY_LOOP_SLEEP≈0.1초) 근사.
1분·N분봉 OHLC intrabar(open→high→low→close)는 익절/어깨를 손절보다 먼저
체결하는 낙관 편향을 만든다. 전 전략 백테·파람서치는 ws_ticks 시간순 재생
기본으로 하고, 틱 없는 구간은 OHLC 폴백을 쓰지 않는다(기본 OFF).
체결하는 낙관 편향을 만든다. 전 전략 백테·파람서치·Optuna는 ws_ticks 시간순 재생.
■ 절대규칙 (정합)
틱 청산/틱 진입 ON 이면 OHLC 폴백으로 체결·고점·손익 숫자를 **절대 변조하지 않는다**.
``*_TICK_FALLBACK_OHLC`` 체크가 ON이어도 ``use_tick_exit`` 경로에서는 무시한다.
(봉 high 선반영·EOD OHLC 강제 폴백 = 실매와 다른 엔진 — 금지)
"""
from __future__ import annotations
@@ -91,6 +95,11 @@ def strategy_tick_fallback_ohlc(
*,
default: bool = False,
) -> bool:
"""OHLC 폴백 플래그 조회.
기본 False. 틱 청산 ON 경로에서는 ``resolve_backtest_sell`` 이 이 값을 **무시**한다.
Optuna/파람서치는 호출측에서 False 고정.
"""
return _param_bool(params, "backtest_tick_fallback_ohlc", env_key, default)
@@ -331,7 +340,7 @@ def resolve_backtest_sell(
slip_pct: float = 0.0,
) -> Optional[Tuple[str, float, str, float, str]]:
"""
한 봉 청산 — 틱 우선, 없으면 OHLC intrabar 폴백(기본 OFF).
한 봉 청산 — 틱 청산 ON 이면 틱만. OHLC 폴백으로 숫자 변조 금지.
Returns:
(reason, fill_price, sell_time, hold_min, exit_source)
@@ -345,19 +354,21 @@ def resolve_backtest_sell(
ct = str(bar.get("candle_time") or "")
entry_time = str(position.get("entry_time") or "")
if use_tick_exit and ticks:
tick_res = try_sell_on_ticks(
position, ticks, params, sell_fn,
is_eod=is_eod, entry_time=entry_time,
poll_ms=poll_ms, slip_pct=slip_pct, low_mode=low_mode,
)
if tick_res:
reason, fill_px, sell_time, hold_min = tick_res
return reason, fill_px, sell_time, hold_min, "ws_ticks"
if not tick_fallback_ohlc:
if use_tick_exit:
if ticks:
tick_res = try_sell_on_ticks(
position, ticks, params, sell_fn,
is_eod=is_eod, entry_time=entry_time,
poll_ms=poll_ms, slip_pct=slip_pct, low_mode=low_mode,
)
if tick_res:
reason, fill_px, sell_time, hold_min = tick_res
return reason, fill_px, sell_time, hold_min, "ws_ticks"
# 절대규칙: 틱 청산 ON → OHLC intrabar 폴백 무시 (tick_fallback_ohlc 체크 무관)
# EOD 플랫은 호출측에서 직전가/장마감만 처리.
return None
# 틱 청산 OFF = 레거시 순수 OHLC 경로 (폴백이 아님 — 봉 OHLC 가 본체)
res = check_sell_signal_backtest_bar(
position, bar, params, is_eod=is_eod, sell_fn=sell_fn, low_mode=low_mode,
)