The backtesting engine

What the engine actually simulates.

A backtest is only as honest as the market it pretends to trade in. This page sets out what a decision is allowed to see, how an order gets filled, what the run is charged for it, how far back it can go, and what it may read along the way.

01Visibility

What a decision can see.

At every decision instant the strategy is handed a snapshot. It holds history through the last bar that closed, which is the bar before the decision, together with the values that were public on that date. The price the order is about to fill at is not in it.

Revisions do not travel backwards. A figure restated later is never substituted for the one that stood at the time, and no read path falls back to the newer version when the older one is missing. If a figure had not been published yet on that date, the strategy gets nothing and a condition that depends on it reads false, which is what point-in-time means. A series we do not hold at all is a different case, and it is not answered that way: the run is refused and told which window is missing, rather than handed a curve with the condition quietly switched off.

Every instrument carries its own history and every window ends on the same bar, so a listing from last year does not shorten the window of one that has printed since the nineties. The consequence is the plain one: the same specification over the same window returns the same numbers today and in six months.

02Execution

How an order is filled.

Orders fill in the session the decision was made in. That is the session the strategy could not see, which is the whole arrangement.

Size is not free. A single order may take at most a declared share of what that session actually traded, and the capacity behind that limit is read from the instrument's own traded value, taken as a rolling median of its recent sessions, out of bars that had already closed. It is not one constant chosen once and applied to everything, which is what lets a small book look infinitely scalable. When an order is larger than the limit allows, the run refuses it rather than shrinking it to fit and reporting the fill anyway.

The push an order puts into the book is charged as a cost of its own. It is priced off the instrument's volatility and the share of the session the order takes, following the empirical law measured on roughly eight million institutional metaorders (Bucci, Benzaquen, Lillo and Bouchaud, Physical Review Letters 122, 108302). The largest participation a run may be given is the top of the range where that law has actually been measured; past that point, charging it would be extrapolation wearing a citation.

03Costs

What a run is charged.

Costs are taken from the session that traded, not averaged over the window and sprinkled back.

  • FeesCharged on the round trip, at the rate the run declares.
  • SlippageCharged on what the order crosses, on every fill.
  • ImpactPriced off volatility and participation, per order, on the published law.
  • FundingCharged on a perpetual position at the settlements that were actually observed. Spot never pays it.
  • BorrowCharged on a margin book with a real cash debt. A perpetual book pays for the same leverage through funding, and charging both would count one cost twice.
  • CashUninvested cash earns the declared rate while it waits, so sitting out is priced too.

Funding deserves a sentence of its own. The engine walks the settlements it observed and charges each one against the position that was open at that moment. It never lays a regular grid over the window and invents the settlements missing from it, because settlements genuinely get skipped, and a synthesised grid would bill a strategy for carry it never paid or spare it carry it did.

Where a cost has to be assumed rather than measured, the assumption is deliberately set wider than anything we have measured, so the error runs against the strategy instead of for it.

04Period

How far back a run may go.

A run gets the history that exists behind every condition it uses, and not one session more.

US company fundamentals are the clearest case. Electronic filing was phased in from 2009, so a condition that reads a balance sheet has nothing before roughly then. A strategy that starts in 2005 and reads one does not get a curve with that condition quietly switched off for the first six years. It gets a refusal that names the window, which is the only answer worth having.

The same holds at the other end. A window shorter than the signal's own lookback is refused rather than padded, and a rebalance cadence finer than the data's own grid is refused rather than rounded up to it and reported as though it had run.

05Materials

What the engine reads.

Two markets, and the series that describe them. Crypto and US equities, including ETFs, run through one engine on the same terms, so a strategy that spans both is one test rather than two that have to be argued together.

  • Crypto
  • US Equity
  • ETF
  • Macro
  • FX
  • Funding
  • Form 4
  • Congress trades
  • US fundamentals
  • Seasonality

A result is scored against a benchmark you pick rather than against nothing: the S&P 500 total return, the Nasdaq 100 total return, or buy and hold Bitcoin. The choice travels with the run, so a curve can never be re-read against a benchmark it was not measured on.

06The boundary

What the engine does not do.

  • It places no orders. There is no venue behind it and no account to connect to one.
  • It holds no money and takes no custody of anything.
  • It publishes no signal, no pick and no model portfolio.
  • It forecasts nothing. Every number it produces is about a window that has already happened.
  • It does not choose the strategy. That part is yours, and it stays yours.

What it does instead is state its terms. The execution settings a run was made under are stored with the result, so months later the same curve can be read on its own assumptions rather than on today's.

Bring the idea. We will test it.

Research and backtesting infrastructure. No strategy recommendations, no trade signals, no order execution.

Vaquero is a research and education service, not investment advice. We recommend no buying or selling, publish no trading signals, and guarantee no return.