-
Notifications
You must be signed in to change notification settings - Fork 130
Home
Welcome to the backtrader_plotting wiki!
The class Bokeh
accepts the following options:
-
scheme
- a scheme object for rendering -
filename
- output filename -
plotconfig
- a Python dictionary with individual plot options as described below -
inmemory
- do not actually write an output file (plotted objects are returned by the call tocerebro.run
) -
tabs
- the tab mode. Available modessingle
andmulti
. Insingle
mode all datas and indicators will be placed in one tabe titledPlots
. Inmulti
mode they will go into individual tabs titledDatas
andIndicators
. Nevertheless tab group can still be modified using optionplottab
Available Options:
Lots of backtrader
's built-in options are supported. A (probably incomplete) list:
subplot
plotmaster
plotname
-
plot
/plotskip
-
- not supported. Please useplotabove
plotorder
instead. plothlines
plotyhlines
plotyticks
Addition Parameters:
backtrader_plotting
also features some extra plotting parameters:
-
plotid
- assigns an identifier to a plot object. Used to reference it in the late plot configuration. -
plottab
- name of a tab this object should be plotted to. Allows to define custom tabs. If not provided then objects will be plotted by category (Datas
orIndicators
). Only allowed for data and indicator object. Does only apply for plot master objects. -
plotaspectratio
- assigns a custom aspect ratio -
plotorder
- an integer defining the order of the objects inside a tab. All objects default to0
. Can only be used on data masters. Objects are ordered with smaller numbers first.
Every plottable glyph will have a lable which consits of these parts:
{label} ({parameters}) @{datas}
label
- Either the classname or the plotname
if provided
parameters
- a stringified list of the object parameters
datas
- a list of all datas this object works on
When using backrader_plotting
then plotting configuration can be done totally separately from strategy configuration. The plotting can be configured in the code after the backtest finished running like this:
plotconfig = {
'id:ind#0': dict(
subplot=True,
),
}
b = Bokeh(style='bar', plot_mode='single', scheme=Tradimo(), plotconfig=plotconfig)
cerebro.plot(b)
plotconfig
is a dictionary. Every key is an expression that selects one or more entities which plot configuration has to be configured. Each value is another dictionary with attributes that will be assigned to the selected objects.
The key has to be in one of these formats:
-
id:<plotid>
- Selects the entitiy with the specifiedplotid
-
#:<type>-<n>
- Selects the n-th object of type. Type can beii
for indicators,o
for observers ord
for datas -
r:<regex>
- A regular expression matching the label of one or more objects
plotaspectratio
Global aspect ratio can be set on the scheme applying to all figures. Individual aspect ratios for specific figures can be overriden though by setting plotaspectratio
on a object. It needs to be applied to a plot master object. It will not hae an effect when applied to a slave object.