26
26
27
27
from ._plotting import plot_heatmaps as _plot_heatmaps
28
28
from ._stats import compute_stats as _compute_stats
29
- from ._util import SharedMemoryManager , _Array , _as_str , _batch , _tqdm
29
+ from ._util import SharedMemoryManager , _Array , _as_str , _batch , _tqdm , patch
30
30
from .backtesting import Backtest , Strategy
31
31
32
32
__pdoc__ = {}
@@ -534,14 +534,17 @@ def __init__(self,
534
534
'Use `FractionalBacktest(..., fractional_unit=)`.' ,
535
535
category = DeprecationWarning , stacklevel = 2 )
536
536
fractional_unit = 1 / kwargs .pop ('satoshi' )
537
- data = data .copy ()
538
- data [['Open' , 'High' , 'Low' , 'Close' ]] *= fractional_unit
539
- data ['Volume' ] /= fractional_unit
540
537
self ._fractional_unit = fractional_unit
541
- super ().__init__ (data , * args , ** kwargs )
538
+ with warnings .catch_warnings (record = True ):
539
+ warnings .filterwarnings (action = 'ignore' , message = 'frac' )
540
+ super ().__init__ (data , * args , ** kwargs )
542
541
543
542
def run (self , ** kwargs ) -> pd .Series :
544
- result = super ().run (** kwargs )
543
+ data = self ._data .copy ()
544
+ data [['Open' , 'High' , 'Low' , 'Close' ]] *= self ._fractional_unit
545
+ data ['Volume' ] /= self ._fractional_unit
546
+ with patch (self , '_data' , data ):
547
+ result = super ().run (** kwargs )
545
548
546
549
trades : pd .DataFrame = result ['_trades' ]
547
550
trades ['Size' ] *= self ._fractional_unit
@@ -554,12 +557,6 @@ def run(self, **kwargs) -> pd.Series:
554
557
555
558
return result
556
559
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
562
-
563
560
564
561
# Prevent pdoc3 documenting __init__ signature of Strategy subclasses
565
562
for cls in list (globals ().values ()):
0 commit comments