A feature rich python framework for backtesting and trading

backtrader enables to focus on writing reusable trading strategies, indicators and analyzers instead of spending time building infrastructure.

Open Source

Use, modify, audit and share it. The secret is in the sauce and you are the cook. This is just the tool.

GitHub Repo

Feature Complete

Multiple Data Feeds, timeframes, strategies, indicators, optimization and more.

See More

Fully Documented

Check the QuickStart, In-Depth topics, Indicators and also ideas and others in the blog.

See Docs See Blog

Community Enabled

See what others have already asked, answered & shared. You are the community! Join and be it!


It can be as easy as this snippet!

    from datetime import datetime
    import backtrader as bt
    class SmaCross(bt.SignalStrategy):
        params = (('pfast', 10), ('pslow', 30),)
        def __init__(self):
            sma1, sma2 = bt.ind.SMA(period=self.p.pfast), bt.ind.SMA(period=self.p.pslow)
            self.signal_add(bt.SIGNAL_LONG, bt.ind.CrossOver(sma1, sma2))
    cerebro = bt.Cerebro()
    data = bt.feeds.YahooFinanceData(dataname='YHOO', fromdate=datetime(2011, 1, 1),
                                     todate=datetime(2012, 12, 31))



In these few lines you'll find a complete SMA CrossOver strategy with customizable parameters, automatic order management and plotting. There are many other possibilities. Check it out!


Click the Chart!

Used in
Send us a message if you also use it
   1 EuroStoxx 50 Bank
   3 Quantitative Trading Firms