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, 5, 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")
        
        ## define our 1 week trade bar consolidator. we can
        # access the 1 week bar from the DataConsolidated events
        #self.Schedule.On(self.DateRules.Every(DayOfWeek.Monday), self.TimeRules.AfterMarketOpen("SPY", 5), Action(self.startOfWeek))
        #self.Schedule.On(self.DateRules.Every(DayOfWeek.Friday), self.TimeRules.BeforeMarketClose("SPY", 5), Action(self.endOfWeek))
        oneWeekConsolidator = TradeBarConsolidator(timedelta(days=5))
        oneWeekConsolidator.DataConsolidated += self.OneWeekBarHandler
        self.SubscriptionManager.AddConsolidator("SPY", oneWeekConsolidator)
        
        
        
    def OneWeekBarHandler(self, sender, bar):
        self.Debug(str(self.Time) + " " + str(bar))
    
        
        
    def startOfWeek(self):
        hist = self.History(self.symbol_, 1, self.OneWeekBarHandler)##########################
        self.prev_high = max(hist['high'])
        self.prev_low = min(hist['low'])
        
        
    #if self.log:
        #self.Log('L: {0} H: {1} C: {2}'.format( str(prev_low), str(prev_high), str(current)))