SRFM Lab

Special Relativity in Financial Modeling

Price paths as worldlines.

Every bar is tested against a light cone. Ordered, timelike bars build mass; when the mass crosses a threshold a black-hole well forms. This is the lab where that idea gets pushed through backtests, Monte Carlo and a paper trader.

Research code, not financial advice. The diagram below is the real output of MinkowskiClassifier and BlackHoleDetector from lib/srfm_core.py on the SPY, QQQ and DIA daily closes bundled in the repo.

Time runs left to right; up is x = ln(P / P₀) / c, so the light cone sits at 45°. Hover or use the arrow keys on the diagram to read a bar.

Quick start

One command, no API keys.

Python 3.12+. quickstart.py makes a virtual environment, installs the pinned core requirements and runs examples/bh_quickstart.py, which runs the physics on hourly bars cached in the repo, prints a table and saves a chart. The output below is what it printed today.

git clone -c core.longpaths=true https://gitlab.com/mattbusel/srfm-lab
cd srfm-lab
python quickstart.py
srfm-lab
$ python quickstart.py
[1/3] creating .venv/ ...
[2/3] installing the core requirements (numpy, pandas, scipy, matplotlib, ...) ...
[3/3] running examples/bh_quickstart.py on the bundled data

       proxy  bars        from          to  timelike %  BH active %  onsets  all days |ret 5d| %  onset signed ret 5d %  onset hit rate %
symbol
ES       SPY  1542  2020-02-10  2026-04-02       43.45         2.85      23                 1.87                  -0.73             21.74
NQ       QQQ  1541  2020-02-10  2026-04-02       38.94         2.79      16                 2.42                  -0.23             50.00
YM       DIA  1542  2020-02-10  2026-04-02       39.23         1.23       8                 1.76                  -0.38             12.50

Descriptive statistics on one historical sample; not a backtest, no costs, not financial advice.
chart saved to examples/output/bh_quickstart.png

-c core.longpaths=true lets the clone finish on Windows (some committed build outputs have very long paths). Extra arguments go to the example, e.g. python quickstart.py --symbols ES --horizon 10. Run the tests with pip install -r requirements-dev.txt && pytest tests -q, which is what CI runs on Python 3.12 and 3.13.

How it works

A light cone per bar, a well when order persists.

Two small classes carry the idea. Everything else in the lab is built on top of what they emit.

Timelike or spacelike

MinkowskiClassifier divides each bar's return by a per-instrument speed of light c. Below 1 the bar is timelike, an ordered move; at or above 1 it is spacelike, an anomalous jump. The interval is ds² = c²dt² − dx².

Mass, then a well

BlackHoleDetector adds mass on consecutive timelike bars and bleeds it on spacelike ones. A well forms when mass crosses bh_form after five ordered bars in a row, and points the way the price has been moving.

SRFM core signal stack backtest + MC paper trader idea engine

The rest of the lab

GARCH vol scaling, an OU sleeve, geodesic and Hawking monitors, backtests with Monte Carlo, an Alpaca paper trader, and an idea engine that mines backtest trades and proposes parameter changes. Most of it needs keys or services.

Four steps from a price bar to a black hole: beta equals absolute return over c; under 1 is timelike, over is spacelike; timelike bars add mass, spacelike bars cut it by 30 percent; a well forms when mass passes 1.5 after five timelike bars in a row.
SPY daily bars from December 2025 to January 2026: each bar's speed against the limit of 1, the timelike run count, and the black-hole mass crossing 1.5 on 2025-12-30 and 2026-01-16, when wells formed.
Real SPY bars run through lib/srfm_core.py by scripts/figures/make_physics_explainer.py.
SPY, QQQ and DIA daily closes over the last 750 days with black-hole wells shaded and BH mass under each panel
The quick start's own chart, restyled: every well the detector found on the three instruments over the last 750 days of bundled data.

Read this before anything else

Research code, not financial advice.

What the quick start shows

On the bundled 2020 to 2026 sample, the 5-day move after a well forms, signed by the well's direction, averages below zero on all three ETFs. With these parameters the bare signal does not predict the next week. The lab exists to test ideas like this one, including when they fail.

What the rest of the repo is

A research monorepo, not a product. Backtest and paper-trading results are experiments on historical or simulated data and swing widely by period and parameters. Nothing here should trade real money without your own independent validation.