Appendix: Stock Screening
This appendix provides a stock screener tool that will allow you to put everything we have learned in this book into practice. It addresses the most pressing issue for market participants: idea generation. We will build a screener across all the constituents of the S&P 500 index.
The sequence of events is as follows:
- Download all the current constituents of the S&P 500 from its Wikipedia webpage.
- Batch download OHLCV prices data from Yahoo Finance. We will drop the level to process each stock individually.
- Calculate the rebased relative series.
- Calculate regimes—breakout, turtle, moving averages (Simple Moving Average (SMA) and Exponential Moving Average (EMA)), and floor/ceiling—on both absolute and relative series. There will be an option to save each stock as a CSV file.
- Create a dictionary with the last row of each stock and append a list, from which we will create a dataframe.
- Sum up...