fix: 로그 WARNING 2종 수정 - scanner 오해 메시지 및 홀딩 종목 rsi 누락 (#267) #268

Merged
jihoson merged 2 commits from feature/issue-267-fix-log-warnings into main 2026-02-26 01:46:44 +09:00
2 changed files with 18 additions and 10 deletions
Showing only changes of commit ccb00ee77d - Show all commits

View File

@@ -581,6 +581,11 @@ async def trading_cycle(
if candidate:
market_data["rsi"] = candidate.rsi
market_data["volume_ratio"] = candidate.volume_ratio
else:
# Holding stocks not in scanner: derive implied RSI from price change,
# volume_ratio defaults to 1.0 (no surge data available).
market_data["rsi"] = max(0.0, min(100.0, 50.0 + price_change_pct * 2.0))
market_data["volume_ratio"] = 1.0
# Enrich market_data with holding info for SELL/HOLD scenario conditions
open_pos = get_open_position(db_conn, stock_code, market.code)
@@ -1499,8 +1504,9 @@ async def run_daily_session(
active_stocks={},
)
if not fallback_stocks:
logger.warning(
"No dynamic overseas symbol universe for %s; scanner cannot run",
logger.debug(
"No dynamic overseas symbol universe for %s;"
" scanner will use overseas ranking API",
market.code,
)
try:
@@ -2812,9 +2818,9 @@ async def run(settings: Settings) -> None:
active_stocks=active_stocks,
)
if not fallback_stocks:
logger.warning(
logger.debug(
"No dynamic overseas symbol universe for %s;"
" scanner cannot run",
" scanner will use overseas ranking API",
market.code,
)

View File

@@ -1668,10 +1668,10 @@ class TestScenarioEngineIntegration:
scan_candidates={"US": {"005930": us_candidate}}, # Wrong market
)
# Should NOT have rsi/volume_ratio because candidate is under US, not KR
# Should NOT use US candidate's rsi (=15.0); fallback implied_rsi used instead
market_data = engine.evaluate.call_args[0][2]
assert "rsi" not in market_data
assert "volume_ratio" not in market_data
assert market_data["rsi"] != 15.0 # US candidate's rsi must be ignored
assert market_data["volume_ratio"] == 1.0 # Fallback default
@pytest.mark.asyncio
async def test_scenario_engine_called_without_scanner_data(
@@ -1702,11 +1702,13 @@ class TestScenarioEngineIntegration:
scan_candidates={}, # No scanner data
)
# Should still work, just without rsi/volume_ratio
# Holding stocks without scanner data use implied_rsi (from price_change_pct)
# and volume_ratio=1.0 as fallback, so rsi/volume_ratio are always present.
engine.evaluate.assert_called_once()
market_data = engine.evaluate.call_args[0][2]
assert "rsi" not in market_data
assert "volume_ratio" not in market_data
assert "rsi" in market_data # Implied RSI from price_change_pct=2.5 → 55.0
assert market_data["rsi"] == pytest.approx(55.0)
assert market_data["volume_ratio"] == 1.0
assert market_data["current_price"] == 50000.0
@pytest.mark.asyncio