Picking Stocks with a Quantitative Momentum Strategy in Python
A simple yet useful method to optimize the process of choosing stocks
Disclaimer: This article is strictly for educational purposes and should not be taken as an investment tip.
Introduction
While I was an amateur trader, the process of choosing the right stocks to trade was a nightmare. News on stocks, uncertainty, and emotions adds to the bitterness of this process. A long way ahead, today, I found my own solution using my best companion Python. In this article, we are going to build a simple quantitative momentum strategy in python that filters and picks out the best intraday stocks. But wait, what is a quantitative momentum strategy?
A Quantitative Momentum strategy is a strategy implemented to choose stocks that have increased in price the most. Simply speaking, it is the process of identifying stocks with a great uptrend. Now that we have built some understanding of what quantitative momentum strategy is and how it can be used to pick stocks. Let’s implement the strategy in python!
Python Implementation
The steps involved in this article are:
- Importing the required packages- Extracting the list of all S&P 500 stock's symbols- Pulling Intraday data of all the stocks in the S&P 500- Calculating percentage change and momentum of all stocks- Finding stocks with greater momentum- Backtesting with a equal-weight portfolio
Step-1: Importing Packages
The primary packages of this article are the Pandas package to deal with data, the NumPy package to work with arrays, and the Requests package to pull data using an API. The secondary packages are going to be the Math package for mathematical functions, the SciPy package for complex functions, and the Statistics package for statistical functions.
Python Implementation: