A walk-forward equity return forecasting and backtesting platform.
Live API · Live dashboard — both on Render's free tier, so the first request after an idle period takes 30-60s to wake the container.
Disclaimer. AlphaBench is an academic research and software-engineering artifact. It is not investment advice, not a trading product, and must not be used to make financial decisions. All results are historical simulations and carry no guarantee of future performance. This disclaimer is repeated in every API response and rendered before anything else on the dashboard.
AlphaBench asks one narrow, honestly-measurable question: given a universe of liquid equities and their daily OHLCV history, can a supervised model predict the sign of the next h-day return with accuracy statistically distinguishable from chance, and does that edge survive realistic transaction costs?
It deliberately does not attempt to predict price levels — the naive formulation nearly
every "stock prediction LSTM" project uses, which trivially "succeeds" by learning that
tomorrow's price looks like today's. That result has zero economic content. AlphaBench
instead predicts direction, on a volatility-scaled deadband, validated with expanding-
window walk-forward cross-validation (purge + embargo), backtested net of costs against
buy-and-hold, and reported with bootstrap confidence intervals throughout. See
docs/PROPOSAL.md for the full methodology and rationale.
The primary market (NSE, 30 large-cap Indian equities, h=1 day) is a null result, and this is reported as such.
| Metric | Value |
|---|---|
| Walk-forward ROC-AUC (mean across 7 folds, 2017-2023) | 0.506 (M1 LightGBM); 0.49-0.52 across the entire model ladder |
| Backtest Sharpe, net of 10 bps costs | 0.108 |
| Buy-and-hold NIFTY Sharpe, same window | 1.80 |
| Excess Sharpe (strategy − benchmark) | −1.69 |
| Bootstrap 95% CI on strategy Sharpe | [−0.45, 1.13], p(Sharpe > 0) = 0.70 |
| Strategy Sharpe at 20 bps costs | −0.13 (negative) |
| Deflated Sharpe probability (50 Optuna trials) | 0.46 — not significant at 95%; the null bar alone (0.146 annualised) exceeds the observed 0.108 |
Every model tried — a naive persistence baseline, logistic regression, ARIMA, LightGBM, XGBoost, an LSTM, and a rank-average ensemble of the last three — lands in a tight 0.49-0.52 AUC band, each with a fold-to-fold standard deviation of roughly 0.01-0.02. That means the differences between models are not distinguishable from noise at this sample size, and none of them clears a bar that would survive costs. The strategy underperforms simply buying and holding the NIFTY 50 over the same period.
This is the expected outcome for a rigorous treatment of this problem (see
docs/PROPOSAL.md sections 1 and 8.1) — daily equity returns are close to a martingale difference sequence,
and a ceiling of roughly 53-55% directional accuracy is the realistic best case for any
approach at this data scale. A well-documented null result is treated as a successful
outcome here, not a failure to hide.
The Week 9 generalisation test (identical pipeline, US large-caps, benchmark SPY) confirms the same finding on an independent market:
| Metric | NSE (primary) | US (generalisation) |
|---|---|---|
| Walk-forward ROC-AUC, M1 LightGBM h=1 | 0.506 ± 0.020 | 0.519 ± 0.028 |
| Backtest Sharpe, net of 10 bps | 0.108 | 0.349 |
| Buy-and-hold Sharpe, same window | 1.80 (NIFTY) | 1.05 (SPY) |
| Excess Sharpe | −1.69 | −0.70 |
| Bootstrap 95% CI, p(Sharpe > 0) | [−0.45, 1.13], 0.70 | [−0.22, 1.30], 0.88 |
No hyperparameters were retuned for the US run — same DEFAULT_PARAMS as NSE, only the
universe/benchmark changed. The strategy beats a coin flip by a small, noisy margin in
both markets and underperforms simply buying and holding in both. That consistency across
two independent markets is itself the finding: this isn't a market-specific fluke, it's
what you get from this feature set and this data scale in general.
The sealed holdout (2025-01-01 onward, touched exactly once) confirms it: ROC-AUC 0.5047, bootstrap 95% CI [0.4817, 0.5266] — straddling 0.50, indistinguishable from chance. Net of 10 bps costs, the holdout-period backtest loses money in absolute terms (Sharpe −0.58, ann. return −1.3%) while buy-and-hold NIFTY rises 10.2% over the same 276 trading days (Sharpe 0.73, excess Sharpe −1.31). This is the single most important number in the project, and it agrees with every walk-forward fold, both markets, and the entire model ladder above.
git clone https://github.com/veerendrakosuri/AlphaBench.git
cd AlphaBench
make setup && make allmake all runs ingest → validate → build-features → train (LightGBM h=1) → backtest, and
reproduces the headline numbers above from the committed data/processed/*.parquet (no
network access required — see "Why processed data is committed" below). To reproduce the
full model ladder:
make train # LightGBM h=1, same as `python -m alphabench.cli train --model lightgbm --horizon 1`
python -m alphabench.cli train --model xgboost --horizon 1
python -m alphabench.cli train --model arima --horizon 1
python -m alphabench.cli train --model lstm --horizon 1
python -m alphabench.cli compare-models --horizon 1make test runs the full suite (64 tests, including the leakage and splitter tests that
are the project's actual core); make lint runs ruff + mypy.
Experiment tracking. MLflow is wired into training/train.py and
training/train_xgboost.py and logs every walk-forward fold when training runs locally —
but the local mlruns/ store is gitignored and not carried in this checkout, the same as
.venv/. The evidence that actually matters is committed independently of it: the Optuna
trial data the deflated Sharpe correction rests on is in
reports/metrics/optuna_study_h1.json, and every
model's per-fold metrics are in their own reports/metrics/walkforward_results*.json. See
docs/TECH_STACK_AND_STRUCTURE.md section 2.2 for the
full accounting.
alphabench/
├── config/ master config, US/NSE universes, per-market config files
├── docs/ the specification this was built against (see below)
├── docker/ api.Dockerfile, dashboard.Dockerfile
├── .github/workflows/ ci.yaml, refresh-data.yaml, keep-alive.yaml
├── data/
│ ├── raw*/, interim*/ NEVER committed (gitignored) — provider cache, per market
│ └── processed*/ features/targets/OOF predictions — committed (see below)
├── models/ per-model artifacts + metadata.json (features, params,
│ train dates, CV AUC) — committed
├── reports/
│ ├── figures/ equity curves, SHAP plots, ACF/PACF
│ └── metrics/ every walk-forward/backtest/holdout result as JSON
├── src/alphabench/
│ ├── cli.py Typer app — the single entrypoint for every stage
│ ├── config.py pydantic config loader
│ ├── data/ providers (yfinance + Stooq failover), ingest, validate,
│ │ repository (the only module that touches disk)
│ ├── features/ ~60 shift()-guarded features: momentum, volatility,
│ │ technical, volume, cross-sectional, market/calendar
│ ├── targets/ forward returns + volatility-scaled deadband labels
│ ├── validation/ WalkForwardSplit (purge + embargo), leakage assertions
│ ├── models/ baselines (B0/B1), arima (B2), lstm (M3), ensemble (M4)
│ ├── training/ walk-forward training loops per model + Optuna tuning
│ ├── evaluation/ backtest engine, robustness (bootstrap, deflated Sharpe,
│ │ DM test, per-year/per-ticker), SHAP interpretability
│ ├── api/ FastAPI service (/health, /predict, /backtest, /metrics)
│ └── dashboard/ Streamlit dashboard (signal, backtest, validation tabs)
├── notebooks/ EDA only — imports from src, never the reverse
└── tests/ 64 tests; test_leakage.py and test_splitters-equivalent
coverage are the most important files in the repo
flowchart TD
A[yfinance / Stooq] --> B[Ingest + retry/backoff]
B --> C[(data/raw Parquet)]
C --> D[Validate: schema, bounds, calendar]
D --> E[(data/interim)]
E --> F[Feature engineering, shift-guarded]
F --> G[(data/processed)]
G --> H[Walk-forward CV: purge + embargo]
H --> I[B0/B1/B2 baselines]
H --> J[M1 LightGBM / M2 XGBoost / M3 LSTM / M4 Ensemble]
I --> K[Evaluation: statistical + economic + robustness]
J --> K
K --> L[reports/]
J --> M[FastAPI]
M --> N[Streamlit dashboard]
O[GitHub Actions: CI, keep-alive] --> M
P[refresh-data.yaml: smoke test only,<br/>result discarded, never committed] -.-> B
Why processed data is committed. data/processed/*.parquet (features, targets, OOF
predictions) is tracked in git, unlike data/raw*/ and data/interim*/ which are always
ignored. This is deliberate: the project's own architecture is cache-first — "every
downstream stage reads Parquet, never the network" — and that includes the deployed API,
which never depends on live yfinance availability at build or run time. Raw provider data
is never committed, both for repo hygiene and because yfinance scrapes undocumented
endpoints and shouldn't be redistributed.
The served data updates only on commit. refresh-data.yaml runs on a weekday cron,
but it is a data-availability smoke test: it proves the ingest → validate →
build-features path still works against the live provider (yfinance changes its
undocumented endpoints without notice), uploads the result as a 7-day build artifact for
inspection, and throws it away. It deliberately does not commit data/processed/
back, so /health reports the date of the last human commit rather than last night. That
is a deliberate trade, for four reasons: every number in this README and the technical
report was computed from the exact parquet files committed alongside them, and a nightly
bot replacing those would break that correspondence; fresh data silently enlarges the
sealed holdout window, which is the reuse the single-use guard exists to prevent;
features.parquet is ~46MB of binary that would add gigabytes a year to the repository;
and the ingest step is fail-soft, so auto-committing would ship a partial ingest straight
to production. To refresh what's served, run the pipeline locally, inspect it, and commit.
NSE, h=1, mean across 7 walk-forward folds (2017-2023):
| Model | ROC-AUC | Accuracy | Base rate |
|---|---|---|---|
| B0 persistence | 0.487 | 0.488 | 0.518 |
| B0 majority | 0.500 | 0.518 | 0.518 |
| B1 logistic regression (5 features) | 0.510 | 0.518 | 0.518 |
| B2 ARIMA(1,0,1) on log returns | 0.503 | 0.511 | 0.518 |
| M1 LightGBM (primary) | 0.506 | 0.518 | 0.518 |
| M2 XGBoost | 0.515 | 0.518 | 0.518 |
| M3 LSTM (PyTorch, CPU, small) | 0.515 | 0.518 | 0.518 |
| M4 rank-average ensemble (M1+M2+M3) | 0.514 | 0.508 | 0.518 |
ADF and KPSS tests agree that all 29 symbols' daily log-return series are stationary
(29/29 by both tests), justifying the ARIMA order used; the ACF/PACF of a representative
symbol shows near-white-noise autocorrelation beyond lag 0 — see
reports/figures/arima_acf_pacf.png. Prophet was rejected rather than included in the
ladder: Prophet decomposes a series into trend + seasonality + holiday components, which
presumes structure daily equity returns simply don't have — applying it here would fit
smooth curves to noise rather than model anything real, and demonstrating that intuition
with a run would only have spent compute confirming the obvious.
h=5 (config.yaml's declared horizons: [1, 5]): M1 LightGBM was trained and
backtested identically at the 5-day horizon — mean AUC 0.521 ± 0.028, the same
noise-level result as h=1. See reports/technical_report.md section 3 for the full
h=5 write-up, including a backtest-engine correctness note (h>1 forward-return windows
overlap and cannot be compounded daily without adjustment — evaluation/backtest.py).
The universe is today's 30 constituents, backfilled to 2010. Companies that were
delisted, acquired, or went bankrupt over that window are absent from the sample, which
biases realised returns upward — this bias is not eliminated, only disclosed and
bounded. Because the target here is relative direction rather than absolute return
level, the impact on directional accuracy is materially smaller than it would be on a
long-only return backtest, but it is not zero: any symbol whose long-run drift was
survivorship-conditioned still contributes to the label distribution the model is trained
on. Point-in-time constituent data is not available for free, so this limitation is
inherited rather than fixed. See docs/PROPOSAL.md section 5.4.
What /predict actually runs. One model, and only one: the M1 LightGBM h=1 final
artifact (models/lightgbm_h1/final.joblib) — 47 features, refit on all data from
2010-02-02 to 2024-12-31, i.e. everything before the sealed holdout. /backtest serves the
matching h=1 out-of-fold predictions. Nothing else in the ladder is served: B2 ARIMA stores
only coefficients, M3 LSTM has per-fold checkpoints but no final artifact (it was built as a
comparison arm, not a deployable model), and the h=5 and US-universe models are committed
for inspection but not wired to any endpoint. So the live signal reflects the primary
model's null result, not the ensemble or the best-looking row of the ladder.
- API: FastAPI + Uvicorn, containerised via
docker/api.Dockerfile, deployed to Render's free tier. Render's free web services sleep after ~15 minutes idle; the first request after a sleep takes 30-60 seconds to wake the container. A GitHub Actions workflow (keep-alive.yaml) pings the API's/healthand the dashboard's/_stcore/healthevery 10 minutes during typical waking hours to blunt this for anyone reviewing the project live. The two are separate Render services that sleep independently, so both are pinged; the workflow writes each response code to its run summary, so a dead URL is visible rather than hidden behind a green tick. Scheduled GitHub Actions runs are best-effort and can drift several minutes late, and they are disabled automatically after 60 days without a push — so treat the pings as a courtesy, not a guarantee. - Dashboard: Streamlit, containerised via
docker/dashboard.Dockerfile, deployed as a second free Render web service (same free-tier sleep/wake behaviour as the API above, and kept warm by the same workflow).API_URLis set as an environment variable pointing at the API deployment; the disclaimer renders before any other content on load. The build plan originally called for a Hugging Face Docker Space here, but Hugging Face now requires a PRO subscription to run Docker Spaces (even on free CPU hardware) and no longer offers a free Streamlit-native SDK — Render keeps both services on the same free, no-subscription footing.
Live URLs:
- API: https://alphabench.onrender.com (health, docs)
- Dashboard: https://alphabench-dashboard.onrender.com
Container images. Both services also build and push to GHCR on
every version tag (.github/workflows/deploy.yaml), independent of Render's git-push
deploy — docker pull ghcr.io/veerendrakosuri/alphabench-api:<tag> (and
alphabench-dashboard) runs the exact code from that tag anywhere docker run works,
with no dependency on any one PaaS. This workflow was added after v1.0.0 shipped, so
that release has no corresponding image; the next tag will.
| Document | What it is |
|---|---|
reports/technical_report.md |
The results write-up: methodology, the full ladder, per-year/per-ticker breakdowns, cost sensitivity, bootstrap CIs, deflated Sharpe, the holdout, limitations. Also as PDF with all figures embedded — rebuild with make report. |
reports/viva_deck.md |
13-slide defence deck: problem reframing, methodology, the ladder, holdout, limitations, next steps. Also as PDF. |
docs/PROPOSAL.md |
The original proposal — problem framing, success criteria, methodology, scope boundaries. |
docs/BUILD_PLAN.md |
Stage-by-stage build plan and the final checklist this project was held to. |
docs/TECH_STACK_AND_STRUCTURE.md |
Dependency choices and repository layout rationale. |
notebooks/01_eda_stationarity.ipynb |
EDA: return distributions and fat tails, volatility clustering, ADF/KPSS on prices vs returns, correlation structure, regime timeline, and what each implies for modelling. Outputs are stripped on commit; its figures are saved to reports/figures/eda_*.png. |
The three docs/ files are the specification this was built against, vendored into the
repo so the claims made throughout the README and report can be checked against the
requirements they were written to satisfy.
Complete against docs/BUILD_PLAN.md's "Final checklist before you
call it done": full model
ladder (B0 through M4) scored and committed, both horizons (h=1 and h=5) trained and
backtested, the sealed holdout evaluated exactly once, Optuna trial count and deflated
Sharpe recorded, SHAP interpretability, the US generalisation test, CI green on every
push, and both services deployed and verified live.
MIT — see LICENSE.