SPB Git

spb/wp40_uqo

Public MIT
7.8 KB · 123 lines markdown
1<!-- Author: Simon-Pierre Boucher — simon-pierre.boucher@uqo.ca -->2# ⚡ RAID — Research Architecture for Intraday Data34**UQO Working Paper No. 40** — *A Metal-Accelerated C++ Framework for Reproducible High-Frequency Financial Econometrics*56[![Paper](https://img.shields.io/badge/paper-PDF%20(30%20p.)-b31b1b?logo=latex&logoColor=white)](paper/main.pdf)7[![C++20](https://img.shields.io/badge/C%2B%2B-20-00599C?logo=cplusplus&logoColor=white)](CMakeLists.txt)8[![Metal](https://img.shields.io/badge/Metal-4%20(FP32)-000000?logo=apple&logoColor=white)](backends/metal/)9[![Python](https://img.shields.io/badge/python-3.12%2B%20nanobind-3776AB?logo=python&logoColor=white)](pyproject.toml)10[![Data](https://img.shields.io/badge/data-FinData%20OS%20%C2%B7%20FirstRate%20(private)-4051b5)](docs/audit.md)11[![Institution](https://img.shields.io/badge/UQO-D%C3%A9pt.%20des%20sciences%20administratives-16365c)](https://uqo.ca)12[![Author](https://img.shields.io/badge/author-Simon--Pierre%20Boucher-16365c)](mailto:simon-pierre.boucher@uqo.ca)1314> **TL;DR** — RAID asks whether heterogeneous high-frequency econometric workloads (realized measures, rolling/batched15> regressions, HAR, GARCH-family QML, block bootstrap) can be turned into batched, fused, streaming computation on Apple16> Silicon **without** losing estimator accuracy, inference validity or reproducibility. It is a C++20 library with a FP6417> CPU reference backend, an optional FP32 Metal backend (Apple GPUs have no FP64), nanobind Python bindings, a CLI, a18> FinData OS client, and a benchmark protocol that reports break-even points and the cases where the CPU wins.19> Status: Phases 0–7 complete (2026-11-02); Phase 8 review in progress — see `RESEARCH_STATUS.md`.2021---2223## 📌 Status2425| Item | Value |26|---|---|27| Version | 1.0 (November 2026) — manuscript v1.0, library 0.1.0 |28| SSRN | not yet submitted |29| Journal | targets: J. Financial Econometrics, J. Financial Data Science, J. Computational Finance |30| Code & data | 55 test cases pass on macOS 27 / Xcode 27.2 (CPU + Metal); synthetic fixtures only in git; real bars via FinData OS (private license, not redistributed); every table/figure generated from `experiments/results/` |31| Ledger | `RESEARCH_STATUS.md` · `docs/PROGRESS.md` · `docs/DECISIONS.md` · `docs/risks.md` |3233## 🎯 What this paper does3435Three falsifiable questions. **RQ1** At what data and batch sizes does Metal beat an optimized multicore CPU, once I/O,36shader compilation, synchronization and transfers are counted? **RQ2** Does batched estimation raise throughput while37preserving statistical coverage and convergence? **RQ3** Can an Arrow/Parquet-to-estimator pipeline materially reduce38copies, memory pressure and end-to-end latency? Negative results are published. Tier A methods (returns, calendar-aware39aggregation, RV/BPV/RSV/RQ/jumps/rCov, OLS/WLS/ridge with HC/HAC/cluster inference, HAR family, GARCH/GJR/EGARCH with40Gaussian/Student-t QML, block bootstrap) are validated against R `highfrequency`/`rugarch` and Python41`statsmodels`/`arch`; GPU results are validated against the FP64 CPU reference with per-method tolerances.4243## 🏆 Headline results4445| Finding | Evidence |46|---|---|47| Metal (FP32 double-float) matches FP64 within 1e−6 on realized measures/regression statistics and 2e−5 on GARCH likelihoods; bitwise reproducible across runs and thread counts | `tests/unit/test_metal_backend.cpp`, `experiments/results/raw/e5_inference.jsonl` |48| Fused realized kernel: Metal wins from ≈ 4×10⁴ elements, 2.0–3.4× vs 18-thread CPU at 4×10⁶–4×10⁷ (kernel level); 1.07–1.41× at the estimator level on 40 M real returns | `bench_primitives_summary.json`, `raw/e1_batched_rv.jsonl` |49| Batched GARCH likelihood grids: 5.1× (888 series × 256 vectors) to 7.9×; single-vector recursions: CPU wins | `raw/e3_garch.jsonl`, `raw/bench_primitives.jsonl` |50| Rolling sums: CPU wins at every size (negative result) | `raw/bench_primitives.jsonl` |51| Parquet→estimates pipeline: 20 M bars/s (RAID CPU) vs 14 M (Polars, DuckDB) vs 0.9 M (pandas); column projection mattered more than any kernel | `raw/e6_pipeline.jsonl`, `raw/e6_baselines.jsonl` |52| 11 Apple Silicon machines (M2→M6): all Metal tests pass; GPU speedup 4.0× (M2) → 1.1× (M5 Max) — largest where the CPU is weakest | `raw/e7/`, `e7_summary.json` |53| Tier A reproduces highfrequency / rugarch / statsmodels / arch to documented tolerances; Monte Carlo coverage 0.90–0.97 | `tests/reference/`, `docs/methods/registry.md` |5455## 🗂 Repository layout5657```58wp40_raid/59├── include/raid/{core,data,statistics,estimators,models,backend}/   # public C++20 headers60├── src/…  backends/cpu/  backends/metal/{host,shaders}/             # implementations (Metal: Phase 3)61├── bindings/python/ python/raid/ cli/                                # nanobind module, Python API, `raid` CLI62├── tests/{unit,property,reference,simulation,stress,integration}/   # Catch2 (reference = vs statsmodels/arch/highfrequency)63├── benchmarks/ experiments/{configs,scripts,results,manifests}/     # harness + tracked artifacts (Phase 6)64├── datasets/{synthetic,fixtures}/                                    # synthetic only; real data cached outside git65├── docs/ paper/ scripts/ .github/workflows/66```6768## 🚀 Quick start6970```bash71brew install cmake ninja eigen apache-arrow catch2 nlohmann-json          # macOS72cmake --preset macos-release && cmake --build --preset macos-release      # CPU + Metal + Arrow73ctest --preset macos-release                                               # unit + reference tests74./build/macos-release/raid devices75./build/macos-release/raid validate datasets/fixtures/synthetic_bars_1m.csv76./build/macos-release/raid estimate realized datasets/fixtures/synthetic_bars_1m.csv --backend auto77uv venv --python 3.12 .venv && uv pip install --python .venv/bin/python -e ".[dev]"   # Python package (nanobind)78```7980Linux / CPU-only: `cmake --preset cpu-only && cmake --build --preset cpu-only && ctest --preset cpu-only`.8182## 🗃 Data8384Market data come from the owner's **FinData OS** lakehouse (`https://findata.spboucher.ai/api/v1`, FirstRate Data under85a private-use license): 1-minute OHLCV bars (bar-open timestamps, extended 04:00–20:00 ET, regular 09:30–16:00 with the8616:00 closing print, zero-volume minutes absent at the source), dataset versions pinned via `X-Dataset-Version`. Raw87bars are never committed; `datasets/fixtures/` contains synthetic bars generated by `scripts/make_fixtures.py`.8889## 🔬 Methodology9091See `docs/methods/registry.md` (one entry per method: equations, conventions, reference software and tolerance) and92`docs/architecture/overview.md`.9394## 🖼 Figures & tables inventory9596Generated by `experiments/scripts/make_paper_assets.py` (hashes in `experiments/manifests/paper_assets.json`):97`paper/tables/tab_{primitives,e1,e2_accuracy,e2_runtime,e3_fits,e4,e5,e6,e7}.tex`, `paper/figures/fig_{primitives_throughput,e1,e7}.pdf`.9899## ⚠️ Limitations100101Apple Metal has no FP64: GPU paths are FP32 with compensated reductions and FP64 combination on the CPU, and are only102valid where the documented tolerance is met. No tick/quote data: microstructure-noise and order-flow methods are out of103scope. Energy is reported only when measured.104105## 📖 Citation106107```bibtex108@techreport{boucher2026raid,109  title  = {RAID: A Metal-Accelerated C++ Framework for Reproducible High-Frequency Financial Econometrics},110  author = {Boucher, Simon-Pierre},111  institution = {Université du Québec en Outaouais, Département des sciences administratives},112  type   = {UQO Working Paper}, number = {40}, year = {2026}113}114```115116## 👤 Author & contact117118Simon-Pierre Boucher — simon-pierre.boucher@uqo.ca — Département des sciences administratives, UQO.119120## 📝 Notes121122Directory name `wp40_raid` (charter requirement) instead of the usual slug; git remote `gitsrv:srv/git/wp40_uqo.git`.123
Files · main
Menu

Theme