Trading bot architecture: the layers you must not merge
Almost every bot that becomes unmaintainable made the same mistake — it let strategy logic reach directly for the exchange.
Blog
How a production trading system is put together: layers, order state, risk, sizing and monitoring.
Almost every bot that becomes unmaintainable made the same mistake — it let strategy logic reach directly for the exchange.
The exchange telling you it received your order and the exchange telling you the order traded are different events. Bots that conflate them report profit that never existed.
Risk management in a trading bot is not a calculation. It is a set of refusals, enforced in code, that the strategy cannot argue with.
The single most useful habit in automated trading is computing size from the distance to your stop. It is also the one most bots get almost right and then lose to fees.
P&L tells you what happened. It does not tell you whether the machine that produced it is working — and by the time P&L reveals a broken bot, it has been broken for a while.
Multi-venue support is not about supporting more venues. It is about having exactly one place in the codebase that knows how any particular venue is weird.
Recording everything is what makes a system honest. Recording it synchronously is what makes it miss the market. The fix is boring and worth getting right early.
We write about what we build. If you need it built, get in touch — scoping is free.