Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
auto pick stocks filter

Guys, I need help!

I have a code but i have selected the 5 individual stocks to trade. But now i want the code to autoselect 5 stocks with a low P/E rato. how can i do that? how can i code it to select e.g. US market or from NYSE stocks only. Is there any filter?

thank you

1 response

Attached is a simple algorithm to get you started. It buys five securities with the highest PE ratios on the NYSE each month (and sells any other positions).

Take a look at the documentation for how to set up pipelines https://www.quantopian.com/tutorials/pipeline

The first step is to define a pipeline to get all the data you need and perhaps filter to a subset of securities based on that data. In this case I used the fundamental data "valuation_ratios.pe_ratio" and "share_class_reference.exchange_id" from Morningstar (see https://www.quantopian.com/data/morningstar/fundamentals the available fields are here https://www.quantopian.com/help/fundamentals )

The second step is to run the pipeline (typically in the "before_trading_start" function) which then gets the data and applies any filters you have defined.

Finally, use that data to place your orders.

Take a look at https://www.quantopian.com/data for all the available data you have at your disposal. Individual fields in those datasets can easily be made into factors to use in your pipeline. Simply use the ".latest" method (see https://www.quantopian.com/help#sample-earnings-risk for an example)

Good luck.