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

OverflowError: int too large to convert to float



  • Im running an example from here: https://ntguardian.wordpress.com/2017/06/12/getting-started-with-backtrader/ and I ran into this error:

    ~/anaconda3/lib/python3.6/site-packages/backtrader/position.py in update(self, size, price, dt)
        191             if size < 0:  # increased position
        192                 opened, closed = size, 0
    --> 193                 self.price = (self.price * oldsize + size * price) / self.size
        194 
        195             elif self.size < 0:  # reduced position
    
    OverflowError: int too large to convert to float
    

    Seems like a simple error- self.price could easily be huge. Wondering if anyone else has encountered it, and if not what the next steps are (Im VERY new to github)


  • administrators

    It's a limitation of floating point storage capabilities (64 bits and you have to account for sign, mantissa and exponent). What is what you want to do?