fix(ws): KIS/키움 WS·조건검색 안정화 및 매도시세 폴백
WS 매니저 spill·조건검색 CNSR 회복·kiwoom_ws_diag 진단 경로를 보강한다. live_sell_price stale RAM/REST 폴백 정합을 유지한다. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -12,7 +12,7 @@ import threading
|
||||
import time
|
||||
from typing import Any, Callable, Optional, Tuple
|
||||
|
||||
from kis_trader.utils.env import get_env_float
|
||||
from kis_trader.utils.env import get_env_bool, get_env_float
|
||||
|
||||
|
||||
_stale_rest_lock = threading.Lock()
|
||||
@@ -196,6 +196,7 @@ def resolve_live_sell_price(
|
||||
is_eod: bool = False,
|
||||
fallback_price: float = 0.0,
|
||||
logger: Any = None,
|
||||
allow_kiwoom_rest: Optional[bool] = None,
|
||||
) -> Tuple[float, str]:
|
||||
"""
|
||||
실매 매도용 현재가.
|
||||
@@ -210,6 +211,8 @@ def resolve_live_sell_price(
|
||||
cooldown = float(get_env_float("SELL_WS_STALE_REST_COOLDOWN_SEC", 30.0) or 0.0)
|
||||
if cooldown < 1.0:
|
||||
cooldown = 1.0
|
||||
if allow_kiwoom_rest is None:
|
||||
allow_kiwoom_rest = bool(get_env_bool("SELL_SCAN_ALLOW_KIWOOM_REST", False))
|
||||
_ = inquire_price # 한투 경로 사용 금지 (시그니처 유지)
|
||||
|
||||
if is_eod:
|
||||
@@ -217,7 +220,7 @@ def resolve_live_sell_price(
|
||||
if ws_px > 0:
|
||||
_remember_last_good(code, ws_px, "WS")
|
||||
return ws_px, "WS"
|
||||
if stale_sec > 0 and _stale_rest_allowed(code, cooldown):
|
||||
if allow_kiwoom_rest and stale_sec > 0 and _stale_rest_allowed(code, cooldown):
|
||||
rest_px = _kiwoom_rest_once(ws, code)
|
||||
if rest_px > 0:
|
||||
return rest_px, "kiwoom_rest"
|
||||
@@ -276,7 +279,7 @@ def resolve_live_sell_price(
|
||||
)
|
||||
return cached_px, cached_src + "_cached"
|
||||
|
||||
if stale_sec > 0 and _stale_rest_allowed(code, cooldown):
|
||||
if allow_kiwoom_rest and stale_sec > 0 and _stale_rest_allowed(code, cooldown):
|
||||
rest_px = _kiwoom_rest_once(ws, code)
|
||||
if rest_px > 0:
|
||||
_remember_last_good(code, rest_px, "kiwoom_rest")
|
||||
|
||||
Reference in New Issue
Block a user