Hello all,

As the title suggests I am having difficulty creating a boolean condition inside OnData to check if a current bar represents the beginning of a new year compared to the previous bar

 

def OnData(self, data):

        if not self.Portfolio.Invested:    #initialise holdings at backtest start
            self.SetHoldings(self.vti, 0.3)

        if ' ' ' boolean to compare current datetime with previous bar datetime' ' ' :   
            self.SetHoldings(self.vti, 0.3)

 

 

Has anyone got an example of how to check this?

Thank you in advance