[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-94646":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":9,"language":10,"languages":9,"totalLinesOfCode":9,"stars":11,"forks":12,"watchers":11,"openIssues":12,"contributorsCount":12,"subscribersCount":12,"size":12,"stars1d":12,"stars7d":12,"stars30d":12,"stars90d":12,"forks30d":12,"starsTrendScore":12,"compositeScore":13,"rankGlobal":9,"rankLanguage":9,"license":14,"archived":15,"fork":15,"defaultBranch":16,"hasWiki":15,"hasPages":15,"topics":17,"createdAt":9,"pushedAt":9,"updatedAt":24,"readmeContent":25,"aiSummary":26,"trendingCount":12,"starSnapshotCount":12,"syncStatus":27,"lastSyncTime":28,"discoverSource":29},94646,"systematic-etf-relative-strength-alpha-attribution","wenqi9115-glitch\u002Fsystematic-etf-relative-strength-alpha-attribution","wenqi9115-glitch","Systematic ETF relative-strength research, overlapping-sleeve portfolio construction, LEAN implementation, and factor attribution.",null,"Jupyter Notebook",104,0,40,"MIT License",false,"main",[18,19,20,21,22,23],"algorithmic-trading","factor-models","portfolio-construction","python","quantconnect","quantitative-finance","2026-08-24 04:01:22","# Systematic ETF Relative-Strength Strategy & Alpha Attribution\n\n[![Python 3.10+](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002Fpython-3.10%2B-3776AB.svg)](https:\u002F\u002Fwww.python.org\u002F)\n[![License: MIT](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FLicense-MIT-yellow.svg)](LICENSE)\n\nI built this project to answer a fairly narrow question: can a simple relative-strength rule rotate among liquid commodity and industry ETFs, and how much of the resulting return is actually unexplained alpha?\n\nThe backtest looked attractive at first. The attribution work changed the conclusion. Standard Fama-French controls left a positive intercept, but adding direct proxies for the exposures the strategy was trading raised model R² from 14.0% to 63.6% and reduced the annualized intercept from 16.5% to 0.38%. My final interpretation is therefore a rules-based way to manage commodity and industry exposure, not evidence of persistent standalone alpha.\n\n## Strategy\n\nThe candidate set is `GLD`, `SLV`, `USO`, `SMH`, and `XBI`; `SPY` is used only as the comparator. For ETF \\(i\\) on date \\(t\\), the signal is its 20-session adjusted return less the corresponding SPY return:\n\n$$\nRS_{i,t}^{20}=\\left(\\frac{P_{i,t}}{P_{i,t-20}}-1\\right)-\\left(\\frac{P_{SPY,t}}{P_{SPY,t-20}}-1\\right).\n$$\n\nAt each rebalance, the two highest finite signals receive 2.5% sleeves. Each sleeve remains active for ten trading sessions, so repeated selections accumulate:\n\n$$\nw_{i,t}=0.025\\sum_{k=0}^{9}\\mathbf{1}\\{i\\text{ was selected at }t-k\\}.\n$$\n\nThis construction makes the portfolio limits easy to audit. Ten active sleeves cap a single ETF at 25%; two selections per day cap total gross exposure at 50%. The parameters are fixed in [`configs\u002Fstrategy_config.json`](configs\u002Fstrategy_config.json).\n\nThe 20-day ranking window is meant to capture medium-horizon persistence without reacting to every daily move. The 10-day holding period smooths turnover through overlapping vintages, while Top 2 avoids diluting the ranking across a five-asset universe. These are design choices, not claims that the parameters are universally optimal.\n\n## Research and implementation flow\n\n```mermaid\nflowchart LR\n    A[\"Adjusted daily closes\"] --> B[\"20-day excess return vs. SPY\"]\n    B --> C[\"Rank eligible ETFs\"]\n    C --> D[\"Select top two\"]\n    D --> E[\"Create ten-day sleeves\"]\n    E --> F[\"Aggregate constrained targets\"]\n    F --> G[\"QuantConnect \u002F LEAN orders\"]\n    G --> H[\"Feature and order reconciliation\"]\n    H --> I[\"Factor attribution\"]\n```\n\nThe pure-Python core handles signal and target construction. A guarded LEAN adapter keeps engine-specific concerns separate. Tests cover deterministic ranking, overlapping-sleeve accounting, risk caps, and the contract between the research logic and LEAN implementation.\n\n## Recorded results\n\n### QuantConnect cloud backtest\n\n| Metric | Value |\n|---|---:|\n| Period | 2024-01-01 to 2026-06-12 |\n| Start \u002F end equity | $100,000 \u002F $169,048.31 |\n| Cumulative net profit | 69.048% |\n| Sharpe ratio | 1.078 |\n| Maximum drawdown | 11.700% |\n| Orders \u002F fees | 1,025 \u002F $1,021 |\n\nThese are frozen historical backtest outputs. They are not live results or expected future returns.\n\n### Return attribution\n\n| Model | N | R² | Annualized intercept | Newey-West t-stat |\n|---|---:|---:|---:|---:|\n| FF3 | 584 | 0.108 | 18.26% | 2.22 |\n| FF5 | 584 | 0.140 | 16.50% | 2.02 |\n| FF5 + Momentum | 584 | 0.140 | 16.48% | 1.99 |\n| FF5 + Momentum + direct ETF proxies | 584 | 0.636 | 0.38% | 0.07 |\n\nThe last specification adds `GLD-RF`, `USO-RF`, `SMH-SPY`, and `XBI-SPY`. That is the most important result in the repository: the apparent FF-only alpha largely disappears once the regression includes controls that match the portfolio's actual economic exposures.\n\n## Repository layout\n\n```text\nstrategy\u002F    Signal, sleeve-accounting, and LEAN adapter code\nconfigs\u002F     Frozen strategy parameters\nnotebooks\u002F   Executed signal-research and attribution notebooks\nreports\u002F     Final research summary\ntests\u002F       Signal, portfolio, and implementation-contract tests\ndocs\u002F        Methodology and limitations\n```\n\n## Running locally\n\n```bash\npython3 -m venv .venv\nsource .venv\u002Fbin\u002Factivate\npython -m pip install -r requirements.txt\npython -m unittest discover -s tests -v\njupyter lab\n```\n\nStart with [`notebooks\u002F01_strategy_research.ipynb`](notebooks\u002F01_strategy_research.ipynb), then continue to [`notebooks\u002F02_factor_attribution.ipynb`](notebooks\u002F02_factor_attribution.ipynb). The notebooks use deterministic synthetic data so the workflow can run without redistributing vendor observations. Aggregate figures above are copied from the completed project report and kept separate from the synthetic examples.\n\nAdditional detail is in the [methodology](docs\u002Fmethodology.md), [limitations](docs\u002Flimitations.md), and [final research summary](reports\u002Ffinal_research_summary.md).\n\n## Caveats\n\nThis is a research project, not a production trading system. The short sample, small and heterogeneous ETF universe, in-sample parameter choices, transaction-cost assumptions, and omitted tax\u002Fcapacity effects all limit what can be inferred from the backtest. There was no real-money deployment. See [`docs\u002Flimitations.md`](docs\u002Flimitations.md) for the full list.\n\nThis repository is for research and educational purposes only and is not investment advice.\n","这是一个面向ETF的系统性相对强度策略研究与归因分析项目，聚焦于商品和行业类ETF（如GLD、USO、XBI等）相对于SPY的中期动量信号构建、重叠式分层组合构造及因子归因检验。核心功能包括：基于20日超额收益的相对强度排序、双标的+10日滚动持仓的约束型组合构建、与QuantConnect\u002FLEAN平台的可验证对接，以及使用Fama-French等因子模型对策略收益进行严谨的alpha分解。项目强调可审计性与归因透明性，适用于量化研究员、组合管理人及学术研究者开展ETF轮动策略的实证评估、风险归因与因子暴露诊断。",2,"2026-08-13 02:30:08","CREATED_QUERY"]