From 7e34959f43d159df40558be217d7f9a320c0df76 Mon Sep 17 00:00:00 2001 From: Vineet Verma Date: Sat, 5 Oct 2024 17:08:28 +0530 Subject: [PATCH] Adding TQDM progress bar to Run method Adding TQDM progress bar to Run method. This will start showing progress while executing the backtest --- backtesting/backtesting.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/backtesting/backtesting.py b/backtesting/backtesting.py index 9c168703..bd76d55e 100644 --- a/backtesting/backtesting.py +++ b/backtesting/backtesting.py @@ -24,7 +24,9 @@ try: from tqdm.auto import tqdm as _tqdm + from tqdm.auto import trange as _trange _tqdm = partial(_tqdm, leave=False) + _trange = partial(_trange, leave=False) except ImportError: def _tqdm(seq, **_): return seq @@ -1202,7 +1204,7 @@ def run(self, **kwargs) -> pd.Series: # np.nan >= 3 is not invalid; it's False. with np.errstate(invalid='ignore'): - for i in range(start, len(self._data)): + for i in _trange(start, len(self._data),): # Prepare data and indicators for `next` call data._set_length(i + 1) for attr, indicator in indicator_attrs: