ZeroDivisionError: float division by zero
Sebastian Vetter last edited by
Traceback (most recent call last): File "/home/svetter/.local/lib/python3.6/site-packages/django_extensions/management/commands/runjob.py", line 35, in runjob job().execute() File "/home/svetter/zenvest/analysis/jobs/daily/backtest_technical_analysis.py", line 325, in execute result = cerebro.run() File "/home/svetter/.local/lib/python3.6/site-packages/backtrader/cerebro.py", line 1127, in run runstrat = self.runstrategies(iterstrat) File "/home/svetter/.local/lib/python3.6/site-packages/backtrader/cerebro.py", line 1301, in runstrategies strat._stop() File "/home/svetter/.local/lib/python3.6/site-packages/backtrader/strategy.py", line 486, in _stop analyzer._stop() File "/home/svetter/.local/lib/python3.6/site-packages/backtrader/analyzer.py", line 200, in _stop self.stop() File "/home/svetter/.local/lib/python3.6/site-packages/backtrader/analyzers/vwr.py", line 154, in stop dt = pn / (pi * math.exp(ravg * n)) - 1.0 ZeroDivisionError: float division by zero
I just had my script run through a few iterations and actually ran into the same issue. I'm not quite sure how
(pi * math.exp(ravg*n) - 1.0
can be zero? with the exponential value of pi * (ravg*n) being exactly 1.0?
Did anyone else run into this? @backtrader what do you think about the suggestion made by the original author to add another check and potentially fill in NaN?
# add a more assert if pi * math.exp(ravg * n)!=0: dt = pn / (pi * math.exp(ravg * n)) - 1.0 else: dt = np.NaN