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/

    Why `observer.array` so many `nan`?

    General Code/Help
    2
    4
    70
    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.
    • asdasda
      asdasda last edited by

      Seems the nan count same to the non nan count, in other words, the nan is a half of the observer.array.

      5f2fa3be-36b1-48f1-8ede-89bcdb55fefe-image.png

      vladisld 1 Reply Last reply Reply Quote 0
      • vladisld
        vladisld @asdasda last edited by

        @asdasda Observer's array member actually refers to observers's first line (LineBuffer object) array member. This array member is used internally for LineBuffer data storage and usually not used/accessed/manipulated directly unless one knows exactly what she/he is doing. In some cases it may be of larger size than loaded/filled data - in which case the extra size is filled wit nans. LineBuffer actually defines its own interface to access the underlying array buffer ( for example it defines the currently active index, access to the past and future values, and many more)

        It is better to use a regular documented ways to access the line data. Please see the following docs:
        https://www.backtrader.com/docu/concepts/#lines

        Also the following post may be useful as well:
        https://community.backtrader.com/topic/3921/zero-records-while-loading-data-from-csv/

        In case you really would like to access the internal buffer directly, please take a lool at the LineBuffer's implementation first:
        https://github.com/mementum/backtrader/blob/master/backtrader/linebuffer.py

        1 Reply Last reply Reply Quote 0
        • asdasda
          asdasda last edited by

          @vladisld How can I access the full line data of observer after cerebro.run()?

          vladisld 1 Reply Last reply Reply Quote 0
          • vladisld
            vladisld @asdasda last edited by

            @asdasda Using slicing could be an option. Docs here

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