-
Notifications
You must be signed in to change notification settings - Fork 134
Home
Welcome to the backtrader_plotting wiki!
The class Bokeh accepts the following special options:
-
scheme- a scheme object for rendering -
filename- output filename -
plotconfig- a Python dictionary with individual plot options as described below -
output_mode- one of 'show', 'save' or 'memory'.memorywill not save to file but return the model.savewill save the model to disk.showwill save the model to disk and automatically launch in browser.
All other options will be interpreted as scheme parameters and will be directly forwarded to modify the currently used scheme.
Example:
b = Bokeh(style='line', scheme=Blackly(), output_mode='memory', legend_text_color='#ff0000')
Scheme options change the way the resulting web pages are rendered. These include style option (like the color and background) but also structural options (like will tabs be automatically used).
These options are part of the scheme in use (e.g. Blackly or Tradimo). Individual options can also be passed as parameters to the Bokeh object.
Structural Options:
-
hover_config- controls a comma separated list of strings that control which data is shown in the hover tooltips. Please refer to the hover tooltip section for details. -
tabs- the tab mode. Available modes aresingleandmulti. Insinglemode all datas and indicators will be placed in one tab titledPlots. Inmultimode they will go into individual tabs titledDatasandIndicators. Nevertheless tab group can still be modified using optionplottab -
show_headline- Places a headline on top of the result page
By default all data lines in a figure are also placed in the corresponding hover tooltip. More data lines can be added using the scheme option hover_tooltip_config. It consists of a comma separated list of 2-character strings. Each character has to be one of:
-
d- data feed -
i- indicator -
o- observer
It configures which types should be added to which other types. The first character is the input type and the second character the target type. So di would mean: Place tooltip lines of all data feeds in the charts of all indicator figures. You can have multiple of those rules separated by commas. Example dd,id,do. This would place all data feed lines to all other data feeds, would place all indicator lines to all data feeds and all data feeds to all observers.
Available Options: Lots of backtrader's built-in options are supported. A (probably incomplete) list:
subplotplotmasterplotname-
plot/plotskip -
- not supported. Please useplotaboveplotorderinstead. plothlinesplotyhlinesplotyticks
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 (DatasorIndicators). 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.
Normally in backtader the plotting configuration is done inside the strategy code to apply plotting options directly to your python objects. When using backrader_plotting then plotting configuration can be done separated from the strategy code. 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 beiifor indicators,ofor observers ordfor datas -
r:<regex>- A regular expression matching the label of one or more objects