추천로직
This commit is contained in:
@@ -410,7 +410,19 @@ async def sync_portfolio(db: AsyncSession = Depends(get_db), force: bool = True)
|
||||
|
||||
# 최신 상태가 'SELL'인 종목 식별
|
||||
ghost_candidates = {code for code, status in stock_status_map.items() if status == "SELL"}
|
||||
|
||||
|
||||
# 부분 매도 보정: KIS 잔고에서 여전히 수량이 있는 종목은 ghost에서 제외
|
||||
if ghost_candidates and "output1" in balance_data:
|
||||
still_holding = {
|
||||
item.get("pdno")
|
||||
for item in balance_data["output1"]
|
||||
if int(item.get("hldg_qty", 0)) > 0
|
||||
}
|
||||
partial_sell_excluded = ghost_candidates & still_holding
|
||||
if partial_sell_excluded:
|
||||
logger.info(f"↩️ 부분매도 종목은 ghost 제외 (잔고 있음): {partial_sell_excluded}")
|
||||
ghost_candidates -= still_holding
|
||||
|
||||
if ghost_candidates:
|
||||
logger.info(f"🚫 Ghost Stock Candidates (Last action today is SELL): {ghost_candidates}")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user