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



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



  • post whole script from the beginning to the end please.


Log in to reply
 

});