Your first strategy bot: a moving-average crossover in Python
Build it, backtest it, and read the report — step by step, with simulated money. The best place to start if you've never written a trading bot.
5 min read
🧪 Simulated money · zero risk · nothing real is traded
CodeBull is a paper-trading platform where you practise Python and trading concepts by building strategy bots — backtest them on real-world market data and compete with your bots against other users' strategies.
Free to use · No credit card required · No real money, ever
class Strategy:
def __init__(self):
self.prices = {}
self.position = {}
self.fast_period = 10
self.slow_period = 20
def on_new_tick(self, symbol, price, ctx):
if symbol not in self.prices:
self.prices[symbol] = []
self.position[symbol] = False
self.prices[symbol].append(price)
if len(self.prices[symbol]) < self.slow_period:
return
prices = self.prices[symbol]
fast_sma = sum(prices[-self.fast_period:]) / self.fast_period
slow_sma = sum(prices[-self.slow_period:]) / self.slow_period
if fast_sma > slow_sma and not self.position[symbol]:
ctx.place_order(symbol, "buy", 10, "market")
self.position[symbol] = True
Backtest · 2019–2024
▲ +11.4%
Simulated equity · 142 trades
Arena
Your bot vs 3 strategies
running
Illustrative backtest on simulated money — not real performance.
Four steps, from an idea to a result you can read.
Write your strategy in Python, or snap it together with visual blocks.
Run it against real-world market data with simulated money.
Read the report: equity curve, trades, P/L. Learn what worked.
Enter your bot in the arena against other users' strategies.
Six pillars that take you from idea to insight.
Write strategies in Python, or snap them together from visual blocks. Switch between the two whenever you like — both build the same bots, and the engine runs them the same way.
Replay historical data and market-price snapshots drawn from real markets, with simulated money, to see how an idea would have behaved.
Equity curve, cash, every trade and the P/L behind it — so you can see exactly where a strategy won or lost.
Enter your bot in timed arenas, where it runs against other users' strategies in sandboxed simulation accounts.
Simulated money only. No real orders are ever sent, so you can experiment freely — including with the ideas that turn out badly.
Guides from the blog walk through paper trading, backtesting and your first strategy bot, step by step.
Practical guides, all on simulated money.
Build it, backtest it, and read the report — step by step, with simulated money. The best place to start if you've never written a trading bot.
5 min read
What a simulated portfolio can teach you about real markets, and where the simulation ends.
4 min read
Overfitting, lookahead bias and the traps that make a strategy look smarter than it is.
4 min read
Build it in Python or visual blocks, backtest it on simulated money, and read the report. It's free, and there's no money at risk.
Get started freeAlready have an account? Sign in