Navigation

    Backtrader Community

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    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

    General Code/Help
    2
    2
    1708
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • yzpaul
      yzpaul last edited by yzpaul

      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)

      1 Reply Last reply Reply Quote 0
      • B
        backtrader administrators last edited by

        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?

        1 Reply Last reply Reply Quote 0
        • 1 / 1
        • First post
          Last post
        Copyright © 2016, 2017, 2018, 2019, 2020, 2021 NodeBB Forums | Contributors