5. Paper trading, sandbox and the first real money
Level 13: Connecting to Real Brokers
Between the backtest and the real account there are intermediate steps, and skipping them is the most expensive way to learn. It is worth distinguishing three things that are often lumped together under the same label of "simulation".
The exchange sandbox. This is a test environment with the same URLs and the same message format, but with fake money and, very importantly, with a fake or nearly empty order book. It serves exactly one purpose: validating the technical integration. That your HMAC signature is correct, that the order body is well formed, that you know how to read the response, that you handle errors. What the sandbox does not tell you is anything at all about profitability or execution quality, because the prices and the liquidity are not real.
Paper trading with real data, also called shadow trading. Here you connect your system to live market data, generate the real signals, and instead of sending the order you record it in an internal book at the price you would have obtained. This is genuinely informative: it measures the strategy's behavior on data nobody has seen before, in real time, without the comfortable assumptions of the backtest. It is the only clean way to check that there is no look-ahead bias hidden in your pipeline, because when data arrives second by second it is physically impossible to look at the future.
Real money in minimum size. This is the only step that reveals what neither the sandbox nor paper trading can reveal: real slippage, real commissions, real rejections and your own reaction when the number on the screen is money that exists. You start with the smallest size the market allows, even if commissions eat the returns. In this phase you are not trying to make money; you are checking that the system does what it says it does.
What to measure at each step
The question that structures the whole process is: does what happens match what the simulation predicted? Specifically:
- Do the signals match? If you run the backtest over the same period the paper trading has just lived through, exactly the same signals should be generated at exactly the same moments. If they do not match, you have a data or logic bug, and you cannot move forward.
- Does the slippage match what you assumed? Compare the price at which you decided to trade with the real execution price, obtained from
GET /fills. If your backtest assumed 5 basis points of cost and live it is 30, the strategy you tested and the strategy you are executing are not the same one. - Is the distribution of results compatible? Do not expect live performance to be identical to the simulated one: they are different samples. What must happen is that it is *compatible* with the simulation, with no systematic and persistent degradation.
The emergency switch
Before the first real euro goes in, the system needs a stop mechanism that a human can trigger in seconds and that can also fire on its own: on maximum daily loss, on a number of consecutive rejected orders, on a prolonged data disconnection. That switch must cancel open orders and stop sending new ones. Deciding in advance which conditions activate it is a design decision, not an improvised reaction in the middle of a bad day.