Lab: free tools · size first · stock scanner · crypto scanner · journal
Algorithmic Trading
Algorithmic trading in crypto refers to using computer programs to automatically execute trades based on predefined rules and strategies, removing human emotion from the decision-making process.
What Is Algorithmic Trading in Crypto?
Algorithmic trading, commonly called algo trading or automated trading, is the use of computer programs to execute trades automatically based on a predefined set of instructions. These instructions can range from simple rules ("buy Bitcoin when the 50-day moving average crosses above the 200-day moving average") to highly complex quantitative models that analyse dozens of market variables simultaneously and execute hundreds of trades per second.
In traditional finance, algorithmic trading has been dominant since the 1990s and now accounts for the majority of volume on equity and futures exchanges. In cryptocurrency markets, the adoption of algorithmic strategies has accelerated sharply since 2017, driven by the 24/7 trading nature of crypto, the accessibility of exchange APIs, and the spread of open-source trading code.
The main case made for algorithmic trading is that it takes emotion out of execution. Fear and greed, the two emotions that cause most retail trading losses, do not influence an algorithm. A bot carries out its rules exactly as written, whatever the market is doing, whatever the headlines say and however stressful it gets to watch a position go the wrong way.
Types of Algorithmic Strategies in Crypto
Trend Following
Trend-following algorithms identify the direction of market momentum and place trades in that direction. Common implementations use moving average crossovers, the MACD indicator, or the ADX to detect trend strength. When the algorithm detects a qualifying trend condition, it enters a long or short position and holds it until a reversal signal occurs or a stop-loss is triggered.
Trend-following bots perform best in strongly trending markets (like the 2020–2021 Bitcoin bull run) and struggle in choppy, sideways conditions where frequent small losses accumulate. Most professional trend-following systems use filters to avoid trading in low-volatility, range-bound environments.
Market Making
Market-making algorithms simultaneously place both buy (bid) and sell (ask) limit orders around the current market price. The bot profits from the spread, the difference between the bid and ask prices, collected each time both orders are filled. It continuously adjusts the orders as the market price moves, maintaining a presence on both sides of the order book.
Market making is a low-margin, high-volume strategy that requires significant capital, sophisticated risk management (to avoid inventory accumulation during one-sided market moves), and very low latency. On major crypto exchanges, dedicated market-making firms provide significant liquidity in exchange for reduced or rebated trading fees.
Arbitrage
Arbitrage bots exploit price discrepancies for the same asset across different exchanges or trading pairs. If Bitcoin is priced at $60,000 on Exchange A and $60,050 on Exchange B, an arbitrage bot will simultaneously buy on A and sell on B, trying to capture the $50 gap per Bitcoin (minus fees and slippage).
Simple exchange arbitrage (also called spatial arbitrage) has become increasingly difficult as competition among bots has compressed spreads. More sophisticated forms include triangular arbitrage (exploiting price inconsistencies between three trading pairs on the same exchange) and statistical arbitrage (trading pairs of correlated assets when their price relationship diverges from the historical norm).
Mean Reversion
Mean reversion strategies assume that after an asset moves significantly away from its historical average price or from a correlated asset, it will revert back. Bollinger Bands strategies, RSI-based overbought/oversold systems, and pairs trading are all forms of mean reversion. The algorithm sells when price is statistically stretched above the mean and buys when it is stretched below.
Mean reversion strategies tend to perform well in range-bound markets but can suffer severe losses in strong trending environments where price continues to move away from the mean for extended periods. Risk management, including hard stop-losses and position size limits, is essential for any mean reversion system.
Execution Algorithms (TWAP/VWAP)
Execution algorithms are not designed to generate alpha (excess returns) but to minimise market impact when entering or exiting large positions. TWAP (Time-Weighted Average Price) algorithms break a large order into equal-sized slices executed at regular time intervals. VWAP (Volume-Weighted Average Price) algorithms distribute the order according to expected trading volume throughout the day. Both methods reduce the price impact of large orders that would move the market if placed all at once.
High-Frequency Trading (HFT)
High-frequency trading involves executing a very large number of trades at extremely high speeds, often in microseconds, to capture tiny price inefficiencies that exist only momentarily. HFT requires co-location of servers physically close to exchange matching engines, proprietary network connections, and significant capital investment. It is largely the domain of well-funded institutional firms rather than individual retail traders.
How API Key Permissions Work for Algo Trading
Any program that trades through an exchange API signs in with an API key, and the permissions on that key decide what it can do:
- Read access: The program can see balances, orders, and market data, and it can't place a trade.
- Trade access: The program can place and cancel orders, so it's usually switched on only when the strategy has to trade.
- Withdrawal access: Most setups leave withdrawal permission off on each key, since a trading program never needs to move funds off the exchange.
- IP allowlist: Where the exchange offers it, the key can be locked to the trading server's IP address, so it won't work from anywhere else if it leaks.
Backtesting: How Algo Strategies Get Tested
Algo strategies are normally backtested against historical data before they ever trade real money. Backtesting simulates how a strategy would have performed in the past using real historical price data. A good backtest accounts for realistic transaction costs (exchange fees and slippage), avoids look-ahead bias (using data that was not available at the time of the simulated trade), and is tested across different market regimes: bull, bear, and sideways.
A critical failure mode in algo trading is overfitting, tuning a strategy so precisely to historical data that it performs brilliantly on the backtest but poorly in live markets. Walk-forward optimisation and out-of-sample testing are used to detect and mitigate overfitting before deployment.
Risk Management in Algorithmic Trading
Even the best algorithms can lose money during adverse market conditions. Well-built algorithmic systems include:
- Maximum drawdown limits: Many systems pause or shut down once the account's drawdown passes a set threshold, such as 15%.
- Position size limits: No single trade risks more than a fixed percentage of the account (typically 1–2%).
- Hard stop-losses: Emergency exits to limit catastrophic losses in extreme market conditions.
- Kill switches: Manual override capability to stop all trading instantly if something goes wrong.
A sizing rule is plain arithmetic about how much of the account one trade can put at risk, and an algorithm applies that rule before each order goes out.
Common Pitfalls in Algo Trading
Curve fitting: It means over-optimising parameters on historical data without out-of-sample validation. A strategy that wins 90% on backtests and loses money live is almost certainly overfit.
Ignoring fees: Many strategies look profitable on backtests but become unprofitable once realistic exchange fees (0.05–0.10% per trade) are accounted for. High-frequency strategies are especially vulnerable.
Neglecting infrastructure: A strategy that needs 99.9% uptime is exposed to every outage on a residential internet connection. Server reliability, exchange API stability, and error handling are critical engineering concerns.
Under-capitalisation: Many arbitrage and market-making strategies require significant capital to generate meaningful absolute returns. Starting with too little capital means fees and slippage consume a disproportionate share of profits.
Summary
Algorithmic trading runs a strategy with a speed and consistency that manual trading can't match, and it can still lose money. From simple moving average systems to sophisticated market-making operations, algo trading spans a wide spectrum of complexity and capital requirements. Whatever the strategy, the fundamentals stay the same: careful backtesting, steady risk control and position sizes that fit the account.