Hi All,

I am new here. When I applied the simple strategy, it pops up below error. Could anyone help? Thanks a lot.

Best Regards,

Yao Yiyang

Code:

import numpy as np
import datetime

class SellInMayBuyInNov(QCAlgorithm):
    def Initialize(self):
        self.SetStartDate(1998,1, 1)  #Set Start Date
        self.SetEndDate(2019,2,1)    #Set End Date
        self.SetCash(1000000)           #Set Strategy Cash
        # Find more symbols here: http://quantconnect.com/data
        self.AddEquity("SPY", Resolution.Minute,Leverage=4,fillDataForward = True, extendedMarketHours = False)
        self.SetRunMode(RunMode.Series)
        

    def OnData(self, data):
        if self.Time.month == 5:
            if self.Portfolio.Invested:
                self.SetHoldings("SPY", -Qty)
                self.Debug("Sell In May" + Time.year  +" Quantity:"+Qty)
        elif self.Time.month  == 11:
            if not self.Portfolio.Invested:
                Qty= self.Portfolio.Cash/["SPY"].Close
                self.SetHoldings("SPY", Qty)
                self.Debug("Buy In Nov" + Time.year+" Quantity:"+Qty)

66512_1550148042.jpg