← All posts

How AI trading bots actually work

Strip away the marketing and an AI trading bot is a pipeline: data in, signal, sizing, execution, risk checks, repeat. A plain-language tour of each stage, and why the model is the least important part.

How AI trading bots actually work

TL;DR: An AI trading bot is a five-stage loop: market data in, a signal, position sizing, order execution, risk checks, repeat. The machine learning lives only in the signal stage and is rarely what decides profitability. Survival comes down to clean data, conservative sizing, respected transaction costs, and a risk layer that assumes the model is sometimes confidently wrong.

"AI trading bot" conjures an image of a neural network staring at charts and outsmarting Wall Street. The reality is less cinematic and more interesting: a pipeline of mostly unglamorous components, where the machine learning is one stage among five and rarely the one that decides whether the thing makes or loses money. Here's how these systems are actually put together.

The loop

Every trading bot, from a hobby script to a fund's infrastructure, runs some version of the same loop. Ingest market data. Compute a signal that says something about what prices might do. Convert that signal into a target position, sized against risk. Execute orders to move from the current position to the target. Then watch, log, and do it again on the next tick, candle, or scheduled interval.

Each stage can be simple or sophisticated, but the stages themselves don't change. What people call "the AI" lives almost entirely in stage two.

Data: the unglamorous foundation

Bots consume price data (candles or raw trades), order book depth, funding and interest rates, and sometimes external inputs like sentiment indices or news feeds. Live data arrives over websocket streams that drop, lag, and occasionally lie; historical data for training comes with its own gaps and revisions.

The quiet rule here is that data quality bounds everything downstream. A model trained on data containing information that wasn't actually available at the time (the classic look-ahead mistake) will look brilliant in testing and lose money live. A surprising amount of the engineering in any serious bot is just making the data trustworthy and making "what the bot knew at time T" precisely reconstructable.

Signals: what the AI part really does

The model's job is narrow: given recent market state, output a number. An expected direction, a probability, a score. Under the hood this ranges from classic indicators (moving averages, momentum measures) through gradient-boosted trees on engineered features, up to sequence models digesting raw order flow.

Two honest observations about this stage. First, the edge in any predictive signal on liquid markets is tiny. Models that are right 52% of the time are respectable; anything claiming much more is usually measuring its own overfitting. Second, not all strategies are predictive at all. Some of the most durable ones are structural: harvesting funding rates, capturing spreads, providing liquidity. These need no forecast, just careful accounting of what they earn versus what they risk. Plenty of "AI bots" quietly make their money on the structural side while the model provides decoration.

Sizing and risk: where survival is decided

A signal says "probably up." Sizing decides what that's worth: how much capital, on which instrument, with what cap. This is where volatility targeting, exposure limits, and drawdown rules live, and it's the stage that separates systems that survive from systems that blow up. A mediocre signal with good sizing loses slowly and recoverably. A good signal with bad sizing can be ruined by one fat-tailed day.

Risk management wraps the whole loop rather than sitting inside it: kill switches when losses breach a threshold, sanity checks that refuse orders that are too large or too frequent, limits on how much of the book any one idea can occupy. Boring by design. Its job is to make the worst day survivable.

Execution and the cost problem

Deciding to buy is free. Buying is not. Every trade pays a spread, fees, and slippage, and this is where most amateur bots actually die, not in the model. A strategy that trades often has to clear its costs on every round trip before earning anything, and transaction costs act like a speed limit: turn over your portfolio faster than your edge can pay for and the bot becomes a machine for donating money to the exchange, with perfectly good-looking signals the whole way down.

This is why execution style matters as much as signal quality. Crossing the spread with market orders is fast and expensive. Resting passive orders earns the spread instead of paying it, at the cost of sometimes not getting filled. Which side of that tradeoff a bot lives on can matter more than which model it runs.

Backtests, and why live is different

Before running live, everything gets simulated on history. A backtest is a hypothesis test, and it's frighteningly easy to cheat by accident: tune parameters until history looks good and you've fit the noise, not the signal. The standard defenses are out-of-sample validation, walk-forward testing, and modeling costs pessimistically. A useful prior: if a backtest looks amazing, the first explanation to rule out is that it's wrong.

Even honest backtests flatter. Live trading adds partial fills, latency, exchange outages, and the bot's own market impact, none of which history records. The usual path is backtest, then paper trading, then live with small size, with performance expected to degrade at each step. A system that's still positive after that gauntlet is doing well.

What "AI" changes, and what it doesn't

Machine learning genuinely helps in spots: combining many weak features into one signal, adapting to regime changes, filtering when a strategy should sit out. What it doesn't do is exempt anyone from the pipeline. The bots that run for years aren't the ones with the cleverest models. They're the ones where the data is clean, the sizing is conservative, the costs are respected, and the risk layer assumes the model is sometimes confidently wrong. The intelligence that matters most is in the plumbing around the AI, not the AI itself.

Key takeaways