Overall Statistics
class Algorithm (QCAlgorithm):
    def Initialize(self):
        self.SetCash(1000000)
        self.SetStartDate(2014, 1, 1)
        self.SetEndDate(2014, 1, 6)
        self.SetBrokerageModel(BrokerageName.AlphaStreams)
        self.AddEquity("SPY", Resolution.Hour)
        
        self.shown = False
    
    def OnData(self, Data):
        # Ensure market is open before submitting any orders
        if not self.Securities['SPY'].Exchange.ExchangeOpen:
            return
        
        if self.Securities['SPY'].Invested:
            target = 0
        else:
            target = 1
        
        quantity = self.CalculateOrderQuantity("SPY", target)
        ticket = self.MarketOrder("SPY", quantity)
        self.Log(f"Fill: {ticket.AverageFillPrice}")