Every day my trading system trains new models that try to replace the one in use. I call them challengers, and the first three went into paper trading, which places simulated orders, on the same day. The record of each one already held a number that told me its fate. The first needed 462 paired decisions, the same decisions scored by both models, before its test could say anything, which is about two days of trading. The second needed 3,774, about a week. The third needed 1,035,365, which at its rate was about 4,970 days, against a deadline of 30. I knew that on day one, not after a month of waiting, because the system writes the sample size before the test begins. That third challenger could never win, and the system ended it as “no verdict” instead of letting me hope.
This is the second loop from the first article of the series: the one that improves what works. The first loop fixes what breaks and the article before this one, The telemetry that lets an agent fix bugs, covers what feeds it. This loop has one hard problem: a system that tries many ideas on its own will eventually find one that looks good by accident, and then it ships the accident. Most of what follows is how I stop that.
What gets better
Each day the system trains a fresh batch of models on everything it recorded. Some are the same design as the model in use, trained on newer days. Others are new designs, with different inputs, a different label (the answer key a model learns from) for what counts as a good outcome, or different model settings. I call each new model a challenger, and the model in use the champion.
The system has four modes. Two trade nothing real: shadow, which decides and records but places no order, and paper, which places simulated orders against the live market. Two trade for real: live assisted, where each trade waits for my approval, and fully autonomous, which trades on its own inside the guardrails the system enforces.
The champion trades in paper mode. A challenger starts in paper too, beside the champion, so both decide on the same days. In my database the loop has registered 30 challengers in 30 days, and every one is a decision model. The spec also names post-mortems, narrative detection, ranking and screening thresholds as parts that should improve this way, and I have not wired those up yet.
The gate
A challenger replaces the champion only through one test, and the test is written down before it runs. This is the shape of the record, trimmed, with the values that every test shares:
A pre-registered test (trimmed)YAML
1hypothesis:the challenger earns more per decision than the champion2metric:net return per decision3test:superiority# not "no worse than"4margin:0# the lower bound must clear it5alpha:0.05# divided by the tries, see below6sample_size:N# fixed on day one, from the champion's observed spread7paired_on:the same decisions, taken after registration8min_hours:100# distinct hours the decisions must span9deadline_days:3010trial_budget:20
Four rules sit behind those fields.
The data is new. A challenger is judged only on decisions made after it was registered, and each one must be scored by a model that never trained on it. It also never trained on anything from the same token creator, because one creator launching many tokens would make the rows look more independent than they are. The champion’s score comes from the same decision, so the comparison is a pair. This record builds up day by day and training never reads it.
The test looks once. It does not compute anything until the pairs reach N and span 100 different hours, and it never peeks. A sequence of early looks at a noisy number is another way to fool yourself, so the page shows the current state and refuses to declare a result before the horizon. Entries come in waves, by hour and by creator, and their returns move together. So the test takes the largest of three error estimates (plain, by hour and by creator). On simulated random data it never passes where the plain formula fails.
The bar is high. The lower end of the challenger’s confidence range must clear the margin, and the t-statistic must reach 3.0.
The clock ends it. If the pairs do not arrive in 30 days, the challenger ends and the champion stays. An honest “I can’t tell” is a result.
Of the 30 challengers, 2 passed and took over the paper champion’s seat. 21 failed, 5 ended with no verdict because the decisions never arrived and 2 were replaced by a newer design before they finished. The two that passed each needed about 100,000 paired decisions. A test that nothing fails is not a test.
A limit on tries
Test 20 ideas that are no better than the champion, and about one of them will clear a 5% bar by luck. So the family of models has a budget of 20 tries in 30 days, and the error level of every test is divided by that 20 (a Bonferroni correction, the plainest answer to the multiple comparisons problem). A new design, registered as a recipe, spends one try. The daily rows that its record collects afterwards are not new tries, and the tries used are visible on the Training page. When the budget is gone, a new idea is recorded as “not tested”, with the reason.
I want this rule at the gate, because that is where it protects the result. It also has a cost, which I only measured later.
The wall in front of the proof
The budget protects the result, but it also throttles the search. A daily run spent about 9 hours building data and about 5 minutes training, so every idea waited for the whole build and cost one try of 20. Most ideas are cheap to state and costly to test.
So I split the two jobs. The older days of the training data go into one Parquet file that DuckDB reads in seconds, and the file stops at a date, the cut. This file is the wall. An agent can try any idea on it as often as it likes, with no budget, and a research run touches no model that trades. Each read is written down, with the range of days it saw, before the first row comes back.
An idea leaves the file in one way only: as one registered recipe, which spends its single try in the next daily run. Its proof starts after the last day that any research read, plus a safety gap, so the days that prove a design are days that no search touched. The probability of backtest overfitting, from Bailey, Borwein, López de Prado and Zhu, sits beside the research runs. It informs me and gates nothing.
The wall has run 6 research runs so far and no recipe has left it. A mechanism built to speed up a search is only worth something once the search uses it.
Labels for what the system skipped
Many decisions of a trading system are “no”. The Rust core samples its skipped decisions, about 19,000 a day in the last week, and stores each with its reason and the return the model expected. That is why the loop can learn from the trades it did not take, not only from the ones it did.
Each decision gets an outcome label once its outcome is known, skips included, under one fixed reference rule for when to sell. When the pretend trade could not sell at all, the label reads “unsellable” and counts as a total loss: a known result, unlike an unknown label, which no model learns from. The report can then say, for each rule that vetoed a token, how much it missed and how much it avoided.
A label is part of the measurement, so changing one changes every verdict. A label bug once fooled a model (the next article tells how). After I fixed it, the model’s skill at ranking winners barely moved, but the money result of the same model moved a lot. So each label version is its own world: the system never compares results across label versions, and a label fix needs a new training run before anyone trusts an old verdict.
Drift, and why it is noisy
A model that was good on its training days can decide on numbers that no longer look like them. The system compares each input of the running model with its training picture every hour and gives each input a drift score. For a model that trades live, a score over the limit demotes the model to paper and restores the previous version. For a model in paper or shadow, I want one warning, once, and no demotion, because an old paper model is not harmful and a flood of alerts is.
That rule closes a gap. The drift check used to be switched off on purpose for models in paper or shadow, so one could drift without a word. The warning that now fills it is also how the system spoke up in the empty-input case of the first article, on exactly the two empty features. It raises one warning for each model and input, and arms itself again only after the score comes well back, to 60% of the limit.
It is still too loud: 502 warnings in 30 days, about 17 a day, 440 of them already cleared. Some inputs follow the market of the day, so they differ from their training picture even inside their own training days. The fix, stored since 26 November, measures that noise once for each model and uses it as the input’s own limit. The daily count has not fallen yet. I would rather say so than tune the limit until the number looks better.
Where I approve and where I don’t
The loop is allowed to do much, and the line is written into the spec. For paper and shadow, the daily training may approve a passing model by my delegation. That is how the two takeovers happened. Nothing reaches a live mode on its own either: a model gets there only by my explicit decision, based on the evaluation report. In live assisted mode I then approve each trade. In fully autonomous mode I don’t, because the guardrails carry that job: the risk limits and screening checks that the loop itself can never change. So my approval sits where I am in the loop, and the guardrails lower the risk where I am not.
Between paper and live sits a second gate that judges each paper strategy from the closed trades it made, never from labels. It passes a strategy only when everything holds at one look. It needs enough trades over enough days and a lower bound that clears zero after correcting for the many strategies and looks. The result must not rest on its five best trades, its later half must not be losing, and it must beat the benchmark. It must also survive charging every trade one percent more. The page says “Ready for the live test: yes” or “no, because …”, and a yes ends with a sentence: this is a measurement, and it switches no mode on.
Where the loop is bounded on purpose
The loop can’t change the things that make its own results mean something. It can’t change risk limits, the hard checks that screen a token, security policy or the mode. It can’t change the metrics, the label definitions, the gate’s settings, the sealed recent period that no search reads, or the count of tries. It can’t promote itself to live. A post-mortem that decides a risk limit is too tight sends me a recommendation, and nothing else.
A loop that may edit its own judge will pass its own tests, so the judge sits outside the loop. The limits also cost speed, and one nearly stopped the loop. The rule said a run may retrain a champion only when the design is the same, so a changed label counted as a new design that had to win a 30-day test first. On 8 November the two paper champions were 32 and 36 days old and nothing could replace them, because no new design had finished its test. The age check skipped paper models by design, so nobody was told. The fix keeps the full test for a genuinely new design and lets the system refit a design that already won, on every recent row, behind a guard that can stop it and spends no try. An old paper model now raises one warning that names its age and why it was not replaced.
I haven’t wanted it freer. The system is still being built, and many of the parts that will one day improve themselves don’t exist yet, so for now these limits are the right size.
What I’d tell someone building the same
Write the test before the test: the metric, the margin and the sample size. A power calculation will tell you on day one which idea can never win.
Judge a challenger on days that training never read, and pair it with the model in use on the same decisions.
Cap the tries, and correct the error level for them. Test enough useless ideas and one will look good by chance.
Let agents explore fast on old data, behind a wall, and let an idea leave it only as one registered recipe.
Label the decisions your system skipped, and never compare results across label versions.
Watch drift, and measure a feature’s own noise before you trust its alert.
Keep the judge outside the loop, and keep a person, or a guardrail the loop can’t edit, at the step that moves real stakes.
When a rule starves the loop, say so and fix the rule, not the test.