@@ -34,7 +34,7 @@ def _tqdm(seq, **_):
34
34
35
35
from ._plotting import plot # noqa: I001
36
36
from ._stats import compute_stats
37
- from ._util import _as_str , _Indicator , _Data , try_
37
+ from ._util import _as_str , _Indicator , _Data , _indicator_warmup_nbars , _strategy_indicators , try_
38
38
39
39
__pdoc__ = {
40
40
'Strategy.__init__' : False ,
@@ -1290,14 +1290,11 @@ def run(self, **kwargs) -> pd.Series:
1290
1290
data ._update () # Strategy.init might have changed/added to data.df
1291
1291
1292
1292
# Indicators used in Strategy.next()
1293
- indicator_attrs = {attr : indicator
1294
- for attr , indicator in strategy .__dict__ .items ()
1295
- if isinstance (indicator , _Indicator )}.items ()
1293
+ indicator_attrs = _strategy_indicators (strategy )
1296
1294
1297
1295
# Skip first few candles where indicators are still "warming up"
1298
1296
# +1 to have at least two entries available
1299
- start = 1 + max ((np .isnan (indicator .astype (float )).argmin (axis = - 1 ).max ()
1300
- for _ , indicator in indicator_attrs ), default = 0 )
1297
+ start = 1 + _indicator_warmup_nbars (strategy )
1301
1298
1302
1299
# Disable "invalid value encountered in ..." warnings. Comparison
1303
1300
# np.nan >= 3 is not invalid; it's False.
0 commit comments