Hi everyone!
Loving QuantConnect so far but having a lot of trouble converting my old algos from Quantopian over.
1: What can I replace all these inputs with?
2: What's happening here? Getting a build error "Sorry, open( is not whitelisted within QuantConnect. Remove this from your project."
Jing Wu
1) The similar "pipeline" in LEAN is the universe selection. Please see the documentation. You can filter stocks by dollar volume in coarse universe selection. In fine universe selection, you can use thousand of fundamental factors from Morningstar. For example
def Initialize(self):
# what resolution should the data *added* to the universe be?
self.UniverseSettings.Resolution = Resolution.Daily
# this add universe method accepts two parameters:
# - coarse selection function: accepts an IEnumerable<CoarseFundamental> and returns an IEnumerable<Symbol>
# - fine selection function: accepts an IEnumerable<FineFundamental> and returns an IEnumerable<Symbol>
self.AddUniverse(self.CoarseSelectionFunction, self.FineSelectionFunction)
# sort the data by daily dollar volume and take the top 'NumberOfSymbols'
def CoarseSelectionFunction(self, coarse):
# sort descending by daily dollar volume
sortedByDollarVolume = sorted(coarse, key=lambda x: x.DollarVolume, reverse=True)
# return the symbol objects of the top entries from our sorted collection
return [ x.Symbol for x in sortedByDollarVolume[:10]]
# sort the data by "IsPrimaryShare"
def FineSelectionFunction(self, fine):
filteredFine = [x.Symbol for x in fine if x.SecurityReference.IsPrimaryShare]
return filteredFine
This python example is available on GitHub UniverseSelectionAlgorithm.py .
To filter stocks with an indicator like Moving Average, please refer to this example EmaCrossUniverseSelectionAlgorithm.py
You should probably start on this thread and converting-algos-from-quantopian where we're breaking it down feature by feature to help you migrate.
2) To schedule an event to fire every day after market open, you can use the method
self.Schedule.On(self.DateRules.EveryDay("SPY"), self.TimeRules.AfterMarketOpen("SPY", 10), self.EveryDayAfterMarketOpen)
Here is an example of schedule event API.
Jared Broad
Welcome to QC!
#2 - We use a slightly different API here for scheduled events - please see these examples & docs :)
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.
Diego Bennett
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!