From 4b18db11527cdc7dc41a05647034f390cd2ed33d Mon Sep 17 00:00:00 2001 From: jongjae Date: Fri, 22 May 2026 15:34:28 +0900 Subject: [PATCH] =?UTF-8?q?[2026-05-22]=20=EC=9D=BC=EC=9D=BC=20=EB=A6=AC?= =?UTF-8?q?=ED=8F=AC=ED=8A=B8=20=E2=80=94=2014=EA=B1=B4=20=EC=8A=B97?= =?UTF-8?q?=ED=8C=A87=20-127,406=EC=9B=90=20/=20TimeoutError=20=EB=A1=9C?= =?UTF-8?q?=EA=B7=B8=20=EB=B2=84=EA=B7=B8=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - reports/daily/2026-05-22.md 생성 - main.py: except 블록에 type(e).__name__ 추가 (빈 에러 메시지 방지) - kis_client._request: asyncio.TimeoutError 명시적 catch → RuntimeError re-raise --- app/execution/kis_client.py | 17 ++++++----- app/main.py | 4 +-- reports/daily/2026-05-22.md | 59 +++++++++++++++++++++++++++++++++++++ 3 files changed, 71 insertions(+), 9 deletions(-) create mode 100644 reports/daily/2026-05-22.md diff --git a/app/execution/kis_client.py b/app/execution/kis_client.py index f30b8e5..9aacefc 100644 --- a/app/execution/kis_client.py +++ b/app/execution/kis_client.py @@ -182,13 +182,16 @@ class KISClient: self._req_times.append(time.monotonic()) _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() - else: - async with session.post(url, headers=headers, json=body) as r: - data = await r.json() + try: + 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() + else: + async with session.post(url, headers=headers, json=body) as r: + data = await r.json() + except asyncio.TimeoutError: + raise RuntimeError(f"KIS API 타임아웃 [{tr_id}]") # 응답 코드 체크 rt_cd = data.get("rt_cd", "") diff --git a/app/main.py b/app/main.py index 54f6d3c..021e747 100644 --- a/app/main.py +++ b/app/main.py @@ -447,7 +447,7 @@ class StockBot: ) except Exception as e: - logger.error(f"진입 체크 오류 {ticker}: {e}") + logger.error(f"진입 체크 오류 {ticker}: {type(e).__name__}: {e}") # ───────────────────────────────────────── # 청산 체크 @@ -487,7 +487,7 @@ class StockBot: await asyncio.sleep(1.1) except Exception as e: - logger.error(f"청산 체크 오류 {ticker}: {e}") + logger.error(f"청산 체크 오류 {ticker}: {type(e).__name__}: {e}") async def _do_exit(self, ticker: str, pos: dict, current: float, qty: int, reason: str): diff --git a/reports/daily/2026-05-22.md b/reports/daily/2026-05-22.md new file mode 100644 index 0000000..3b8ef7f --- /dev/null +++ b/reports/daily/2026-05-22.md @@ -0,0 +1,59 @@ +# [2026-05-22] 일일 리포트 + +## 매매 결과 +- 총 매매: 14회 / 승 7 패 7 (승률 50.0%) +- 순손익: -127,406원 +- 수수료: 33,320원 + +## 매매 상세 +| 종목 | 진입 | 청산 | 사유 | 손익 | +|------|------|------|------|------| +| 대원전선 | 09:05 | 09:11 | SL | -37,052원 | +| 이노인스트루먼트 | 09:05 | 09:06 | SL | -35,792원 | +| 피노 | 09:06 | 09:08 | TP1 | +13,433원 | +| MDS테크 | 09:10 | 09:14 | SL | -34,526원 | +| 원텍 | 09:11 | 09:15 | SL | -21,394원 | +| LG디스플레이 | 09:15 | 09:23 | TP1 | +9,512원 | +| 한화생명 | 09:15 | 09:24 | TP1 | +5,885원 | +| 코스모로보틱스 | 09:25 | 09:38 | TP1 | +18,999원 | +| 아주IB투자 | 09:28 | 09:48 | SL | -34,590원 | +| 피노 (재진입) | 09:49 | 11:14 | SL | -22,309원 | +| LG디스플레이 | 10:12 | 10:20 | TP1 | +10,226원 | +| 한화생명 (재진입) | 11:21 | 12:36 | SL | -11,176원 | +| LG디스플레이 | 12:12 | 14:12 | TIME | +4,494원 | +| PS일렉트로닉스 | 12:36 | 14:22 | TP1 | +6,882원 | + +## 분석 및 피드백 + +### 1. 개장 초반 손절 집중 (09:05~09:15) +5거래 중 4손절, 1익절 — 이 구간에서 -128,764원 발생. +변동성 돌파 신호가 개장 5~15분간 노이즈에 취약하다는 패턴이 반복됨. +그러나 피노(09:06 TP1)는 성공해 개장 직후 전면 금지 결론은 시기상조. 추가 거래일 관찰 필요. + +### 2. 구조적 손익비 문제 (핵심) +- 손절 평균: **-28,120원** (100% 청산, SL=-1.5%) +- 익절 평균: **+9,919원** (TP1 50% 청산, +2%) +- 실제 손익비: **0.35** → 50% 승률에서도 손실 필연 + +TP1에서 절반(50%)만 청산하는 구조상, 나머지 50% 포지션이 TP2(+3%)까지 못 가고 손절/타임청산되면 익절 건의 전체 수익이 대폭 줄어듦. 4거래일 누적 -375,418원의 핵심 원인. +**→ TP2 도달률 집계 필요. 나머지 50% 포지션 처리가 손익비 개선 여부를 결정함.** + +### 3. 오후 청산 체크 오류 버그 (수정 완료) +12:51~14:11 사이 `청산 체크 오류 {ticker}: ` (빈 메시지) 반복. +원인: `asyncio.TimeoutError`의 `str()` = `""`로 에러 내용이 숨겨짐. +수정: `main.py` except 블록에 `type(e).__name__` 추가, `kis_client._request`에서 `TimeoutError` 명시적 catch 후 `RuntimeError`로 re-raise. + +### 4. AI 부스트 없음 +전체 14건 모두 `ai_boosted=0`. morning 컨텍스트가 유니버스 필터링에 반영되지 않는 상태. + +## 파라미터 변경 +없음 (단일 거래일 데이터로 판단 보류. TP2 도달률 추가 관찰 후 재검토) + +## 실전 전환 조건 +| 조건 | 기준 | 현재 | 통과 | +|------|------|------|------| +| 누적 운영 | 30거래일 | 4일 | ✗ | +| 승률 | >48% | 45.5% | ✗ | +| MDD | <-10% | -3.8% | ✓ | +| 샤프지수 | >1.0 | -29.01 | ✗ | +| L3 월 2회 이하 | ≤2회 | 0회 | ✓ |