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/

    decimal.Decimal in BT

    General Code/Help
    3
    4
    515
    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.
    • D
      deedy last edited by

      I am seeing large discrepancies between computations in my actual system, which uses Decimals throughout, and my results in BT.

      How hard would it be to go through the codebase and convert everything to a Decimal?

      I would like to get a handle on the size of the task to see whether it is worth my time.

      Kind Regards

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

        @deedy said in decimal.Decimal in BT:

        I am seeing large discrepancies between computations in my actual system

        I see large discrepancies between a blank statement like that one, backed by an anonymous id in a forum in the internet, and ... well who knows where the discrepancies are what you mean and ... and ...

        D 1 Reply Last reply Reply Quote 0
        • D
          deedy @backtrader last edited by

          @backtrader

          Floating point arithmetic.

          I have written a system which uses high precision Decimals. Backtrader uses Floats.

          I run a backtest through my system to verify the output of BT.

          To do this, I must convert the source prices used in BT from Floats into Decimals.

          After some iterations, with spreads involving subtraction and division, my indicators begin to diverge, presumably due to the increased rounding accuracy.

          I would prefer to convert BT to use Decimals and this is why I asked the question.

          Without searching the entire codebase for occurences of all numbers, I would like to ask the creator of this library for his view on how best to do this.

          B 1 Reply Last reply Reply Quote 0
          • B
            beladiyahardik7 @deedy last edited by

            @backtrader can you please reply on this one. as this is the main concern when we are dealing with the float.

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