버그 수정 2건 — MDD 계산 오류 + KIS API 타임아웃
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 <noreply@anthropic.com>
This commit is contained in:
+3
-2
@@ -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
|
||||
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user