Python trading strategies, backtested
A growing library of trading strategies in Python. Each walkthrough explains the idea, gives you runnable Manifold-BT code, and backtests it with realistic costs, so you see how it behaves before risking a cent.
- Mean reversion strategy in Python
Mean reversion bets that price extremes snap back toward an average, here is the full strategy, in Python, backtested with realistic costs.
- Momentum strategy in Python
Momentum buys what is already going up, here is a Python momentum strategy, backtested with real costs on the Rust engine.
- Breakout strategy in Python
Breakout strategies buy when price escapes its recent range, here is one in Python, backtested honestly on the Rust core.
- VWAP strategy in Python
VWAP is the intraday fair-value benchmark traders watch, here is a VWAP strategy in Python, backtested on intraday bars.
- MACD trading strategy in Python
MACD is one of the most popular momentum indicators, here is a MACD trading strategy in Python, backtested with real costs.
- Moving average crossover in Python
The moving average crossover is the 'hello world' of trading systems, here it is in Python, backtested properly.
- Grid trading in Python
Grid trading scales into a position as price moves against you, here is a grid strategy in Python, backtested with real costs.
- Market making in Python
Market making earns the spread by providing liquidity, here is a simplified market-making strategy in Python, backtested on the Rust core.
- Pairs trading in Python
Pairs trading bets on the spread between two correlated assets, here is an ETH/BTC pairs strategy in Python, backtested on the Rust core.
- Crypto arbitrage in Python
Crypto arbitrage exploits price gaps between venues, here is a cross-exchange basis strategy in Python, backtested on the Rust core.
- Scalping strategy in Python
Scalping takes many small, fast trades, here is a scalping strategy in Python on one-minute bars, backtested with real costs.
- RSI strategy in Python
The RSI flags overbought and oversold extremes, here is an RSI mean-reversion strategy in Python, backtested with real costs on the Rust core.
- Swing trading strategy in Python
Swing trading captures multi-day moves, here is a trend-filtered swing strategy in Python, backtested with real costs on the Rust core.
- Intraday trading strategy in Python
Intraday trading opens and closes inside the session, here is an intraday strategy in Python on 5-minute bars, backtested with real costs.
- Trend following strategy in Python
Trend following rides sustained moves in either direction, here is a Donchian trend strategy in Python, backtested on the Rust core.
Keep reading
Run your first backtest
Install Manifold-BT and reproduce the backtest above in seconds. The Rust core runs years of bars sub-second so you can sweep parameters instead of waiting.