diff --git a/app/main.py b/app/main.py index 80b3b26..c9b39c7 100644 --- a/app/main.py +++ b/app/main.py @@ -437,31 +437,35 @@ async def run(): while True: now = datetime.now().strftime("%H:%M") - # 08:30 AI 컨텍스트 로드 + 유니버스 갱신 - # (claude_morning이 08:15에 시작해 08:30 전에 daily_context.json 생성) - if now == "08:30": - ctx = bot.strategy.load_ai_context() - await notify_ai_result( - ctx["market_sentiment"], - ctx["sentiment_score"], - ctx.get("hot_sectors", []), - ctx.get("avoid_sectors", []), - ctx.get("reason", ""), - ) - bot.risk.set_risk_level(ctx.get("risk_level", "보통")) - await bot.update_universe() + try: + # 08:30 AI 컨텍스트 로드 + 유니버스 갱신 + # (claude_morning이 08:15에 시작해 08:30 전에 daily_context.json 생성) + if now == "08:30": + ctx = bot.strategy.load_ai_context() + await notify_ai_result( + ctx["market_sentiment"], + ctx["sentiment_score"], + ctx.get("hot_sectors", []), + ctx.get("avoid_sectors", []), + ctx.get("reason", ""), + ) + bot.risk.set_risk_level(ctx.get("risk_level", "보통")) + await bot.update_universe() - # 08:50 목표가 계산 - elif now == "08:50": - await bot.calc_targets() + # 08:50 목표가 계산 + elif now == "08:50": + await bot.calc_targets() - # 09:00 매매 루프 시작 - elif now == "09:00": - await bot.trading_loop() + # 09:00 매매 루프 시작 + elif now == "09:00": + await bot.trading_loop() - # 15:10 결산 - elif now == "15:10": - await bot.daily_summary() + # 15:10 결산 + elif now == "15:10": + await bot.daily_summary() + + except Exception as e: + logger.error(f"스케줄러 루프 오류 ({now}): {e}", exc_info=True) await asyncio.sleep(30)