fix: market_data에 unrealized_pnl_pct/holding_days 추가하여 SELL 시나리오 정상화 (#259)
Some checks failed
CI / test (pull_request) Has been cancelled
Some checks failed
CI / test (pull_request) Has been cancelled
trading_cycle()의 market_data에 보유 포지션 정보가 없어 Condition requires 'unrealized_pnl_pct' but key missing from market_data 경고 발생. 보유 종목(NVDA 등)의 take-profit/stop-loss 시나리오가 평가 불가하여 HOLD(confidence=0) 고착. - get_open_position()에 timestamp 컬럼 추가 - market_data 구성 시 open_position 조회 후 아래 키 추가: - unrealized_pnl_pct: (current_price - entry_price) / entry_price * 100 - holding_days: 매수일로부터 경과 일수 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -254,7 +254,7 @@ def get_open_position(
|
||||
"""Return open position if latest trade is BUY, else None."""
|
||||
cursor = conn.execute(
|
||||
"""
|
||||
SELECT action, decision_id, price, quantity
|
||||
SELECT action, decision_id, price, quantity, timestamp
|
||||
FROM trades
|
||||
WHERE stock_code = ?
|
||||
AND market = ?
|
||||
@@ -266,7 +266,7 @@ def get_open_position(
|
||||
row = cursor.fetchone()
|
||||
if not row or row[0] != "BUY":
|
||||
return None
|
||||
return {"decision_id": row[1], "price": row[2], "quantity": row[3]}
|
||||
return {"decision_id": row[1], "price": row[2], "quantity": row[3], "timestamp": row[4]}
|
||||
|
||||
|
||||
def get_recent_symbols(
|
||||
|
||||
Reference in New Issue
Block a user