Overall Statistics
import numpy as np
import datetime
import decimal as d
import json
class BasicTemplateAlgorithm(QCAlgorithm):

    def Initialize(self):
        '''Initialise the data and resolution required'''

        self.SetStartDate(2018,10,1)  #Set Start Date
        self.SetEndDate(2019,1,31)    #Set End Date
        #self.SetWarmUp(timedelta(50)) # set warmup in days
        self.SetCash(100000)           #Set Strategy Cash
        self.SetBrokerageModel(BrokerageName.InteractiveBrokersBrokerage) #optional
        self.SetBenchmark('SPY')

        sym = 'SPY'
        self.AddEquity(sym, Resolution.Minute)
        self.myRSI = self.RSI(sym, 14, Resolution.Daily)


        # Schedule trades
        self.Schedule.On(self.DateRules.EveryDay('SPY'), \
                 self.TimeRules.BeforeMarketClose('SPY', 12), \
                 Action(self.Trade))


        self.Log("end init")
    
    #def OnData(self, data):
    #    self.Log("OD: "+ str(self.Time)+" : "+str(self.myRSI.Current.Value))

    def Trade(self):
        prc = self.Securities['SPY'].Price
        self.Log("PM: "+ str(self.Time)+" : "+str(prc)+" : "+str(self.myRSI.Current.Value))

    def OnEndOfDay(self):
        prc = self.Securities['SPY'].Price
        self.Log("EOD: "+ str(self.Time)+" : "+str(prc)+" : "+ str(self.myRSI.Current.Value))