Hello! I am trying to transpose a code from Quantopian to QuantConnect but face difficulties with the header
from QuantConnect.pipeline import Pipeline
from QuantConnect.algorithm import attach_pipeline, pipeline_output
from QuantConnect.pipeline.data.builtin import USEquityPricing
from QuantConnect.pipeline.data import morningstar
from QuantConnect.pipeline.factors import SimpleMovingAverage, AverageDollarVolume
from QuantConnect.pipeline.filters.morningstar import IsPrimaryShare
and the following instruction
# Equities listed as common stock (as opposed to, say, preferred stock).
# 'ST00000001' indicates common stock.
common_stock = morningstar.share_class_reference.security_type.latest.eq('ST00000001')
Help is appreciated! Thank you.
Alexandre Catarino
Please checkout the docs, under Universes.
You can also find working examples in the University tab in the Algorithm Lab and the open-source project.
If you want to filter the universe to find only common stock, you should use:
filtered = [x for x in fine if x.SecurityReference.SecurityType == 'ST00000001']
in the selector method:
# sort the data by P/E ratio and take the top 'NumberOfSymbolsFine' def FineSelectionFunction(self, fine): # only use common stock (ST00000001) filtered = [x for x in fine if x.SecurityReference.SecurityType == 'ST00000001'] # sort descending by P/E ratio sortedByPeRatio = sorted(filtered, key=lambda x: x.ValuationRatios.PERatio, reverse=True) # take the top entries from our sorted collection return [ x.Symbol for x in sortedByPeRatio[:self.__numberOfSymbolsFine] ]
Skyfold
Thank you very much Alexandre for your support. I will look attentively to the provided documentation.
Ruslan
Any updates on the algorithm?
It just so happens that I am trying to convert the same one, so feel free to let me know if there are any areas you need help with.
Chris Buckley
You guys ever finish converting this algorithm?? ive been hitting nothing but roadblocks :/
Skyfold
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!