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

Broker.getvalue() = nan?

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


  • administrators

    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)

  • @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)?

  • administrators

    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.

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

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

Log in to reply