Backtrader Community

    • 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/

    Broker.getvalue() = nan?

    General Code/Help
    3
    6
    2417
    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.
    • C
      cwse last edited by

      Hi There,

      I have a strange case where when I run a multi-stock strategy which different stocks, after a while the broker.getvalue() returns nan. Could this be because some stock dataframes (which have additional LINES columns) have no values in the additional LINES colums? Would this cause the broker to error?

      I don't think any of the data has missing OHLC values, but could that also cause this error?

      Thanks!

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

        The broker only uses the close price to make value calculations. Any other thing in the data feeds is not considered (high, low and open are used for order execution but not for value calculations)

        C 1 Reply Last reply Reply Quote 0
        • C
          cwse @backtrader last edited by cwse

          @backtrader OK cool - so a missing value would cause the broker to error?

          Even if that stock wasn't held at the time (position = 0)?

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

            If the definition of missing value is NaN, then it will probably set everything to NaN: Python arithmetic rules. But without any code, data sample, etc ... it's impossible to say what, when, how and why.

            1 Reply Last reply Reply Quote 0
            • C
              cwse last edited by

              Alright thanks. I filled all NaNs with '0' and issue seems to have resolved

              1 Reply Last reply Reply Quote 0
              • K
                kev last edited by

                I also ran into the the same bizarre situation today. Have you figured out something?

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