버그 처리
This commit is contained in:
@@ -18,7 +18,8 @@
|
||||
"Bash(pip install:*)",
|
||||
"Bash(python -c:*)",
|
||||
"Bash(git pull:*)",
|
||||
"Bash(git stash:*)"
|
||||
"Bash(git stash:*)",
|
||||
"Bash(git -C /Users/commylife/myproject/java/workspace/auto-stock ls-files)"
|
||||
]
|
||||
},
|
||||
"enableAllProjectMcpServers": true,
|
||||
|
||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -71,3 +71,4 @@ summary_output.json
|
||||
|
||||
# Virtual environments
|
||||
.venv/
|
||||
.venv/
|
||||
|
||||
@@ -205,7 +205,7 @@ async def lifespan(app: FastAPI):
|
||||
try:
|
||||
from app.models.models import StockAnalysis, TradeHistory, Portfolio
|
||||
from sqlalchemy import delete
|
||||
from datetime import date, timedelta
|
||||
from datetime import datetime, date, timedelta
|
||||
|
||||
async with AsyncSessionLocal() as session:
|
||||
_kst = pytz.timezone("Asia/Seoul")
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
재시작 후에도 ban 상태 유지: DB(stock_bans 테이블) 영속화.
|
||||
"""
|
||||
import logging
|
||||
from datetime import datetime, timedelta
|
||||
from datetime import datetime, timedelta, timezone
|
||||
from typing import Dict, Optional
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
@@ -39,7 +39,7 @@ class ConsecutiveLossTracker:
|
||||
if is_loss:
|
||||
entry["consecutive_losses"] += 1
|
||||
if entry["consecutive_losses"] >= self.ban_count:
|
||||
entry["ban_until"] = datetime.now() + timedelta(days=self.ban_calendar_days)
|
||||
entry["ban_until"] = datetime.now(timezone.utc) + timedelta(days=self.ban_calendar_days)
|
||||
logger.warning(
|
||||
f"{stock_code}: {entry['consecutive_losses']}회 연속 손실 → "
|
||||
f"{entry['ban_until'].strftime('%Y-%m-%d')}까지 진입 금지"
|
||||
@@ -71,7 +71,7 @@ class ConsecutiveLossTracker:
|
||||
else:
|
||||
record.consecutive_losses = entry["consecutive_losses"]
|
||||
record.ban_until = entry["ban_until"]
|
||||
record.updated_at = datetime.now()
|
||||
record.updated_at = datetime.now(timezone.utc)
|
||||
|
||||
await db.commit()
|
||||
logger.debug(f"loss_tracker DB 저장 완료: {stock_code}")
|
||||
@@ -87,7 +87,7 @@ class ConsecutiveLossTracker:
|
||||
result = await db.execute(select(StockBan))
|
||||
records = result.scalars().all()
|
||||
|
||||
now = datetime.now()
|
||||
now = datetime.now(timezone.utc)
|
||||
loaded = 0
|
||||
for rec in records:
|
||||
# 만료된 ban은 초기화
|
||||
@@ -117,7 +117,7 @@ class ConsecutiveLossTracker:
|
||||
entry = self._tracker.get(stock_code)
|
||||
if not entry or not entry["ban_until"]:
|
||||
return False
|
||||
if datetime.now() >= entry["ban_until"]:
|
||||
if datetime.now(timezone.utc) >= entry["ban_until"]:
|
||||
# 금지 기간 만료 → 리셋
|
||||
entry["consecutive_losses"] = 0
|
||||
entry["ban_until"] = None
|
||||
|
||||
Reference in New Issue
Block a user