From 2aeb024c4c4975bd3e7c661595cde8a8f7f0bb88 Mon Sep 17 00:00:00 2001 From: jongjae Date: Thu, 21 May 2026 19:29:58 +0900 Subject: [PATCH] =?UTF-8?q?=EB=B2=84=EA=B7=B8=20=EC=88=98=EC=A0=95=202?= =?UTF-8?q?=EA=B1=B4=20=E2=80=94=20MDD=20=EA=B3=84=EC=82=B0=20=EC=98=A4?= =?UTF-8?q?=EB=A5=98=20+=20KIS=20API=20=ED=83=80=EC=9E=84=EC=95=84?= =?UTF-8?q?=EC=9B=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. evening.py MDD: peak=0 초기값 문제로 분모가 1이 되어 수천만% 출력 → 초기자본(10,000,000) 기준 % 계산으로 변경 2. kis_client.py _request: ClientTimeout 미설정으로 SSL 연결이 무한 대기 → total=10초 타임아웃 적용, 세마포 타임아웃 오류 방지 Co-Authored-By: Claude Sonnet 4.6 --- app/ai/evening.py | 5 +++-- app/execution/kis_client.py | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/app/ai/evening.py b/app/ai/evening.py index 96e55ba..80f669a 100644 --- a/app/ai/evening.py +++ b/app/ai/evening.py @@ -104,7 +104,8 @@ def calc_live_ready(summaries: list[dict]) -> dict: win_trades = sum(s["win_trades"] for s in summaries) win_rate = win_trades / total_trades * 100 if total_trades else 0 - # MDD: 누적 손익 기준 최대 낙폭 + # MDD: 초기자본 대비 누적 낙폭 (%) + STARTING_CAPITAL = 10_000_000 cum = 0.0 peak = 0.0 mdd = 0.0 @@ -112,7 +113,7 @@ def calc_live_ready(summaries: list[dict]) -> dict: cum += s["net_pnl"] or 0 if cum > peak: peak = cum - drawdown = (peak - cum) / max(abs(peak), 1) * 100 + drawdown = (peak - cum) / STARTING_CAPITAL * 100 if drawdown > mdd: mdd = drawdown diff --git a/app/execution/kis_client.py b/app/execution/kis_client.py index a1a9e39..f30b8e5 100644 --- a/app/execution/kis_client.py +++ b/app/execution/kis_client.py @@ -181,7 +181,8 @@ class KISClient: await asyncio.sleep(wait) self._req_times.append(time.monotonic()) - async with aiohttp.ClientSession() as session: + _timeout = aiohttp.ClientTimeout(total=10) + async with aiohttp.ClientSession(timeout=_timeout) as session: if method == "GET": async with session.get(url, headers=headers, params=params) as r: data = await r.json()