보유종목 1분마다 호출하는부분 수정
This commit is contained in:
@@ -606,7 +606,13 @@ async def check_and_execute_exit_trades(db: AsyncSession):
|
||||
from datetime import datetime
|
||||
|
||||
try:
|
||||
await sync_portfolio(db, force=True)
|
||||
# 매매가 발생했거나 캐시가 비어있을 때만 KIS 잔고 조회 (API 호출 최소화)
|
||||
latest_trade_id = await _get_latest_executed_trade_id(db)
|
||||
if latest_trade_id != portfolio_cache.last_trade_id or not portfolio_cache.holdings:
|
||||
logger.info(f"🔄 New trade detected (prev={portfolio_cache.last_trade_id}, cur={latest_trade_id}) — syncing balance")
|
||||
await sync_portfolio(db, force=True)
|
||||
else:
|
||||
logger.debug("⏭️ No new trade since last sync — skipping get_balance()")
|
||||
|
||||
# MDD 업데이트 (async — thread-safe lock 내부)
|
||||
summary = await _get_portfolio_summary(db)
|
||||
|
||||
Reference in New Issue
Block a user