Quant500 Academy

1. From backtest to market: what changes when the money is real

Level 13: Connecting to Real Brokers

In Level 12 you built a rigorous backtest: walk-forward, transaction costs, no look-ahead bias. That backtest is a simulation in which you control absolutely everything. You decide the price at which each trade executes, you decide that the order always fills, and you decide that the data arrives on time. In the real market you control none of that.

The fundamental difference is this: a backtest computes returns, a live system sends orders. They are two different engineering problems. The backtest is a data analysis problem; the live system is a distributed systems problem, with networks, latency, partial failures and state shared between your machine and the broker.

These are the new things that appear the moment you really connect:

From this comes the most important rule of the whole level: the source of truth for state is the broker, not your local variable. If your code holds a variable position = 100 and the broker says you have 40, the broker is right. A well-designed system periodically queries the real state of positions and open orders, and reconciles what it believes with what is actually there. That process is called reconciliation and it is not optional.

The minimum architecture of a live system has five separate pieces, and they should be genuinely separate, in distinct modules:

1. Data ingestion: receive prices, clean them, detect gaps.

2. Signal engine: exactly the same code you used in the backtest. If it is not the same code, you are testing one strategy and executing another.

3. Risk manager: decides whether the signal becomes an order and at what size, and holds veto power.

4. Execution: turns the decision into API calls, handles retries and confirmations.

5. State and reconciliation: what I hold, what I asked for, what has been filled.

Having the signal engine be literally the same module you ran in the backtest is what makes it possible to compare real performance with simulated performance afterwards. If the logic is duplicated in two places, sooner or later they diverge and you will never know again whether the difference comes from the market or from a bug.

To go deeper into this lesson

The rest of Quant500

What you are learning, applied to the index every day:

The model portfolio, weekly in your inbox

Every Saturday, its week in one minute: how it went, the best and the worst, and which insiders bought with their own money. Plus, the day the model is rebuilt, which stocks come in and which go out. A simulation, not advice. At most one email a week, no ads, no account; one-click unsubscribe. Made by one person: Pol Gracia.

A model portfolio with simulated results, not a personalized recommendation. Your email is used for this only: privacy.

Behind the Academy and the rest of Quant500 there is one person: Pol Gracia Serrahima.