|
24 | 24 | import numpy as np
|
25 | 25 | import pandas as pd
|
26 | 26 |
|
27 |
| -from ._plotting import plot_heatmaps as _plot_heatmaps, plot |
| 27 | +from ._plotting import plot_heatmaps as _plot_heatmaps |
28 | 28 | from ._stats import compute_stats as _compute_stats
|
29 | 29 | from ._util import SharedMemoryManager, _Array, _as_str, _batch, _tqdm
|
30 | 30 | from .backtesting import Backtest, Strategy
|
@@ -554,42 +554,11 @@ def run(self, **kwargs) -> pd.Series:
|
554 | 554 |
|
555 | 555 | return result
|
556 | 556 |
|
557 |
| - def plot(self, *, results: pd.Series = None, filename=None, plot_width=None, |
558 |
| - plot_equity=True, plot_return=False, plot_pl=True, |
559 |
| - plot_volume=True, plot_drawdown=False, plot_trades=True, |
560 |
| - smooth_equity=False, relative_equity=True, |
561 |
| - superimpose: Union[bool, str] = True, |
562 |
| - resample=True, reverse_indicators=False, |
563 |
| - show_legend=True, open_browser=True): |
564 |
| - |
565 |
| - data = self._data.copy() |
566 |
| - data[['Open', 'High', 'Low', 'Close']] /= self._fractional_unit |
567 |
| - data['Volume'] *= self._fractional_unit |
568 |
| - |
569 |
| - if results is None: |
570 |
| - if self._results is None: |
571 |
| - raise RuntimeError('First issue `backtest.run()` to obtain results.') |
572 |
| - results = self._results |
573 |
| - |
574 |
| - return plot( |
575 |
| - results=results, |
576 |
| - df=data, |
577 |
| - indicators=results._strategy._indicators, |
578 |
| - filename=filename, |
579 |
| - plot_width=plot_width, |
580 |
| - plot_equity=plot_equity, |
581 |
| - plot_return=plot_return, |
582 |
| - plot_pl=plot_pl, |
583 |
| - plot_volume=plot_volume, |
584 |
| - plot_drawdown=plot_drawdown, |
585 |
| - plot_trades=plot_trades, |
586 |
| - smooth_equity=smooth_equity, |
587 |
| - relative_equity=relative_equity, |
588 |
| - superimpose=superimpose, |
589 |
| - resample=resample, |
590 |
| - reverse_indicators=reverse_indicators, |
591 |
| - show_legend=show_legend, |
592 |
| - open_browser=open_browser) |
| 557 | + def _get_plot_data(self) -> pd.DataFrame: |
| 558 | + plot_data = self._data.copy() |
| 559 | + plot_data[['Open', 'High', 'Low', 'Close']] /= self._fractional_unit |
| 560 | + plot_data['Volume'] *= self._fractional_unit |
| 561 | + return plot_data |
593 | 562 |
|
594 | 563 |
|
595 | 564 | # Prevent pdoc3 documenting __init__ signature of Strategy subclasses
|
|
0 commit comments