Hi everyone,
I'm new to QuantConnect and I have read through the docs. I am trying to implement a basic strategy that filters stocks with the highest market cap and then perform analysis on them using technical indicators to get trade signals.
I have implemented the filter functions but I'm unsure of how to set up and update indicators like StandardDeviation(), EMA(), RSI() on the filtered equities (since this is usually done in the initialize method)
class FirstProject(QCAlgorithm):
def Initialize(self):
self.SetStartDate(2018, 1, 1)
self.SetEndDate(2018, 2, 1)
self.SetCash(10000)
self.AddUniverse(self.CoarseSelectionFunction, self.FineSelectionFunction)
self.UniverseSettings.Resolution = Resolution.Daily
#set up indicators?
self.symbols = []
def OnData(self, data):
#update indicators??
pass
def CoarseSelectionFunction(self, coarse):
self.symbols = [x.Symbol for x in coarse if x.HasFundamentalData and x.Price > 5]
return self.symbols
def FineSelectionFunction(self, fine):
market_cap = {}
for i in fine:
market_cap[i] = (i.EarningReports.BasicAverageShares.ThreeMonths *
i.EarningReports.BasicEPS.TwelveMonths *
i.ValuationRatios.PERatio)
sorted_market_cap = sorted([x for x in fine if market_cap[x] > 0], key=lambda x: market_cap[x], reverse=True)
self.symbols = sorted_market_cap[:10]
return self.symbols
Thanks!
Gage Riley Coon
I believe looking at the EMA bootcamp lesson again would help. Here they implement the 200 and 50 day EMA inside of the coarse filter to use technical indicators on their universe of stocks, I believe this is what you are trying to accomplish.
Gamer mazer
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!