Algorithmic Trading Model for Combo Moving Average Crossover Grid Search Take 1

NOTE: This script is for learning purposes only and does not constitute a recommendation for buying or selling any stock mentioned in this script.

SUMMARY: The purpose of this project is to construct and test an algorithmic trading model and document the end-to-end steps using a template.

INTRODUCTION: This algorithmic trading model examines a series of exponential and simple moving average (MA) crossover models via a grid search methodology. This iteration of the modeling will focus on applying a trend-following or a momentum-oriented approach. When the fast moving-average curve crosses above the slow moving-average curve, the strategy goes long (buys) on the stock. When the opposite occurs, we will exit the position.

For this Take1 iteration, the grid search script will search through all combinations between the two sets of MA curves, simple and exponential. The faster MA curve can range from 5 days to 20 days, while the slower MA can range from 10 days to 50 days. Both curves use a 5-day increment.

ANALYSIS: For this Take1 iteration, we analyzed the stock prices for Apple Inc. (AAPL) between January 1, 2019 and August 3, 2020. The best simple MA model with 10-day and 20-day produced a profit of 284.11 per share. The best exponential MA model with 5-day and 20-day produced a gain of 280.73. The long-only approach yielded a profit of 280.86 per share.

CONCLUSION: For this dataset and period, the simple moving average curves of ten days and 20 days seem to produce the best profit level. However, the buying-and-holding approach is almost as profitable without too much fuss.

Dataset ML Model: Time series analysis with numerical attributes

Dataset Used: Quandl

The HTML formatted report can be found here on GitHub.