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
class ModulatedNadionAutosequencers(QCAlgorithm):

    def Initialize(self):
        self.SetStartDate(2019, 1, 16)  # Set Start Date
        self.SetEndDate(2019, 1, 26)
        self.SetCash(100000)  # Set Strategy Cash
        self.AddEquity("SPY", Resolution.Minute)
        
        consolidator = TradeBarConsolidator(1)
        consolidator.DataConsolidated += self.OnDailyDataConsolidated
        self.SubscriptionManager.AddConsolidator("SPY", consolidator)
        
        # boolean: if Daily Open Price ready to get
        self.isOpen = True
        # current date of backtest
        self.currDate = f"{self.Time.year}-{self.Time.month}-{self.Time.day}"

    def OnData(self, data):
        # is open price ready to get
        if self.isOpen:
            self.Open = data["SPY"].Open
            self.isOpen = False
            self.Log(f"{self.Time} > Daily Open Price: {self.Open}")
            
    def OnDailyDataConsolidated(self, sender, bar):
        if self.currDate != f'{self.Time.year}-{self.Time.month}-{self.Time.day}':
            # next day has come, update current date
            self.currDate = f'{self.Time.year}-{self.Time.month}-{self.Time.day}'
            # since this is the next day, so ready to get market open price
            self.isOpen = True