MCPcopy Index your code
hub / github.com/kernc/backtesting.py / plot

Method plot

backtesting/backtesting.py:1643–1752  ·  view source on GitHub ↗

Plot the progression of the last backtest run. If `results` is provided, it should be a particular result `pd.Series` such as returned by `backtesting.backtesting.Backtest.run` or `backtesting.backtesting.Backtest.optimize`, otherwise the last run's

(self, *, results: pd.Series = None, filename=None, plot_width=None,
             plot_equity=True, plot_return=False, plot_pl=True,
             plot_volume=True, plot_drawdown=False, plot_trades=True,
             smooth_equity=False, relative_equity=True,
             superimpose: Union[bool, str] = True,
             resample=True, reverse_indicators=False,
             show_legend=True, open_browser=True)

Source from the content-addressed store, hash-verified

1641 shmem.close()
1642
1643 def plot(self, *, results: pd.Series = None, filename=None, plot_width=None,
1644 plot_equity=True, plot_return=False, plot_pl=True,
1645 plot_volume=True, plot_drawdown=False, plot_trades=True,
1646 smooth_equity=False, relative_equity=True,
1647 superimpose: Union[bool, str] = True,
1648 resample=True, reverse_indicators=False,
1649 show_legend=True, open_browser=True):
1650 """
1651 Plot the progression of the last backtest run.
1652
1653 If `results` is provided, it should be a particular result
1654 `pd.Series` such as returned by
1655 `backtesting.backtesting.Backtest.run` or
1656 `backtesting.backtesting.Backtest.optimize`, otherwise the last
1657 run's results are used.
1658
1659 `filename` is the path to save the interactive HTML plot to.
1660 By default, a strategy/parameter-dependent file is created in the
1661 current working directory.
1662
1663 `plot_width` is the width of the plot in pixels. If None (default),
1664 the plot is made to span 100% of browser width. The height is
1665 currently non-adjustable.
1666
1667 If `plot_equity` is `True`, the resulting plot will contain
1668 an equity (initial cash plus assets) graph section. This is the same
1669 as `plot_return` plus initial 100%.
1670
1671 If `plot_return` is `True`, the resulting plot will contain
1672 a cumulative return graph section. This is the same
1673 as `plot_equity` minus initial 100%.
1674
1675 If `plot_pl` is `True`, the resulting plot will contain
1676 a profit/loss (P/L) indicator section.
1677
1678 If `plot_volume` is `True`, the resulting plot will contain
1679 a trade volume section.
1680
1681 If `plot_drawdown` is `True`, the resulting plot will contain
1682 a separate drawdown graph section.
1683
1684 If `plot_trades` is `True`, the stretches between trade entries
1685 and trade exits are marked by hash-marked tractor beams.
1686
1687 If `smooth_equity` is `True`, the equity graph will be
1688 interpolated between fixed points at trade closing times,
1689 unaffected by any interim asset volatility.
1690
1691 If `relative_equity` is `True`, scale and label equity graph axis
1692 with return percent, not absolute cash-equivalent values.
1693
1694 If `superimpose` is `True`, superimpose larger-timeframe candlesticks
1695 over the original candlestick chart. Default downsampling rule is:
1696 monthly for daily data, daily for hourly data, hourly for minute data,
1697 and minute for (sub-)second data.
1698 `superimpose` can also be a valid [Pandas offset string],
1699 such as `'5T'` or `'5min'`, in which case this frequency will be
1700 used to superimpose.

Callers 15

test_optimizeMethod · 0.95
test_file_sizeMethod · 0.95
test_paramsMethod · 0.95
test_hide_legendMethod · 0.95
test_resolutionsMethod · 0.95
test_range_axisMethod · 0.95
test_previewMethod · 0.95
test_wellknownMethod · 0.95
test_resampleMethod · 0.95
test_indicator_nameMethod · 0.95
test_indicator_colorMethod · 0.95

Calls 1

plotFunction · 0.90

Tested by

no test coverage detected