Skip to content

eluckydog/math-to-alpha

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

math-to-alpha — Mathematical Structure → Alpha Factor Mining

Translating mathematical structures from physics papers into quantitative factors, with empirical validation on real market data. Because paper-to-factor translation needs evidence, not argument.

Python 3.10+ License MIT


One-Sentence Insight

Mathematical structure (box-counting dimension, Poisson clustering, Hurst persistence) often fails as a standalone alpha factor — and documenting clean failures is as valuable as finding signals. This repository shows three translations from arXiv:2603.14100 into quant factors, each validated on real A-share data, with rigorous IC comparison.


📊 Quick Results: IC with Future 20-Day Volatility (600519, 2015–2024)

| Factor | IC (|r|) | Verdict | |--------|--------|---------| | Box-Counting Dimension D(t) | 0.005–0.072 | ❌ Dead — paper math doesn't survive market translation | | Tail Event Clustering (KS p) | 0.297 | ⚠️ Strongest but wrong sign (p↑→vol↑ = counterintuitive) | | Hurst Exponent H(t) | 0.208→0.241 | ✅ Works — direction correct, horizon-gradient monotonic |

Comparison Summary

Key Finding

Hurst H(t) is the only factor with both correct direction and horizon consistency: higher persistence → higher future volatility, with IC rising monotonically from 0.15 (5d) to 0.24 (60d). Tail clustering registers the highest absolute IC (0.30) but with an inverted signal direction, suggesting it may work as a reversal indicator rather than a warning signal.


🏗️ Architecture

math-to-alpha/
├── factors/                    # Three factor implementations
│   ├── factor_box_count.py     #   1. Box-Counting Dimension D(t)
│   ├── factor_tail_clustering.py # 2. Tail Event Clustering
│   └── factor_hurst.py         #   3. Hurst Exponent H(t)
├── scripts/
│   ├── pull_data.py            # AKShare data fetcher
│   └── run_all.py              # Run all three factors in sequence
├── data/
│   └── 600519_daily.csv        # 600519 daily data 2015-2024 (2431 trading days)
├── figures/                    # Diagnostic plots + comparison summary
├── tests/                      # Test suite
└── LICENSE                     # MIT

🚀 Quick Start

# 1. Install dependencies
pip install numpy pandas scipy matplotlib akshare

# 2. Pull data (or use pre-packaged data/600519_daily.csv)
python scripts/pull_data.py

# 3. Run all three factors
python scripts/run_all.py

# 4. Check figures/ for output
#    - dimension_plot.png — Box-counting dimension
#    - tail_clustering.png — Tail event clustering
#    - hurst_factor.png — Hurst exponent
#    - comparison_summary.png — Side-by-side IC comparison

📈 Factor Details

1. Box-Counting Dimension — factor_box_count.py

Math: Cover the price graph with ε×ε squares, count N(ε), fit log(N) vs log(1/ε). D=1 for smooth trends, D≈1.5 for Brownian motion, D→2 for white noise.

Validation: Multi-window (60/120/250 days), both absolute D(t) and ΔD(t) rate-of-change. Result: no predictive power — D(t) measures roughness/persistence but doesn't capture directional volatility expectation.

Why it failed: The paper's free-boundary theorem (dim≤1 at equilibrium) is a static property. Price series in the wild are never near equilibrium in this sense.

2. Tail Event Clustering — factor_tail_clustering.py

Math: Under Poisson null, tail events (3σ returns) arrive independently with exponential interval distribution (CV=1). When intervals cluster (CV>1), the process departs from equilibrium.

Validation: KS test against exponential + CV ratio. Result: r=0.30 with future vol, but the sign is inverted — high KS-p (no clustering) predicts higher vol. Possible interpretation: isolated large moves occur in trending/volatile regimes, while clustered tails indicate post-discharge calm.

3. Hurst Exponent — factor_hurst.py

Math: R/S analysis: H>0.5 = persistent (trending), H<0.5 = anti-persistent (mean-reverting), H=0.5 = random walk.

Validation: Multi-horizon IC (5d→60d), multi-window (60/120/250). Result: IC 0.21-0.24, horizon-gradient monotonic, direction correct. This passes all sanity checks.

Why it works: Hurst directly measures the persistence structure that box-counting only indirectly captures. The R/S method's built-in normalization across time scales makes it robust to price level shifts.


🧪 Methodology

This repository follows a strict paper→factor→validate protocol:

  1. Extract a mathematical structure from a paper (arXiv:2603.14100)
  2. Implement a rolling-window computation with tunable parameters
  3. Validate on 600519 (Kweichow Moutai) daily data, 2015–2024
  4. Compare IC with future realized volatility across multiple horizons
  5. Interpret — does the sign make economic sense? Is the horizon gradient stable?

Clean failures (like box-counting dimension) are documented with full reasoning, not hidden. Knowing what doesn't work prevents wasted months on false leads.


📦 Dependencies

  • numpy, scipy — numerical computation
  • pandas — data handling
  • matplotlib — visualization
  • akshare — A-share data access (only for data pull)

📄 License

MIT — use it, fork it, build on it.


🔗 Related

  • arXiv:2603.14100 — McCann, O'Brien, Rankin: Singularities are discrete in equilibrium

About

数学结构→量化因子。将 arXiv 物理论文中的数学结构翻译为 A 股 alpha 因子,用真实市场数据验证。盒维数、Poisson 聚类、Hurst 指数等,含 IC 对比与失败记录。跨域同构方法论。

Topics

Resources

License

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages