Skip to content
← Trading engine

A research simulator

Engine v1 · Jul – Oct 2026 · eight updates · Updated

Engine v1 was a research simulator. Every strategy ran as a paper portfolio inside it, through eight updates from July to October, newest first on this page. Update 1.8 added the shared backtest core, which Engine v2 still uses for research.

1.8 One shared backtest core

2 October 2026

Every strategy is now a short specification that runs through one shared backtest core and one evidence path before a paper portfolio can observe it. No policy has beaten its frozen control yet.

Figure 01 · One evidence path · 1.8

Every strategy goes through the same core

  • Strategy
  • Backtest
  • Evidence
  • Paper path

STRATEGIESSPECIFICATIONSHARED COREEVIDENCEPAPERpublic strategy open specprivate strategy separate repoFREEZEstrategy spec two modesRUNSHARED BACKTEST COREnative simulation events + portfoliospoint-in-time data future read raisesversioned costs primary + harsherdeflated Sharpe per trial countsealed holdout opens onceshared price panel 989 s → 0.85 srun manifest 3 input hashesREPORTreport evidencePAPERpaper book simulated
fig. 1 — Public and separately held private strategies become short specifications. One core owns the no-peeking view, named costs, event or portfolio simulation, gross benchmark, calendar-day deflated Sharpe and sealed holdout. Only its evidence report reaches a paper portfolio.

Before 1.8, a new strategy could bring its own replay machinery. Now it only describes its decisions, fills, exits, universe and liquidity rule.

I tested the evaluator on a synthetic market where the answer was known. It found the planted edge in 48 of 50 seeded runs and rejected noise in 7 of 200, or 3.5%. Serial and parallel reports were byte-identical. A shared in-memory price panel then cut the 16-worker, 3,000-stock benchmark from 989.05 seconds to 0.847 seconds without changing those bytes.

Each nightly stage now records its own timing. Price checks overlap network waits, earnings refreshes are bounded between weekly full passes, and the weekly walk-forward uses a rolling eight-slot pool. Together the measured collection changes remove about 18 minutes from a 44.5-minute nightly path.

The free-source store now has a public ticker master with listing intervals, SEC delisting notices and public insider-trade datasets. Its audit found that the old store held only roughly a third of the listed names in each year from 2010 through 2025.

Facts for 1.8
shared backtest
event and portfolio strategies · one deterministic core
evidence rules
no peeking · named costs · gross benchmark · calendar-day deflated Sharpe
holdout
sealed · one opening
synthetic proof
planted edge found in 48/50 seeds · noise flagged in 7/200 (3.5%)
tests
4,217 collected

1.7 Scoring every candidate

26–29 September 2026

Since 29 September a model scores every nightly candidate next to a fixed rule, and a paired test decides at set dates whether the model adds anything.

Until 1.7 the AI made one pick a night from five standouts, and it abstained on 92% of them. At that pace, twenty trades would arrive around February 2027, and twenty trades can only detect an edge of about five percent per trade.

So the unit of evidence changed from a trade to a scored candidate. Each night the model and a fixed rule both score every candidate in a wider universe, and each score is later labelled with what the stock did. A paired test compares the two on the same names and dates, and I only read it at 60, 90 and 120 scored trading days. Three simulator portfolios trade on the scores with identical mechanics: one ranked by the model, one by the rule, and one by the rule with a model veto.

The model still sizes nothing. Before the open the model can look again and cancel an order, never add or resize one, and every cancelled order keeps the fill it would have had, so the cancel decision is scored too.

Each strategy starts as a written test plan: the mechanism, the control it has to beat, one primary statistic, a kill criterion, and the total number of trials. Ten test plans so far. Seven are closed as rejected or inconclusive.

Facts for 1.7
paper portfolios
25 active in the simulator
test portfolios
model-ranked · rule-ranked control · rule + model veto
entries
volatility sizing · limit order at the open · pre-open check may only cancel
tests logged
103 written down in advance · counted as 139 trials
tests
4,078 collected
python
~118k lines outside tests · started 2026-07-16

1.6 TradingView for research

25 September 2026

Update 1.6 was a small change on top of 1.5: TradingView quotes and bars reached the intraday agents as research input. They never touched prices, fills or orders.

Saturdays a verifier re-checks the full universe against a second source and reports disagreements instead of quietly patching them. Sundays the walk-forward replays every portfolio through the live league.py daily step with the config frozen in its database row, so the report can never describe a rule no portfolio is trading.

Coding agents built the engine from a written spec. Even after the research answer became “nothing works yet, wait for evidence”, the agents kept building anyway: forty-six thousand lines of governance for a broker that does not exist.

Facts for 1.6
paper portfolios
21 rule-based (18 replayable) · 1 run by an AI agent
data sources
Yahoo · Nasdaq · FRED · Cboe · FINRA · CFTC · AAII · SqueezeMetrics
research-only source
TradingView quotes and bars, for the intraday agents
tests
3,280 collected · warnings are failures
python
~89k lines outside tests · started 2026-07-16

1.5 An agent in the loop

18–24 September 2026

I let a model back in with 1.5, but only after writing a rulebook for the engine, and only with one narrow job: look at the day’s standouts and, at most, place one paper trade through a tool it cannot widen.

After my 6 out of 10 review on 18 September, with the server code at about 46,000 lines, the engine got a written rulebook: maintenance only, a bar that new work must clear, code-size limits that the tests enforce, and short build-log entries. The repo went public the same day.

A swing is only a request. It has to go through one locked submit_paper_trade call, and deterministic code decides whether it passes and how big it is. The first run on 21 September produced five assessments, two watches and one swing, which was not traded.

Every decision is stored with its information cutoff, the exact model and prompt, and labels at one, five, ten and twenty days, next to a paired control. A replay of 2022 showed why that matters: the model picked XOM on all four dates and compounded +19.78%. That says more about what a model already knows about 2022 than about its judgement, so the replay is labelled contaminated and cannot move anything to real money.

Until the agent has 60 trading days, 90 calendar days and 20 trades behind it, I treat its results as a log, not as evidence.

Facts for 1.5
agent portfolio
one isolated US$10k simulator portfolio · first run 21 September
agent buy rules
market in risk-on mode · passes the trend screen · confidence ≥ 0.65 · no earnings within 5 days · ≤ 3 positions · 10 % size
observers
hourly and four-hour agents · no order authority
not connected yet
SEC EDGAR (probe refused) · Alpaca IEX (no credentials)

1.4 Evidence first

18 August – 17 September 2026

With no model in the loop, 1.4 spent a month testing whether any of the strategies were real. Almost none were, and most of the month went into showing that carefully enough to believe it.

The walk-forward went from six folds to ten, because a single window could flip a verdict. The sweep farm tried 51 candidates without a single model call.

The harder finding was the ceiling. Of 30 swept candidates, 26 were indistinguishable from their benchmark and none beat it, and the test only had even odds of spotting an edge near seven points a year. Because the history holds only today's survivors, more compute would not have fixed that; it is a limit of the data.

An audit on 2 September found seven simulator bugs. The worst was that no dividend had ever been credited, which a backfill fixed with 26 credits worth $230.42.

By September three forward monitors were running, each frozen before its first signal. None of them can change a portfolio; they can only report whether it should continue.

By mid-September the engine was honest and very large. My own review on 18 September gave it 6 out of 10, with research output and scope control both at 3. I decided 1.5 would start with limits on the engine itself before any agent came back.

Facts for 1.4
price sources
Yahoo only · Nasdaq API as verifier, not failover
portfolios
25 → 18 after the AI layer, 21 active by the end
fill model
v4 · profiles baseline, 2× cost, participation stress
tests
228 on 2 September → 2,261 by mid-September

1.3 AI adjusting the portfolios

4–17 August 2026

Update 1.3 was my first attempt at putting a language model in the trading loop, and the most useful thing it produced was a reason to take it out. The model sat beside five portfolios, could only veto entries or move parameters inside bounds written down in advance, and each of those portfolios ran next to a twin that never changed.

On 4 August the analyst wrote one brief from 133 headlines, and one veto agent produced one file: eight candidates, all marked unclear, no vetoes. From 5 August every scheduled run failed because the login they depended on had expired. The failures went into TODO: lines in a log nobody read, and the layer stayed dead for thirteen days before anyone noticed.

I agree with the log's own verdict: “The defect was not the failure, it was the silence.” The model acted in one run out of about fifteen, so any spread against the twins was noise, and calling it an AI result would have been dishonest. The more lasting lesson was about where a model belongs. Frequent, low-stakes calls that a rule could make are the worst use of one, and anything a grid can decide should be decided by a grid.

Update 1.4 replaced the model with a parameter grid and a stricter walk-forward. The twin idea stayed.

Facts for 1.3
model call
one turn, no tools, JSON out · about 18 a week
veto agent limits
veto or scale 0.25–1.00 · never add · at most half the candidates
tuning agent limits
≤ 2 parameters a run · ≤ 25 % a move · within ±50 % of the original
output
1 veto file · 1 news brief · 0 scheduled tuning changes
retired
18 August · 25 → 18 portfolios

1.2 More portfolios and a backtest farm

28 July – 3 August 2026

Update 1.2 added six portfolios, but the change that mattered was finding out the price history was wrong. Yahoo rewrites old prices after a split, the engine only re-fetched the last five days, and dividends were never stored.

A five-day refetch leaves a permanent break in the series after a split, so portfolios holding that stock showed crashes that never happened. Prices are a cache of Yahoo's adjusted view, restated at the break found in the stored series. Portfolio state is a pure function of fills and dividends, with dividends replayed first. Fetching new actions only warns, but the reconcile stage is fatal. The log puts the reason better than I can: “trading on a broken scale is strictly worse than skipping a night.”

The first grid of 78 jobs drained the same day without a failure, and its answer was blunt: no stock-picking portfolio beat its own equal-weight benchmark over any window of three years or more. The sample leans toward survivors, with 1,237 eligible names in 2011 against 3,873 today, and that caveat never went away.

That result set the bar for everything since. A stock-picking portfolio has to beat an equal-weight basket of the same names, over years, before I treat it as more than noise.

Facts for 1.2
new data
Yahoo splits and dividends · 409,684 action rows
portfolios
16 with fixed rules + 1 manual
new portfolios
turtle breakout · stopped momentum · sector momentum · low vol · 52-week high · post-earnings drift
first reconcile
36 splits adjudicated · 1,839 dividends stored
exit
seven clean nightly runs, 24 July – 3 August

1.1 Data and the first paper portfolios

16–27 July 2026

Most of what went wrong in the first version had nothing to do with trading. It was one cron job on one Linux box: pull the market, screen it, and let ten paper portfolios trade whatever passed, filling at the next morning’s open.

The plan had Stooq as the price source and Yahoo as the fallback. On 16 July Stooq returned a JavaScript anti-bot page and Nasdaq's FTP server timed out, so Yahoo, through yfinance, supplied every daily bar.

An order signalled at a close fills at the next trading day's open. A local UI could add a discretionary portfolio, fed by risk-checked manual orders that filled the same way. That discretionary portfolio broke the engine. From 20 to 23 July every nightly run failed at the portfolio step with KeyError: 'discretionary', because the UI had created the portfolio at runtime and the strategy registry had never heard of it. Each day-step runs in one transaction, so every night rolled back cleanly and the paper portfolios sat frozen at 17 July with 42 orders pending.

The rule I took from it is in the log: a copy used to prove a go-live has to include every row the system creates at runtime, not only what the installer creates. What 1.1 still had no answer for was splits and dividends, and 1.2 found out how much that mattered.

Facts for 1.1
universe
Nasdaq Trader symbol list · 12,209 kept · 4,118 liquid
history
19.8M rows, back to 1962
portfolios
10 with fixed rules + 1 manual · $39,000 each
fill model
next open · 5–25 bp spread tier + 5 bp · ≤ 1 % of volume
schedule
cron 22:30 UTC, weekdays

Ong Jun Xiong

SOFTWARE ENGINEER · SINGAPORE

ContactHobbiesArchiveNotes (opens in a new tab)UiPackGitHub (opens in a new tab)LinkedIn (opens in a new tab)Source (opens in a new tab)

© 2026 Ong Jun Xiong