Overall Statistics
from datetime import timedelta
import math

class MHAS(QCAlgorithm):

    def Initialize(self):
        self.SetStartDate(2019, 3, 1) # Set Start Date 
        self.SetEndDate(2019, 3, 29) # Set End Date
        self.SetCash(100000)  # Set Strategy Cash
        # subscribe SPY with minute level resolution
        self.AddEquity("SPY", Resolution.Daily)
        self.symbol_ = self.Symbol("SPY")
        self.Schedule.On(self.DateRules.Every(DayOfWeek.Saturday), self.TimeRules.At(0, 1), Action(self.endOfWeek))
    def endOfWeek(self):
        # request data from last week
        hist = self.History(self.symbol_, timedelta(weeks = 1))
        if hist.empty:
            # should only happen when data is broken
        # build weekly bar
        high_price = max(hist['high'])
        low_price = min(hist['low'])
        open_price = hist['open'][0]
        close_price = hist['close'][len(hist.index) - 1]
        # reminder: logging price is limited to debugging purpose. Logging a bulk of data is against our term of use!
        self.Log(f"consolidated time: {self.Time}, open: {open_price}, high: {high_price}, low: {low_price}, close: {close_price}")
        # your strategy could be here: