I am trying to simply view a list of the symbols that are present in my universe each day, 15 minutes after market open. I have attached the code I have used below. For some reason whatever I do I am usually faced with the following error: "Runtime Error: TypeError : object is not callable TypeError : object is not callable". Any ideas on how to solve this?
class BasicTemplateFrameworkAlgorithm(QCAlgorithm):
def Initialize(self):
self.UniverseSettings.Resolution = Resolution.Daily
self.AddEquity("SPY")
self.SetStartDate(2013,10,7) #Set Start Date
self.SetEndDate(2013,10,11) #Set End Date
self.SetCash(100000) #Set Strategy Cash
self.AddUniverse(self.Universe.DollarVolume.Top(50))
self.Schedule.On(self.DateRules.EveryDay("SPY"), self.TimeRules.AfterMarketOpen("SPY", 15), self.ViewUniverse)
def ViewUniverse(self):
for universe in self.UniverseManager.Values:
if universe is UserDefinedUniverse:
continue
symbols = universe.Members.Keys
symbol_list = []
for symbol in symbols:
symbol_list.append(symbol)
self.Log(symbol_list)
Gurumeher Sawhney
Thanks for sending the code! After using self.Debug it looks like the universe trying to be called is empty. When calling AddUniverse, a function should be called to select the desired symbols. In the code above self.Universe.DollarVolume.Top(50) is not doing anything. DollarVolume is a property of coarse universe selection so that would need to be called in order to filter using that property. The sample code below will show an implementation that receives the top 5 stocks by dollar volume. To receive 50, the source code can be copy/pasted and change self.__numberOfSymbols to 50 instead.
Ben stelzer
Thanks!
Gurumeher Sawhney
Just an update: self.AddUniverse(self.Universe.DollarVolume.Top(50)) should have worked but there seems to be a bug. We are looking into it now but in the meantime the above solution is a good substitute.
Ben stelzer
The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
To unlock posting to the community forums please complete at least 30% of Boot Camp.
You can continue your Boot Camp training progress from the terminal. We hope to see you in the community soon!