GT MTF 프로필·캘리브레이션과 04 매칭/시뮬/실거래 파이프라인을 추가한다.

3분~일봉 GT 타점 분석(03c), leg 체결 순서 수정, 총자산 90% 검증 루프,
walk-forward Go/No-Go 시뮬, monitor·live_trader 및 reference 문서를 포함한다.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-05-31 11:27:50 +09:00
parent b52d61b777
commit 2cb67c42b3
47 changed files with 5956 additions and 209 deletions

View File

@@ -1,15 +1,36 @@
# Phase 04 — Matching
# Phase 04 — Matching (GT + 전구간 EV)
Ground Truth 매수·매도 타점의 MTF 스냅샷(`docs/03_analysis/general_analysis_trades.csv`)과
실시간·최근 봉 상태를 비교해 **가장 근접한 기술적 프로파일** 및 **진입·청산 규칙**을 선택합니다.
안2 파이프라인: 03b GT 스냅샷에서 규칙 후보를 만들고, 3분봉 전 구간에서 발화·forward 수익을 검증한 뒤 valid 구간 EV로 최종 규칙을 고릅니다.
예정 산출물:
## PDCA
- `docs/04_matching/rule_candidates.json`
- `docs/04_matching/similarity_report.html`
| 단계 | 스크립트 모듈 | 산출물 |
|------|---------------|--------|
| 4-1 Plan/Do | `profile_rules.py` | `rule_candidates.json` (기본: 복합·대조만) |
| 4-2 Do | `rule_eval.scan` | `rule_fires.csv` |
| 4-3 Check | `label_outcomes.py` | `fire_outcomes.csv` (기본: `leg_gt` 청산) |
| 4-4 Act | `select_rules.py` | `matched_rules.json`, `backtest_summary.html` |
실행 (스텁):
## 실행
```bash
# 전체 (enrich+스캔 약 2~3분)
python scripts/04_match_rules.py
# 단계별
python scripts/04_match_rules.py --phase profile
python scripts/04_match_rules.py --phase scan
python scripts/04_match_rules.py --phase label
python scripts/04_match_rules.py --phase select
```
선행: `python scripts/03_analyze_trades.py`
## 설정 (`.env` / `config.py`)
- `MATCH_LABEL_MODE``leg_gt`(다음 GT 매도/직전 매수) 또는 `forward`
- `MATCH_MAX_HOLD_DAYS` — leg_gt 최대 보유 일수 (기본 45)
- `MATCH_INCLUDE_ATOMIC` — 0이면 atomic 규칙 제외
- `MATCH_FORWARD_BARS` — leg_gt 불가 시 폴백 봉 수 (기본 60)
- `MATCH_TRAIN_RATIO` — train/valid 분할 (기본 0.7)
- `MATCH_MIN_FIRES`, `MATCH_MIN_EV_VALID`, `MATCH_MIN_PROFIT_FACTOR`