Overall Statistics
import numpy as np
import pandas as pd


class MyAlgo(QCAlgorithm):
    
    
    def Initialize(self):

        self.SetCash(100000)
        # Start and end dates for the backtest.
        self.SetStartDate(2019,9,1)
        self.SetEndDate(2019,9,15)
        
        self.spy = self.AddEquity("SPY", Resolution.Minute).Symbol

        # Schedule (3:59pm)
        self.Schedule.On(self.DateRules.EveryDay("SPY"), \
                        self.TimeRules.At(15, 39), \
                        Action(self.rebalance))
    
    
    def OnData(self, data):
        pass


    def rebalance(self):

        # History (Hourly)
        history = self.History(self.spy, 90, Resolution.Hour)
        spy_history = history['close'].unstack(level=0)
        
        self.Debug(str(self.Time) + " Getting Hourly SPY: " + '\n'+ str(spy_history.tail()))
        
        # History (Minute)
        min_history = self.History(self.spy, 10, Resolution.Minute)
        spy_min = min_history['close'].unstack(level=0)
        current_spy = spy_min.iloc[-1] 
        
        self.Debug(str(self.Time) + " Getting Minute SPY: " + '\n'+ str(spy_min.tail()))
        self.Debug(str(self.Time) + " Current SPY: " + '\n'+ str(current_spy))