Quickstart
Quickstart Guide
How to use
Use Backtrader_Bokeh as analyzers(only Live Mode)
Default 80 port:
from backtrader_bokeh import bt ... ... cerebro = bt.Cerebro() cerebro.addstrategy(MyStrategy) cerebro.adddata(LiveDataStream()) # Note! Data is must Live Data cerebro.addanalyzer(bt.analyzers.Live, force_plot_legend=True, autostart=True) cerebro.run()
If 80 port is not available, you can use other port:
cerebro.addanalyzer(bt.analyzers.Live, address="localhost", port=8889, force_plot_legend=True, autostart=True)
Use Backtrader_Bokeh as plot object
Normal Mode is the backtest which has only a set of strategy's argument:
from backtrader_bokeh import bt ... ... plot = bt.Bokeh(style = 'bar', scheme=bt.schemes.Blackly(), force_plot_legend=True) # bt.schemes.Blackly is style of scheme cerebro.plot(plot, iplot=False) # if run in Jupter, need to pass 'iplot' argument in there
Optstrategy Mode is the backtest which has multi sets of strategy's argument:
from backtrader_bokeh import bt ... ... cerebro.optstrategy(MyStrategy, buydate=range(40, 180, 30)) result = cerebro.run(optreturn=False) b = bt.Bokeh(style='bar', scheme=bt.schemes.Tradimo(), force_plot_legend=True) browser = bt.Opt(b, result, address='localhost', port=8889, autostart= True) browser.start()
Document
You can get more of backtrader_bokeh documents through visit Documents or Github wiki