A local-first backtest engine built to reject my own trading rules

A personal research system. It reads my trade fills and public market data on my laptop, scores each trade against written rules, and backtests rule ideas before I am allowed to believe them. Its most useful output so far is the list of ideas it killed, starting with the first one that looked great.

Solo project, October to December 2026. Stack: Python (153 files, about 22,000 lines), pandas, launchd, Chrome DevTools Protocol. The main repository is private; two screeners that came out of it are open source.

Research notes, not investment advice. The returns below are backtest results on historical data with known biases, listed further down. Most of them are reasons a rule was thrown away.
60,936signal events in the factor table, 485 tickers, 2017 to 2026
80entry and exit combinations tested against a random-day baseline
20random seeds in the control that retired version 1
+4.6% → +0.2%the one idea taken out of sample, before and after

Why local-first

The inputs are my own fills and statements. I did not want them on anyone's server, and I did not want broker credentials in code.

What does leave the machine: requests to public market-data endpoints, one text-parsing step that calls a hosted LLM API, and code pushed to a private repository. One small replay tool was deployed to a static host behind a signed-link gate.

Pipeline

Sources fills, prices, options Data layer primary, fallback, cache Event table 60,936 signal events Score 8 features kept, 4 cut Portfolio simulator next-day fills, costs Daily screen report and dashboard Refutation harness same rules and costs, one thing changed A written verdict in the report: kept, or retired
The same score is used in three places: the portfolio backtest, the daily screen, and grading my own past trades. That is deliberate. A rule I cannot backtest does not get to judge me either.

Each input in the data layer has a primary source, a fallback and a local cache. Every refresh records how fresh each input is, and a stale input is flagged in the report instead of being used silently. After one data provider started refusing requests, I added per-domain route memory so a refresh tries the environment proxy, a direct connection and the system proxy in the order that last worked.

Keeping the future out

The falsification log

Each row is a claim I wanted to be true, the control I ran against it, and what happened. Returns are annualised unless stated. The benchmark is an index ETF held over the same period, which returned 19.4% a year.

ClaimControlResultVerdict
Version 1: buy the strongest three-month performers in one sectorBacktest with a 14-row ablation grid26.2%, against 19.4%Looked like a win
…and the ranking is what earns itSame rules, ranking replaced by random numbers, 20 seedsRandom mean 12.3%Ranking matters
…and the rules generaliseSame rules on the whole index and on 5 sector groups10.3%, against 11.5% equal-weightRejected
…and the entry and exit rules add valueRandom picks under the rules, against simply holding the sector equal-weight12.3%, against 24.1%Rules subtract. v1 retired
Which entries and exits work at all10 entries × 8 exits, with a random-day baseline, in two halves (2017–21, 2022–26)Random +1.57% per trade; best entry +2.61%; breakout +0.08%Kept cells positive in both halves
A fixed 12% stop protects the downsideSame gridAbout a point less on average, and a worse worst-decileStop removed
Market-environment factors carry an edge60,936 events bucketed by factor, both halves8 features held in both halves; 4 did not8 in, 4 out
Version 3: the resulting score can run a portfolio alonePortfolio backtest, 8 variantsBest 10.7%, with a 38% drawdownRejected as a standalone
Nine published classic strategies work on this dataSame data, same costsNone beat the plain trend-filtered index on riskNone adopted
Buying sharp post-earnings dropsFitted on four months (161 events), then run on two unseen years (1,243 events)+4.6% → +0.2% over 5 days; win rate 69% → 49%Failed out of sample
An order-flow reversal rule from a trading community76 days of tick data; blind controls, a mirror test, a 2,000-draw bootstrap by dayOriginal rule lost. The mirrored rule also lost, so the effect is not symmetric.Original rejected

The retirement note for version 1 says its good result most likely came from picking the right sector with hindsight, plus survivorship in today's index members, plus parameters chosen on the same data. Version 3 survives only as a small sleeve beside a plain index core, and even that rests on thresholds chosen in-sample.

A simplified version of the order-flow rule is kept as a paper-trading candidate, with a note attached that its numbers are in-sample.

Decisions inside the engine

Biases and gaps that remain

What became public

Two screeners that carry no positions and no recommendations are open source.