Hello,

I am trying to develop uptick vs downtick based on stocks trading on NYSE.  I am trying to understand few things. I have shared my code and results as well.

Q1: Looking at the code  below, although the start date is 01/23/2019 - QC universe does not load into Slice until the following day. I have tested it with multiple date ranges and i encounter the same issue. Is there something i can do to rectify this?

Q2: I developed a coarse and fine filter, which returns around 1000 symbols. While doing backtesting, i believe everyday these symbols gets loaded into filter function, which inturn is returned to onData event. I need close prices of these stocks every minute to see if they are upticking or not. In doing so, i wonder, in order to speed up algo, is there anything other than not restricting the stocks. If you have an example, that would be good. Would restricting the universe filter function to run only once a week speed up backtesting speed of the algo? Is there a way for filter not to pass all the properties of the equity - there are around 900 properties from morning star available. 

Your thoughts are highly appreciated.

# Backtest inputs START_DATE = "01/23/2019" # must be in "MM/DD/YYYY" format END_DATE = "01/24/2019" # must be in "MM/DD/YYYY" format CASH = 100000 # starting portfolio value ################################################################################ # Import libraries required import clr clr.AddReference("System") clr.AddReference("QuantConnect.Algorithm") clr.AddReference("QuantConnect.Common") from System import * from QuantConnect import * from QuantConnect.Algorithm import * from QuantConnect.Data import * from QuantConnect.Data.Custom import * from QuantConnect.Data.Market import * from QuantConnect.Data.Consolidators import * from QuantConnect.Indicators import * from Selection.QC500UniverseSelectionModel import QC500UniverseSelectionModel from datetime import timedelta, datetime from System.Drawing import Color ################################################################################ class BasicTemplateAlgorithm(QCAlgorithm): def Initialize(self): # Setup the backtest # Set the start and end date (YYYY, MM, DD) start_split = START_DATE.split('/') self.SetStartDate(int(start_split[2]), int(start_split[0]), int(start_split[1])) end_split = END_DATE.split('/') self.SetEndDate(int(end_split[2]), int(end_split[0]), int(end_split[1])) # Set the starting equity amount self.SetCash(CASH) # Set the user time zone to be ET self.SetTimeZone(TimeZones.NewYork) # Define the brokerage model and account type self.SetBrokerageModel(BrokerageName.Default, AccountType.Margin) # Disable margin call model self.Portfolio.MarginCallModel = MarginCallModel.Null # Use the QC500 Universe self.AddUniverseSelection(QC500UniverseSelectionModel()) self.UniverseSettings.Resolution = Resolution.Minute # Add SPY for timing relative to open/close self.AddEquity("SPY") ################################################################################ def OnData(self, slice): """Event handler for new data.""" # Check for new minute bar if self.Time.microsecond == 0 and self.Time.second == 0: # Update McClellan Oscillator counter = 0 for stock in slice.Keys: # Use try/except block to handle possible future data in slice try: if self.Time.hour == 9 and (self.Time.minute == 30 or self.Time.minute == 31 ) and counter <= 10: self.Log('{} {} O:{} C:{} '.format(str(self.Time),str(stock),slice.Bars[stock].Open,slice.Bars[stock].Close)) counter = counter + 1 except: continue

 

2019-01-23 00:00:00 : Launching analysis for 214bbbb2374852945b231c4b84833069 with LEAN Engine v2.4.0.0.6113 2019-01-23 09:31:00 : 2019-01-23 09:31:00 SPY O:261.580210366 C:261.609934264 2019-01-24 09:31:00 : 2019-01-24 09:31:00 A RPTMYV3VC57P O:71.15758128 C:71.22728504 2019-01-24 09:31:00 : 2019-01-24 09:31:00 AA WF7IHVI76I5H O:28.15 C:28.05 2019-01-24 09:31:00 : 2019-01-24 09:31:00 AAL VM9RIYHM8ACL O:34.068531138 C:33.988978234 2019-01-24 09:31:00 : 2019-01-24 09:31:00 AAP SA48O8J43YAT O:164.685486045 C:164.37572025 2019-01-24 09:31:00 : 2019-01-24 09:31:00 AAPL R735QTJ8XC9X O:152.69477934 C:152.9526762 2019-01-24 09:31:00 : 2019-01-24 09:31:00 ABBV VCY032R250MD O:86.020359137 C:86.010638224 2019-01-24 09:31:00 : 2019-01-24 09:31:00 AAS R735QTJ8XC9X O:78.52610337 C:78.803370822 2019-01-24 09:31:00 : 2019-01-24 09:31:00 ABMD R735QTJ8XC9X O:337.5 C:339.54 2019-01-24 09:31:00 : 2019-01-24 09:31:00 ABT R735QTJ8XC9X O:69.454623 C:69.533999712 2019-01-24 09:31:00 : 2019-01-24 09:31:00 ADBE R735QTJ8XC9X O:245.62 C:244.24 2019-01-24 09:31:00 : 2019-01-24 09:31:00 ADI R735QTJ8XC9X O:89.632037927 C:90.759982769 2019-01-25 00:00:00 : Algorithm Id:(214bbbb2374852945b231c4b84833069) completed in 11.01 seconds at 19k data points per second. Processing total of 204,088 data points.