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/

    Getting stuck in calculating average turnover

    General Code/Help
    2
    2
    44
    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.
    • N
      Niranjan Godbole last edited by

      Trying to calculate average turnover

      def __init__(self):
              self.addminperiod(260)
              self.stocks = self.datas[2:]
      
              for d in self.stocks:
                  self.inds[d] = {}
                  turnover = d.close * d.volume
                  print (d.open[0],d.high[0],d.low[0],d.close[0],d.volume[0], d.openinterest[0])
                  self.inds[d]["avg_turnover"] = bt.indicators.SimpleMovingAverage(turnover,period=20)
      

      ohlcv data is printed correctly

      In next function, when i try to print average turnover print(self.inds[d]["avg_turnover"][0]) , I am getting nan as output.. expecting average turnover.

      Any pointers would be very useful.

      1 Reply Last reply Reply Quote 0
      • A
        ab_trader last edited by

        post whole script from the beginning to the end please.

        1 Reply Last reply Reply Quote 1
        • 1 / 1
        • First post
          Last post
        Copyright © 2016, 2017, 2018 NodeBB Forums | Contributors
        $(document).ready(function () { app.coldLoad(); }); }