fix: Update imports and enhance error handling in momentum engine and tick replay

Changes:
- Replaced the import of `get_env_int` with `get_env_from_db` in `momentum_engine.py` to improve environment variable retrieval.
- Modified error handling in `momentum_tick_replay.py` to ensure `TickColumnView` is only referenced if successfully imported, enhancing robustness.

Impact:
- These updates streamline the import process and improve the stability of the momentum trading logic by ensuring that the code handles import errors gracefully.
This commit is contained in:
2026-07-06 21:43:00 +09:00
parent 618041909b
commit a4626e0351
2 changed files with 7 additions and 7 deletions

View File

@@ -33,7 +33,7 @@ from kis_trader.engine.momentum_env_keys import (
_legacy_float,
)
from kis_trader.engine.strategy_eod import is_strategy_eod_bar
from kis_trader.utils.env import get_env_int
from kis_trader.utils.env import get_env_from_db, get_env_int
MOMENTUM_STRATEGY_ID = "MOMENTUM"

View File

@@ -314,12 +314,12 @@ def try_momentum_sell_on_ticks(
# 백테 틱재생: 공유메모리 컬럼 뷰면 직접집계(실매 dict 경로 무변경).
try:
from kis_trader.backtest.shared_ticks import TickColumnView
if isinstance(ticks, TickColumnView):
return _try_momentum_sell_on_ticks_columnar(
position, ticks, params, is_eod=is_eod, entry_time=entry_time,
)
except Exception:
pass
except ImportError:
TickColumnView = None # type: ignore[misc,assignment]
if TickColumnView is not None and isinstance(ticks, TickColumnView):
return _try_momentum_sell_on_ticks_columnar(
position, ticks, params, is_eod=is_eod, entry_time=entry_time,
)
if not ticks:
return None