The bot I tested was not the bot I ran
Over the four weeks from the fifth of August, the Kerdoos paper account lost $7,633 on its VWAP pullback strategy. A replay of the same four weeks — same strategy code, same parameters, same recorded watchlist — made $5,097 on it. Twelve and a half thousand dollars of disagreement between a system and the simulation of itself, and when I went looking for where it came from I found one bug in the bot and two kindnesses in the simulator, which between them meant that every parameter the optimiser had ever chosen was chosen for a bot that did not exist.
The bot was reading the wrong bars
The scanner fetched a symbol's recent history with one parameter: limit=120. No start time, no sort order. That reads as "the last 120 bars", and it is not. The broker's bars endpoint pages from the start of the day forward and returns the first page, so limit=120 means the first 120 bars of today. For a stock that is harmless until early afternoon — the session is 78 five-minute bars long. For crypto, which trades 288 five-minute bars a day, it means that from about ten in the morning UTC the scanner's newest bar was from 09:55, and every scan after that evaluated the morning's chart and then placed an order at the afternoon's price. Probed live at 19:13 UTC on the third of September: BTC/USD, 120 bars, newest 09:55. Nine hours stale. It had been doing this since the thirteenth of July.
The same response had a second problem, visible in the NVDA probe from the same afternoon: 71 bars, newest 19:10 — which was now. The broker includes the bar currently being built. A scan takes four to five minutes to walk the watchlist, so a symbol late in the list was judged on a bar that had been open for three minutes and would close in two, as though those three minutes were a close. Every strategy in the system is defined on closed bars. The backtester, correctly, only ever fed them closed bars. The scanner was feeding them something else.
The measurable consequence: replaying the fifth of August to the third of September on the recorded watchlist reproduces 213 of the 587 trades the bot actually took — 126 of 350 for the VWAP strategy, 31 of 127 for momentum, 56 of 110 for mean reversion. The simulator and the bot were making different decisions on what was supposed to be the same data, and no amount of tuning the simulator could have told me anything about the bot.
The fix is small and the shape of it is worth writing down, because it is the shape of every "fetch recent bars" call that has ever been written in a hurry:
$bars = fetch(symbol, start: now - 120 bars, sort: 'desc', limit: 120)
-> sortAscending()
-> reject(fn (bar) => bar.open + timeframe > now) // still forming
if (newest($bars).close is older than 3 × timeframe) {
skip(symbol, reason: 'bars are stale');
}
Newest first from an explicit start, so the page you get is the page you meant. Drop any bar whose open plus its width is in the future, because it is not a bar yet. And refuse to evaluate a symbol whose newest closed bar is more than three bar-widths old, because a stale chart is not a chart with less information; it is a chart about a different time. Four tests pin it, and three older test fixtures had to shift one bar back, because they had been asserting on the forming bar too.
The simulator was being kind
With the scanner fixed, the replay and the bot could at least be asked the same question. The replay was still too optimistic, in two ways I had let it be.
First, it charged no friction. An entry in the simulator filled at the bar's close; an exit on a stop filled at the stop price. On the live book, entries filled about 0.04 % above the reference close — behind the 0.3 % limit cap, but above it — and stop exits filled 0.03 to 0.08 % below the stop for stocks and 0.06 to 0.10 % below for crypto, because a stop becomes a market order and the market is moving away from you when it triggers. On a stop 0.6 % wide, that is a tenth of every trade's risk, paid on every trade, and paid most heavily by exactly the tight-stop configurations the optimiser would otherwise rank first. A frictionless simulator does not merely overstate returns. It prefers the wrong parameters, systematically, because the cost it omits is the cost that punishes them.
Second, it filled every target on a touch. If a bar's high reached the take-profit price, the simulator booked the win. A real limit order at that price fills only if the market trades through it — someone has to be willing to buy above your ask — and a bar whose high is exactly your target is a bar where it almost certainly did not. The live book never got those fills. The simulator got all of them.
The fix is a slippage model per asset class, calibrated from the live fills — 0.05 % on equities, 0.10 % on crypto, every market-order leg slipped against you — and a take-profit that fills only when the bar's high exceeds the target. Five tests. The result on the same four-week replay:
| 5 Aug → 3 Sep, recorded watchlist | The account | Old simulator | Friction-aware simulator |
|---|---|---|---|
| Return on the window | −14 % | −3.1 % | −17.4 % |
vwap_pullback P/L | −$7,633 | +$5,097 | negative |
Minus 17.4 against a real minus 14 is not a perfect model, and I do not want it to be — a simulator that is slightly too pessimistic is one whose recommendations survive contact with the market. Minus 3.1 against minus 14 was a model that had been telling me, for two months, that the problem was almost solved.
What the honest replay said
Then I asked it the only question that matters: with fees and slippage charged, does any configuration of any strategy hold up out of sample? Walk-forward on stocks, the 113 names the watchlist actually held, trained on the fifth to the twenty-fifth of August and tested on the twenty-sixth to the third of September. The VWAP strategy's best in-sample configuration was negative in-sample — all twelve combinations were. Mean reversion's best was positive in-sample and lost out of sample. Momentum's best was negative in-sample and broke even out of sample, which the sweep flagged as "held up" and which I do not count, because a negative in-sample result is not evidence of an edge whatever the next week does.
Read plainly: no. Two things are still worth knowing from it. Every sweep put the widest stop on the grid at the top, which agrees with the live stop buckets — two independent measurements pointing the same way. And the momentum configuration is the one to compare against a clean week of closed-bar data when there is one. On the fifteenth of September I paused entries on that finding. The scanner still syncs fills, ratchets stops and exits positions; it hunts nothing. It is a decision, not a fault, and it stays until something clears the bar.
The general shape
A backtester is a claim: that the simulator and the bot make the same decisions on the same data. Everything it tells you rests on that claim, and I had never tested it. The test is cheap and I would run it before anything else now: replay a live week and count the trades you reproduce. If it is not nearly all of them, the simulator is measuring a different system and its recommendations are about that system. Only once the two agree is a backtest a statement about your bot — and only once it charges what the market charges is it a statement about your bot in the market.
Paper account, not advice. The numbers above are what one system did on one window; what they establish is that the measurement is honest now, not that anything works.