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 -i https://test.pypi.org/simple/ backtrader-plotly==1.1.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.2.0.tar.gz
(23.2 kB
view details)
Built Distribution
File details
Details for the file backtrader_plotly-1.2.0.tar.gz
.
File metadata
- Download URL: backtrader_plotly-1.2.0.tar.gz
- Upload date:
- Size: 23.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.10.0 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.8.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
269ce66f0867aa76913224f015e19eb810c7bdcc7ba16e2ec74c9648652cfa84
|
|
MD5 |
99e535671118572f771bdb20a8f1313c
|
|
BLAKE2b-256 |
aec2b574b3994c74cca21981ba5be85e4241960f8de3722f2004e7786495dc55
|
File details
Details for the file backtrader_plotly-1.2.0-py3-none-any.whl
.
File metadata
- Download URL: backtrader_plotly-1.2.0-py3-none-any.whl
- Upload date:
- Size: 22.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.10.0 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.8.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
4529bb05772cc34a1c3c881bb9731eb0db2ce2ceeb5aa497885e032344a42150
|
|
MD5 |
27679f46270f6da815b831f46786c229
|
|
BLAKE2b-256 |
a579f4b6f0a131664f5868e8a8b448be0134b5fddfa7c2eee1e91960203a3db8
|