Overall Statistics
Total Trades
0
Average Win
0%
Average Loss
0%
Compounding Annual Return
0%
Drawdown
0%
Expectancy
0
Net Profit
0%
Sharpe Ratio
0
Loss Rate
0%
Win Rate
0%
Profit-Loss Ratio
0
Alpha
0
Beta
0
Annual Standard Deviation
0
Annual Variance
0
Information Ratio
0
Tracking Error
0
Treynor Ratio
0
Total Fees
$0.00
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
            return
        # 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: