Library replacing original matlibplot used by backtrader
Project description
backtrader_plotly
Plot backtrader
's result using plotly
instead of the default matplotlib
This is an experimental package, and it is done by replacing original matplotlib
method calls.
Installation
$ pip install backtrader-plotly==1.3.0
New Scheme Arguments
New scheme arguments are added to provide extra control
Name of Argument | Default Value | Description |
---|---|---|
decimal_places | 5 | It is used to control the number of decimal places of price shown on the plot. For instance, forex price usually consists of 5 decimal places. |
max_legend_text_width | 16 | It is used to limit the legend text width to prevent it from occupying the page. |
Usage
# import the package after installation
from backtrader_plotly.plotter import BacktraderPlotly
from backtrader_plotly.scheme import PlotScheme
import plotly.io
# do whatever you want with `backtrader`
import backtrader as bt
# for instance
cerebro = bt.Cerebro()
# after adding data and strategy
cerebro.run()
# define plot scheme with new additional scheme arguments
scheme = PlotScheme(decimal_places=5, max_legend_text_width=16)
# plot and save figures as `plotly` graph object
figs = cerebro.plot(BacktraderPlotly(show=True, scheme=scheme))
figs = [x for fig in figs for x in fig] # flatten output
for fig in figs:
plotly.io.to_html(fig, full_html=False) # open html in the browser
plotly.io.write_html(fig, file='plot.html') # save the html file
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
backtrader_plotly-1.3.0.tar.gz
(23.5 kB
view details)
Built Distribution
File details
Details for the file backtrader_plotly-1.3.0.tar.gz
.
File metadata
- Download URL: backtrader_plotly-1.3.0.tar.gz
- Upload date:
- Size: 23.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.8.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6cfd57976a133bee6b101f91fc3af35f0f621dfde5a25990aee49ede9ffb52da |
|
MD5 | cc291c005821ff4d069f05bec46b810e |
|
BLAKE2b-256 | 2f626876b1da8903acb8106792f5cdf522824250f2e2074f96f8c991b36a2546 |
File details
Details for the file backtrader_plotly-1.3.0-py3-none-any.whl
.
File metadata
- Download URL: backtrader_plotly-1.3.0-py3-none-any.whl
- Upload date:
- Size: 23.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.8.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e616ee250121d94ca078e8fced223add068f7861e91b963c22ba32baa323470b |
|
MD5 | 3757b6599dabcbbbe3d7728d25cb5356 |
|
BLAKE2b-256 | 1ca59cbe35348c703edb654d8b4ad0cb8d6c328d8c2880eb035b57a0c05d3c36 |