7. Logging, monitoring and final checklist: closing the course
Level 13: Connecting to Real Brokers
What remains is the least glamorous part, and the one that saves a system most often: knowing, at every moment, what your program is doing and why.
Logging: the black box
When something goes wrong (and it will), the log will be the only evidence of what happened. For every decision, a serious system records: timestamp, input data, signal generated, risk manager's decision, order sent with its identifier, response received and, later, the real fill with its price and commission. With that you can reconstruct any trade months afterwards.
Two rules: the log must be structured (one line per event, in a format that can be queried automatically such as JSON, not loose prose), and keys, secrets and authentication headers are never logged. It is easy to leak a secret by dumping the full request object into a debug log that ends up in an external service.
Monitoring: the metrics that matter
A production system is watched with a handful of well-chosen metrics:
- Latency from signal to order and from order to confirmation.
- Average realized slippage, comparing the decision price with the execution price.
- Rejection and API error rates, by type.
- Open orders and real position versus theoretical position: any divergence is an alert.
- Age of the last data received: if the most recent data point is minutes old, the system is blind.
There is a diagnostic distinction worth being clear about: if slippage and rejections are within their normal range but results are deteriorating, the problem is the model; if results deteriorate at the same time as slippage spikes, the problem is execution. They are two different diseases with two different treatments.
Checklist before trading with real money
- The live signal engine is the same code as the backtest's.
- Credentials are in environment variables, without withdrawal permission, and the repository is clean of secrets.
- The system recovers its state from the broker on startup, not from its own memory.
- Every order submission has a timeout, retries classified by error type and a client identifier.
- There is a daily loss limit and an emergency switch that has been tested, not merely written.
- There are structured logs and at least one alert that reaches a human.
- It has run in paper trading long enough for its signals to match the backtest's.
- The capital committed is an amount you can afford to lose completely.
The road traveled
You started with Python and financial data. You learned to obtain and clean price series, to compute returns and risk measures, to build and validate signals, and to put together a backtest whose conclusions actually mean something, without fooling yourself with look-ahead bias or overfitting. In this final level you have closed the circle: that logic leaves your computer and becomes an order in a real market.
Out of the whole course, keep one idea above all the others: the quant's job is not to find the strategy that wins, it is to honestly discard all the ones that only looked like they would. The rigorous backtest, paper trading, minimum size and monitoring are the only tools you have for telling a real edge from a statistical mirage. Programming is learned in months; that discipline is practiced over an entire career.
This course teaches programming and quantitative method, it does not give investment advice. What you do with your money is your decision and your responsibility.