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:
@@ -33,7 +33,7 @@ from kis_trader.engine.momentum_env_keys import (
|
|||||||
_legacy_float,
|
_legacy_float,
|
||||||
)
|
)
|
||||||
from kis_trader.engine.strategy_eod import is_strategy_eod_bar
|
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"
|
MOMENTUM_STRATEGY_ID = "MOMENTUM"
|
||||||
|
|
||||||
|
|||||||
@@ -314,12 +314,12 @@ def try_momentum_sell_on_ticks(
|
|||||||
# 백테 틱재생: 공유메모리 컬럼 뷰면 직접집계(실매 dict 경로 무변경).
|
# 백테 틱재생: 공유메모리 컬럼 뷰면 직접집계(실매 dict 경로 무변경).
|
||||||
try:
|
try:
|
||||||
from kis_trader.backtest.shared_ticks import TickColumnView
|
from kis_trader.backtest.shared_ticks import TickColumnView
|
||||||
if isinstance(ticks, TickColumnView):
|
except ImportError:
|
||||||
|
TickColumnView = None # type: ignore[misc,assignment]
|
||||||
|
if TickColumnView is not None and isinstance(ticks, TickColumnView):
|
||||||
return _try_momentum_sell_on_ticks_columnar(
|
return _try_momentum_sell_on_ticks_columnar(
|
||||||
position, ticks, params, is_eod=is_eod, entry_time=entry_time,
|
position, ticks, params, is_eod=is_eod, entry_time=entry_time,
|
||||||
)
|
)
|
||||||
except Exception:
|
|
||||||
pass
|
|
||||||
|
|
||||||
if not ticks:
|
if not ticks:
|
||||||
return None
|
return None
|
||||||
|
|||||||
Reference in New Issue
Block a user