Skip to content

Commit 5c99b77

Browse files
committed
chore: add collaboration workflow and templates
0 parents  commit 5c99b77

File tree

81 files changed

+21363
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+21363
-0
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
---
2+
name: "Bug/复现问题"
3+
about: "报告复现失败、错误或数据异常"
4+
title: "[Bug] "
5+
labels: "bug"
6+
assignees: ""
7+
---
8+
9+
## 问题描述
10+
11+
请简要说明问题与影响。
12+
13+
## 复现步骤
14+
15+
1. ...
16+
2. ...
17+
18+
## 期望结果
19+
20+
## 实际结果
21+
22+
## 环境信息
23+
24+
- OS:
25+
- Python 版本:
26+
- 分支与 Commit:
27+
- 快照包版本(Release/zip):
28+
29+
## 相关日志/截图
30+
31+
粘贴关键报错或 CSV 异常样例。
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
---
2+
name: "需求/改进"
3+
about: "新增功能、研究改进或流程优化"
4+
title: "[Feature] "
5+
labels: "enhancement"
6+
assignees: ""
7+
---
8+
9+
## 背景与目标
10+
11+
请描述该需求的背景与预期目标。
12+
13+
## 影响范围
14+
15+
- 影响模块:
16+
- 影响命令:
17+
- 是否影响口径(manifest/pricing/阈值/样本/目标变量):
18+
19+
## 输出影响
20+
21+
- 是否会改动输出 CSV(sample_table/stats_table):
22+
23+
## 验证方式
24+
25+
提供复现步骤或验收标准。

.github/workflows/ci.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: ci
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- main
8+
9+
jobs:
10+
lint-and-smoke:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout
14+
uses: actions/checkout@v4
15+
16+
- name: Set up Python
17+
uses: actions/setup-python@v5
18+
with:
19+
python-version: "3.10"
20+
21+
- name: Install minimal tools
22+
run: |
23+
python -m pip install --upgrade pip
24+
pip install ruff
25+
26+
- name: Ruff format check
27+
run: ruff format --check MethodD
28+
29+
- name: Smoke check (syntax)
30+
run: python -m compileall MethodD

.gitignore

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
.DS_Store
2+
__pycache__/
3+
*.pyc
4+
.venv/
5+
.env
6+
.idea/
7+
.vscode/
8+
9+
# MethodD snapshots & outputs
10+
MethodD/data/snapshots/runs/
11+
MethodD/outputs/
12+
13+
# Temporary exports
14+
*.zip
15+
*.tar.gz

CONTRIBUTING.md

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# 协同贡献规范(RMSC6007 Group Project)
2+
3+
本项目采用 **GitHub 私有仓库 + PR 审阅 + 固定产物** 的协同模式,目标是确保**同一份输入快照、同一份代码版本、同一套命令**,任何人都能复现相同的 `sample_table.csv``stats_table.csv`
4+
5+
## 1. 分支与发布规则
6+
7+
- **main 分支永远保持可运行**
8+
- `python3 MethodD/tools/capture_snapshots.py ...`
9+
- `python3 MethodD/experiments/run_iv_factor_study.py`
10+
- main 不接受半成品或无法复现的提交。
11+
12+
- **个人改动必须走 feature 分支 + PR**
13+
- 命名规范:`feat/<name>-<topic>`
14+
- 示例:`feat/alice-report-edits``feat/bob-factor-v2`
15+
16+
## 2. PR 必须回答的三件事
17+
18+
1. **口径是否变化**
19+
- manifest schema、pricing_rule、过滤阈值、样本定义、目标变量定义
20+
2. **可复现性是否破坏**
21+
- 同一快照包 + 同一 commit 产物一致
22+
3. **输出是否变化**
23+
- `MethodD/outputs/sample_table.csv`
24+
- `MethodD/outputs/stats_table.csv`
25+
26+
## 3. 数据快照策略
27+
28+
- **代码仓库只保留 schema / 脚本 / 小型示例快照**
29+
- **真实快照不进 Git**,使用以下方式之一:
30+
1. GitHub Release 附件(zip)
31+
2. 独立私有仓库:`MethodD-data`
32+
33+
## 4. 提交规范
34+
35+
- 每次提交尽量聚焦一个主题(单功能/单修复)。
36+
- 必须在 PR 描述中列出:
37+
- 修改文件列表
38+
- 影响的命令
39+
- 是否更改口径
40+
- 是否新增/修改输出 CSV
41+
42+
## 5. 权限与角色
43+
44+
- **Owner 权限**(你本人)保留:
45+
- 合并 main 权限
46+
- 修改采集口径与 manifest schema 权限
47+
- 其他成员只允许走 feature 分支提交 PR。
48+
49+
## 6. 复现实验最小流程
50+
51+
```bash
52+
python3 MethodD/tools/capture_snapshots.py --ticker NVDA t0
53+
python3 MethodD/tools/capture_snapshots.py t5
54+
python3 MethodD/experiments/run_iv_factor_study.py
55+
```
56+
57+
产物:
58+
- `MethodD/outputs/sample_table.csv`
59+
- `MethodD/outputs/stats_table.csv`

GOOGLE_FORM_SUBMISSION.md

Lines changed: 153 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,153 @@
1+
# Google Form Submission Templates
2+
3+
## 选择方案后,直接复制对应的文本到Google Form
4+
5+
---
6+
7+
## 📋 方案A:VaR/ES 风险度量与回测框架
8+
9+
### Proposed Topic
10+
Unified VaR/ES Risk Measurement and Backtesting Framework in Python (Integrating QuantStats, arch, vectorbt)
11+
12+
### Objectives
13+
• Objective 1: Build a unified Python pipeline that computes Value-at-Risk (VaR) and Expected Shortfall (ES) using multiple methods, including Historical Simulation, Parametric (Gaussian), Monte Carlo, and GARCH-based approaches.
14+
15+
• Objective 2: Implement standard backtesting procedures for VaR forecasts, including coverage tests (e.g., Kupiec POF) and independence tests (e.g., Christoffersen), and produce comparable diagnostics across methods.
16+
17+
• Objective 3: Generate reproducible risk reports (tables and visualizations) and a single-click notebook workflow that benchmarks methods across assets and market regimes.
18+
19+
### Data to be Analyzed
20+
• Source 1: Daily adjusted close prices for 5–10 major equity indices or broad-market ETFs (e.g., S&P 500, Hang Seng, Nikkei 225 equivalents) downloaded via Yahoo Finance using yfinance; sample period fixed (e.g., 2015–2025).
21+
22+
• Source 2: Optional risk-free rate series from FRED via pandas-datareader for risk-adjusted metrics (Sharpe and excess-return calculations).
23+
24+
• Preprocessing: Align trading calendars, handle missing values (forward-fill where appropriate), compute log returns, and standardize rolling-window splits for in-sample fitting and out-of-sample evaluation.
25+
26+
### Possible Comparisons
27+
• Comparison 1: Compare VaR/ES estimates across methods by realized exceedances, coverage ratios, and backtesting p-values under a consistent rolling-window protocol.
28+
29+
• Comparison 2: Stress-period robustness comparison by segmenting the sample into regimes (e.g., calm vs. crisis periods) and evaluating model stability and conservativeness.
30+
31+
• Comparison 3: Cross-asset comparison of tail risk: examine how tail behavior differs across markets and whether GARCH-based VaR improves performance during volatility clustering.
32+
33+
### Expected Outcomes
34+
• Outcome 1: A modular, well-documented Python package with a unified API (single function call to compute VaR/ES + backtests) and reproducible notebooks.
35+
36+
• Outcome 2: An empirical benchmark report showing which VaR/ES methods are most accurate and robust across assets and regimes, with clear interpretation of backtesting results.
37+
38+
• Outcome 3: Engineering deliverables including tests (80%+ coverage), environment specification (requirements/lockfile), and an automated HTML/markdown risk report.
39+
40+
### Possible Extensions
41+
• Extension 1: Add portfolio-level risk aggregation (multi-asset VaR/ES) and compare equal-weight vs. optimized portfolios using PyPortfolioOpt.
42+
43+
• Extension 2: Extend volatility modeling (EGARCH/GJR-GARCH) and evaluate incremental benefits over standard GARCH for VaR prediction.
44+
45+
• Extension 3: Provide a lightweight dashboard (e.g., Streamlit) for interactive exploration of risk forecasts and backtesting outcomes.
46+
47+
---
48+
49+
## 📈 方案B:GARCH 波动率预测与VaR链条
50+
51+
### Proposed Topic
52+
Volatility Forecasting with GARCH-family Models and Its Impact on VaR Forecast Accuracy
53+
54+
### Objectives
55+
• Objective 1: Implement and compare GARCH-family models (GARCH, EGARCH, GJR-GARCH) to capture volatility clustering and asymmetry in financial returns.
56+
57+
• Objective 2: Translate conditional volatility forecasts into forward-looking VaR forecasts and evaluate accuracy using rolling out-of-sample backtesting.
58+
59+
• Objective 3: Produce a reproducible benchmark notebook and report that explains model choice, parameter stability, and forecast performance across assets and regimes.
60+
61+
### Data to be Analyzed
62+
• Source 1: Daily return series for a set of indices/ETFs or a diversified basket of liquid large-cap stocks from Yahoo Finance using yfinance, covering 2015-2025.
63+
64+
• Source 2: Optional volatility index proxies (e.g., VIX-like series when available) for external comparison and validation of GARCH-implied volatility.
65+
66+
• Preprocessing: Stationarity checks (ADF test), return transformation, rolling-window splits, and consistent forecasting horizon settings (1-day, 5-day, 20-day ahead).
67+
68+
### Possible Comparisons
69+
• Comparison 1: Model selection comparison using AIC/BIC and forecast error metrics (RMSE, MAE) for realized volatility proxies.
70+
71+
• Comparison 2: VaR backtesting comparison between GARCH-based VaR and simpler VaR approaches (historical/parametric) using Kupiec and Christoffersen tests.
72+
73+
• Comparison 3: Asset-class/market comparison of asymmetry and leverage effects across different equity indices and sectors.
74+
75+
### Expected Outcomes
76+
• Outcome 1: A validated GARCH-based risk forecasting pipeline with clear documentation and reproducible experiments across multiple assets.
77+
78+
• Outcome 2: Evidence-based conclusions on when sophisticated volatility models materially improve VaR performance vs. simpler methods.
79+
80+
• Outcome 3: A reusable codebase for volatility modeling and risk forecasting tasks with 80%+ test coverage.
81+
82+
### Possible Extensions
83+
• Extension 1: Multivariate correlation dynamics (DCC-GARCH) for portfolio-level risk and contagion analysis.
84+
85+
• Extension 2: Regime-switching volatility models for crisis detection and adaptive risk management.
86+
87+
• Extension 3: Link volatility forecasts to dynamic asset allocation constraints and portfolio optimization.
88+
89+
---
90+
91+
## 💼 方案C:因子暴露与风险归因分析
92+
93+
### Proposed Topic
94+
Factor Exposure Estimation and Risk Attribution with Rolling CAPM/Fama-French Models in Python
95+
96+
### Objectives
97+
• Objective 1: Estimate time-varying factor exposures using rolling regressions under CAPM and Fama-French models to quantify systematic risk contributions.
98+
99+
• Objective 2: Perform risk attribution to decompose portfolio variance into factor-driven and idiosyncratic components, enabling targeted risk management.
100+
101+
• Objective 3: Backtest risk forecasts derived from factor models and compare against naive historical-volatility baselines to validate predictive power.
102+
103+
### Data to be Analyzed
104+
• Source 1: Daily returns for a portfolio of stocks/ETFs from Yahoo Finance via yfinance, covering 2015-2025 across multiple sectors.
105+
106+
• Source 2: Factor return series (Fama-French 3-factor and 5-factor models) from Kenneth French's data library, aligned by date; risk-free rate from FRED for excess returns.
107+
108+
• Preprocessing: Date alignment across sources, winsorization of extreme returns (beyond 5 standard deviations), rolling-window estimation choices, and out-of-sample evaluation design.
109+
110+
### Possible Comparisons
111+
• Comparison 1: CAPM vs. FF3/FF5 explanatory power (R², alpha significance, residual volatility) to assess incremental value of multi-factor models.
112+
113+
• Comparison 2: Risk forecast comparison between factor-based and historical-volatility approaches using rolling backtesting.
114+
115+
• Comparison 3: Style/sector portfolio comparison of factor exposures and risk contributions to identify which factors drive risk in different investment styles.
116+
117+
### Expected Outcomes
118+
• Outcome 1: A reproducible framework that outputs rolling betas, factor contributions, and risk decomposition tables/plots for any portfolio.
119+
120+
• Outcome 2: Quantified evidence of which factors drive risk across portfolios and regimes, with clear interpretation of results.
121+
122+
• Outcome 3: Clean, documented code with notebooks demonstrating end-to-end factor risk analytics and actionable insights.
123+
124+
### Possible Extensions
125+
• Extension 1: Incorporate macro factors (interest rates, inflation) and PCA-based dynamic factors for broader economic risk modeling.
126+
127+
• Extension 2: Conditional factor models where factor loadings depend on market conditions (volatility regime, business cycle phase).
128+
129+
• Extension 3: Multi-asset risk attribution (equity + bond + commodity) with cross-asset factor exposures.
130+
131+
---
132+
133+
## 📝 Team Information Template
134+
135+
**Group Leader Name:** [填写]
136+
**Group Leader Student ID:** [填写]
137+
**Group Leader Email:** [填写]
138+
139+
**Member 2 Name:** [填写]
140+
**Member 2 Student ID:** [填写]
141+
**Member 2 Email:** [填写]
142+
143+
**Member 3 Name:** [填写]
144+
**Member 3 Student ID:** [填写]
145+
**Member 3 Email:** [填写]
146+
147+
**Member 4 Name (if applicable):** [填写]
148+
**Member 4 Student ID:** [填写]
149+
**Member 4 Email:** [填写]
150+
151+
**Member 5 Name (if applicable):** [填写]
152+
**Member 5 Student ID:** [填写]
153+
**Member 5 Email:** [填写]

0 commit comments

Comments
 (0)