Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,15 @@ python main.py --mode health
# 게이트 artifact의 장애성 신호(부재/stale/표기 불일치)는 ATTENTION(1)으로 강등된다.
# 같은 점검을 tools/paper_runtime_status.py --health (--json) 으로도 실행할 수 있습니다.

# 주간 요약 리포트 (성과 · 귀속 분해(실행/구성 격차) · 진행률 · 주간 이벤트 → 디스코드)
python main.py --mode weekly_report

# 바스켓 배포 점검 (계획 주문·예상 비용·활성화 절차)
python main.py --mode deploy_check

# 바스켓 paper 운영 평가 (승격 판정 + 성과 귀속 분해)
.venv\Scripts\python.exe tools/basket_paper_evaluation.py

# 휴장일 갱신
python main.py --update-holidays
```
Expand Down
4 changes: 4 additions & 0 deletions docs/PAPER_MONTH1_REVIEW_AND_PLAN.md
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,10 @@ P0-1(하트비트·재시도)을 먼저 머지하고 재시작하는 순서를
> 적대적 리뷰 반영: 결측 판정 '오늘'을 스냅샷 귀속과 같은 KST로 맞춤(비KST 호스트 오탐 방지),
> 룩백 14일로 확대(명절 연휴 클러스터 커버), live 동기화 실패 시 CYCLE_ERROR 기록,
> run_rebalance 배선 통합 테스트 보강(스킵/critical 분기).
> → **재시도 크론 설정 완료(2026-07-06)**: 스케줄 작업 `basket-snapshot-retry`(평일 11:00·14:00,
> 당일 스냅샷 결측 시에만 사이클 재실행 — TODAY_OK면 무동작) + `weekly-basket-report`
> (금 16:00, --mode weekly_report). 운영 검증: 7/3·7/6 사이클에서 CYCLE_START/END·
> SNAPSHOT_SAVED·GAP(6/26, warning) 이벤트가 설계대로 기록됨을 확인.
> - ⬜ P0-2 SMTP 재발급 — 오너 액션
> - ✅ **P1-5 집계 배치율 감시** — `core/operator_health.py`에 순수 `summarize_deployment`
> 추가, `summarize_basket_operation`이 설계 대비 -5%p 초과 미달 시 ATTENTION 승격.
Expand Down
13 changes: 8 additions & 5 deletions docs/PROJECT_GUIDE.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# QUANT TRADER — 프로젝트 가이드

> **목적**: 코드를 볼 때 **파일별 역할**, **프로그램 흐름**, **알고리즘·설정**을 세세히 알 수 있도록 정리한 문서.
> **문서 버전**: v6.1
> **최종 수정**: 2026-06-10 (guide/health/deploy_check 모드, 바스켓 paper 운영 개시·승격 기준·일일 스냅샷/백업 반영)
> **문서 버전**: v6.2
> **최종 수정**: 2026-07-06 (weekly_report 모드, 사이클 관측성·집계 배치율 감시·성과 귀속 분해 반영 — 한 달 운영 리뷰 후속. 이전: 2026-06-10 guide/health/deploy_check)
> **참고**: 전체 아키텍처·지표 공식·전략 상세·시스템 진단은 루트의 `quant_trader_design.md` 참고.

---
Expand Down Expand Up @@ -66,6 +66,7 @@
| **rebalance** | `run_rebalance(args)` | BasketRebalancer (baskets.yaml 기반 목표 비중 vs 실제 비중 드리프트 체크 → 주문 생성·실행). `--basket`, `--dry-run` 옵션 지원. live 실행은 바스켓별 `basket_rebalance:<basket>` 승인 단위로 live gate/account/order tag가 일치해야 한다. **종료 시(비 dry-run) paper 일일 NAV 스냅샷 저장 + DB 일일 백업**(`database.backup_path` 설정 시) — 상시 스케줄러 없이 일일 CLI만으로 트랙레코드 시계열·백업이 쌓인다 |
| **health** | `run_health_check()` | core.operator_health — 전 전략 runtime state + current_blockers + **바스켓 paper 운영(스냅샷 끊김 감시)**을 단일 verdict(OK/ATTENTION/BLOCKED)로 요약. 반환 코드 0/1/2 |
| **deploy_check** | `run_deploy_check(args)` | 바스켓 배포 점검 — 계획 주문·예상 비용·회전율·활성화 절차 출력. `--as-of`, `--json` 지원 |
| **weekly_report** | `run_weekly_report()` | core.weekly_report — 주간 다이제스트 디스코드 발송(주간/누적 성과 · vs KS11 · **귀속 분해(실행/구성 격차)** · 진행률/커버리지 · 주간 이벤트[결측 고유일수·사이클 오류]). 금요일 크론용 |
| **guide** | (인자 없이 실행과 동일) | 사용 가이드 치트시트 출력 후 종료. 시스템 초기화 없음 |

---
Expand All @@ -74,7 +75,7 @@

```
quant_trader/
├── main.py # CLI 진입점, --mode 분기 (17개 모드; 무인자 실행 시 가이드 출력)
├── main.py # CLI 진입점, --mode 분기 (18개 모드; 무인자 실행 시 가이드 출력)
├── test_integration.py # 통합 검증 스크립트 (단일 실행, pytest 아님)
├── pyproject.toml # 프로젝트 메타데이터 (Python >=3.11,<3.13, 패키지, pytest 설정)
├── requirements.txt # pip 의존성 목록
Expand Down Expand Up @@ -126,8 +127,10 @@ quant_trader/
│ ├── target_weight_rotation.py # Portfolio-level target-weight plan 생성/검증, 가격 최신성 진단
│ ├── evidence_collector.py # Deprecated v1 collector no-op shim (v2 paper_evidence 사용)
│ ├── promotion_engine.py # metrics 기반 전략 승격 판정 (research→paper→live)
│ ├── operator_health.py # 운영 통합 헬스 요약 (전략 runtime + blockers + 바스켓 운영 → OK/ATTENTION/BLOCKED)
│ ├── basket_evaluation.py # 바스켓 paper→live 승격 판정 (60영업일·커버리지·dead-letter·비용 드래그 → WAIT/PASS_CANDIDATE/FAIL_REVIEW)
│ ├── operator_health.py # 운영 통합 헬스 요약 (전략 runtime + blockers + 바스켓 운영·집계 배치율 → OK/ATTENTION/BLOCKED)
│ ├── basket_evaluation.py # 바스켓 paper→live 승격 판정 (60영업일·커버리지·dead-letter·비용 드래그 → WAIT/PASS_CANDIDATE/FAIL_REVIEW) + 리포트 v2 부가필드 + 성과 귀속 분해(실행/구성 격차)
│ ├── cycle_observability.py # 일일 사이클 관측성 (CYCLE_START/END/ERROR·SNAPSHOT_* 이벤트 기록, 스냅샷 결측 감지·당일 경보)
│ ├── weekly_report.py # 주간 요약 다이제스트 포맷터 (성과·귀속·진행률·주간 이벤트 — --mode weekly_report)
│ ├── position_lock.py # threading.RLock (포지션/주문 동시 접근 제어)
│ └── order_guard.py # 동일 종목 TTL(기본 600초) 동안 중복 주문 차단
├── tools/
Expand Down
8 changes: 6 additions & 2 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -1860,7 +1860,11 @@ def _build_cli_guide(args) -> str:
" python main.py --mode dashboard",
" 실시간 웹 대시보드 (기본 http://127.0.0.1:8080).",
" python main.py --mode health",
" 전 전략 운영 헬스·blocker 점검.",
" 전 전략 운영 헬스·blocker 점검 (배치율 미달·스냅샷 끊김 포함).",
" python main.py --mode deploy_check --basket <이름>",
" 바스켓 배포 점검 (계획 주문·예상 비용·활성화 절차).",
" python main.py --mode weekly_report",
" 주간 요약 디스코드 발송 (성과·귀속 분해·진행률·주간 이벤트).",
"",
" [실전 — 신중히]",
f" python main.py --mode live --strategy {strategy} --confirm-live",
Expand Down Expand Up @@ -1961,7 +1965,7 @@ def main():
"weekly_report",
"guide",
],
help="실행 모드. backtest_momentum_top: 모멘텀 상위 동일비중 멀티종목. portfolio_backtest: 멀티종목 포트폴리오 백테스트. paper: 워치리스트 1회. schedule: 모의 스케줄 무한 루프(상시 서버). rebalance: 바스켓 리밸런싱. health: 운영 통합 헬스 점검(전 전략 runtime + blockers). deploy_check: 바스켓 배포 점검(계획·비용·활성화 절차).",
help="실행 모드. backtest_momentum_top: 모멘텀 상위 동일비중 멀티종목. portfolio_backtest: 멀티종목 포트폴리오 백테스트. paper: 워치리스트 1회. schedule: 모의 스케줄 무한 루프(상시 서버). rebalance: 바스켓 리밸런싱. health: 운영 통합 헬스 점검(전 전략 runtime + blockers). deploy_check: 바스켓 배포 점검(계획·비용·활성화 절차). weekly_report: 주간 요약 디스코드 발송(성과·귀속 분해·진행률·이벤트).",
)
from strategies import get_strategy_names
parser.add_argument(
Expand Down
11 changes: 11 additions & 0 deletions tests/test_cli_guide.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,14 @@ def test_guide_mode_accepts_strategy_and_symbol_defaults():
assert result.returncode == 0
assert "python main.py --mode guide" in result.stdout
assert "python main.py --mode backtest --strategy scoring --symbol 000660" in result.stdout


def test_guide_lists_operation_modes():
# 운영 모드(health/deploy_check/weekly_report)가 가이드에 빠지면 운영자가
# 존재 자체를 모른다 — 가이드 노출을 고정한다.
result = _run_main("--mode", "guide")

assert result.returncode == 0
assert "python main.py --mode health" in result.stdout
assert "python main.py --mode deploy_check" in result.stdout
assert "python main.py --mode weekly_report" in result.stdout
Loading