Algorithmic Trading 101: How Bots Actually Work
A clear introduction to algorithmic trading: how trading bots actually work, the main strategy types, and what separates a well-built system from a reckless one.
What a Trading Bot Actually Is
A trading bot is a program that watches market data and executes trades automatically according to a fixed set of rules, without a human clicking the buy or sell button in the moment. That's the entire definition. The complexity people imagine (constant machine learning, adapting in real time, some form of market prediction) describes a small subset of bots. Most run on rules that are simple to state and mechanical to execute: "if the 20-period moving average crosses above the 50-period moving average, buy."
The Core Loop Every Bot Runs
Strip away the specifics and nearly every trading bot runs the same basic loop:
- Receive data: price, volume, order book depth, or another feed, updated continuously or at set intervals
- Evaluate conditions: check the incoming data against the strategy's rules
- Generate a signal: buy, sell, hold, or adjust an existing position
- Manage risk: size the position, set a stop-loss, check it against portfolio-level risk limits
- Execute: send the order to an exchange or broker via an API
- Log and repeat: record the outcome and return to step 1
The sophistication in a trading system usually lives in steps 2 and 4, the rule logic and the risk management, not in some mysterious central intelligence.
Main Categories of Algorithmic Strategies
Trend-Following
Rules based on moving average crossovers, breakouts, or momentum indicators that aim to catch and ride a sustained directional move. Simple to build, historically effective in trending markets, prone to a string of small losses in choppy, range-bound conditions.
Mean Reversion
Rules that bet a price which has moved unusually far from its average will revert back toward it, often using indicators like RSI, Bollinger Bands, or z-scores of price deviation. Works well in range-bound markets, dangerous in strongly trending ones where "unusually far" keeps getting further.
Market Making
Bots that continuously post both a buy and a sell order slightly inside the current bid-ask spread, profiting from the spread itself across a high volume of small trades. Requires low latency and careful inventory risk management, since holding a large one-sided position when the market moves against it erases the accumulated spread profit quickly.
Arbitrage
Bots that exploit small, temporary price differences for the same or economically equivalent asset across two venues (two exchanges, or a stock versus its futures contract). Requires speed and reliable execution, since the mispricing typically closes within seconds once enough participants act on it.
Statistical Arbitrage / Pairs Trading
Bots that trade the relationship between two correlated instruments, going long one and short the other when their historical relationship diverges, betting on convergence. More complex to build and monitor, since the underlying correlation itself can break down.
What Separates a Well-Built Bot From a Reckless One
| Well-built | Reckless |
|---|---|
| Backtested out-of-sample across multiple regimes | Backtested only on the period it was designed against |
| Hard position size and daily loss limits enforced in code | Sizing left to whatever the signal implies, with no ceiling |
| Kill switch for abnormal conditions (data feed failure, extreme slippage) | No fail-safe if data or execution behaves unexpectedly |
| Paper traded before going live | Deployed with real capital straight from a backtest |
| Monitored regularly for performance drift | Left running unattended indefinitely |
| Clear, explainable logic | A black box even to the person who built it |
The single biggest cause of blown-up trading bots isn't a bad strategy, it's the absence of hard risk limits enforced automatically. A bot with a mediocre edge and strict risk controls survives. A bot with a great backtest and no risk controls eventually meets a market condition it wasn't built for and gives back months of gains in a session.
Why AI Doesn't Change the Fundamentals
Modern AI-assisted bots add a layer on top of this same core loop, often using a model to generate or refine the signal in step 2, or to adjust sizing dynamically in step 4. The loop itself, and the discipline required around risk management and validation, doesn't change. A bot with an AI-generated signal and no risk controls fails the same way a bot with a simple moving-average signal and no risk controls fails, just with more confident-sounding logic behind the decision.
Getting Started Responsibly
- Start with a strategy simple enough that you can explain its logic in two sentences.
- Backtest out-of-sample and paper trade before any real capital is involved.
- Build risk limits into the code itself, not into a rule you promise yourself you'll follow manually.
- Run small size initially, live, even after paper trading looks clean, execution always surfaces something a backtest didn't model.
- Monitor continuously. A strategy that worked for six months can stop working the moment market structure shifts underneath it.
Summary
A trading bot is a rules-based program that watches data, evaluates conditions, and executes orders without manual intervention at each step. The main strategy families (trend-following, mean reversion, market making, arbitrage, statistical arbitrage) are well understood and not inherently complex. What actually separates systems that survive from ones that blow up is disciplined risk management enforced in code, thorough out-of-sample validation, and a kill switch for conditions the strategy wasn't built to handle.
Related reading:
- Backtesting AI-Generated Trading Strategies — validating a bot's logic before it trades real capital
- Position Sizing Guide — the risk management layer every bot needs
- Risk-Reward Trading Guide — evaluating whether an automated strategy's edge justifies its risk
We're Cooking Something Great.
Revealing Soon.
TradeThesis is being rebuilt from the ground up. The 5-agent AI research pipeline is coming back sharper than before.
No sign-up needed. Just watch this space.