Algorithmic Trading Model for Simple Moving Average Crossover Grid Search

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 simple moving average (MA) models via a grid search methodology. 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.

The grid search methodology will search through all combinations between the two MA curves. 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. We will apply the analysis on the AMZN stock for the trading period between 2019-1-1 to 2020-06-15.

ANALYSIS: In this iteration, the top model of 20-day/50-day returned a net profit of $839.07. In the meantime, the long-only approach achieved an accumulated return of 1,079.82.

CONCLUSION: For this trading period, the trading strategy deployed using the SMA model failed to outperform the more straightforward long-only path. We should consider doing more modeling and more back-testing to validate the approach we wish to apply to the future trading period.

Dataset ML Model: Time series analysis with numerical attributes

Dataset Used: Quandl

The HTML formatted report can be found here on GitHub.