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 Probabilistic 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 ModulatedDynamicFlange(QCAlgorithm): def Initialize(self): self.SetStartDate(2019, 7, 12) # Set Start Date self.SetEndDate(2019, 7, 15) self.SetCash(100000) # Set Strategy Cash tickers = ["SPY" , "AAPL", "TSLA", "AMZN"] # Dictionary to hold our rolling windows self.data = {} for ticker in tickers: # Add minute equity data to our algorithm and save the symbol symbol = self.AddEquity(ticker, Resolution.Minute).Symbol # Store a instance of a rolling window for each symbol self.data[symbol] = RollingWindow[TradeBar](65) # Define a 30 minute consolidator for each symbol consolidator = TradeBarConsolidator(timedelta(minutes = 30)) # Add that consolidator to our symbol self.SubscriptionManager.AddConsolidator(ticker, consolidator) # Set OnConsolidated as our event handler for that consolidator consolidator.DataConsolidated += self.OnConsolidated # Every monday at market open we will do calculations on our data self.Schedule.On(self.DateRules.Every(DayOfWeek.Monday), self.TimeRules.AfterMarketOpen("SPY", 1), self.MakeCalculations) def OnConsolidated(self, sender, bar): self.Debug(bar.Symbol.Value + " thirty minute bar consolidated at " + str(bar.Time) + " with closing price " + str(bar.Close) ) # Store consolidated bar in corresponding rolling window self.data[bar.Symbol].Add(bar) def MakeCalculations(self): # If rolling windows not ready, we will wait until the next monday if not all([window.IsReady for window in self.data.values()]): return ## Our Calculations go here...