For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See:

ZeroDivisionError: float division by zero

  • Re: anaylzer-vwr may have something error

    Traceback (most recent call last):
      File "/home/svetter/.local/lib/python3.6/site-packages/django_extensions/management/commands/", line 35, in runjob
      File "/home/svetter/zenvest/analysis/jobs/daily/", line 325, in execute
        result =
      File "/home/svetter/.local/lib/python3.6/site-packages/backtrader/", line 1127, in run
        runstrat = self.runstrategies(iterstrat)
      File "/home/svetter/.local/lib/python3.6/site-packages/backtrader/", line 1301, in runstrategies
      File "/home/svetter/.local/lib/python3.6/site-packages/backtrader/", line 486, in _stop
      File "/home/svetter/.local/lib/python3.6/site-packages/backtrader/", line 200, in _stop
      File "/home/svetter/.local/lib/python3.6/site-packages/backtrader/analyzers/", 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
        dt = np.NaN

Log in to reply