Skip to main content

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.4.0

Features

  • Support for Filled Area Plotting and Toggling (Added from 1.4.0)

  • New Scheme Arguments (Added from 1.3.0)

    Additional 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

Complete Working Example Here

# 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


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.4.0.tar.gz (23.9 kB view details)

Uploaded Source

Built Distribution

backtrader_plotly-1.4.0-py3-none-any.whl (23.6 kB view details)

Uploaded Python 3

File details

Details for the file backtrader_plotly-1.4.0.tar.gz.

File metadata

  • Download URL: backtrader_plotly-1.4.0.tar.gz
  • Upload date:
  • Size: 23.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.8.10

File hashes

Hashes for backtrader_plotly-1.4.0.tar.gz
Algorithm Hash digest
SHA256 2f8823ac38db6705e759087bf2dbdeff1970e7abd47e132e58652bf042b186cb
MD5 0179c311a044edfb8b88b789dfa1b228
BLAKE2b-256 b0b93f56d333ad7f48ec23ab7493d9be90c82057e1828bcc696ca9f0d82a2824

See more details on using hashes here.

File details

Details for the file backtrader_plotly-1.4.0-py3-none-any.whl.

File metadata

File hashes

Hashes for backtrader_plotly-1.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4c2709af936ee63a2c926d73a51d2c38d0883d45bbb842704b900ae1b9cb6aa6
MD5 28402cf0c36052b3d31d307ee7ee1bd0
BLAKE2b-256 6c82fd050db8f18be5852cf6a1ef6be1cba6ac750b5c32cff979664084f4d36e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page