Tag: mean reversion

# Algorithmic Trading Model for Mean-Reversion with RSI Exit Signal for an Individual Stock Using Python

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: This project aims to construct and test an algorithmic trading model and document the end-to-end steps using a template.

INTRODUCTION: This algorithmic trading model compares a simple mean-reversion strategy with or without using RSI as the exit signal for an individual stock. The model will use a trend window size of ten days for long trades only. When the 14-day RSI value reaches 70, the model will exit the long position.

ANALYSIS: In this modeling iteration, we analyzed the stock of AAPL (Apple Inc.) between January 1, 2016, and July 19, 2021. The mean-reversion model without using RSI produced a profit of 3.59 dollars per share, while the model with RSI signals returned 45.97. In addition, the buy-and-hold approach yielded a gain of 118.09 dollars per share.

CONCLUSION: For the AAPL stock during the modeling time frame, the long-only trading strategy with or without RSI as the exit signal did not produce a better return than the buy-and-hold approach. We should consider experimenting with more variations of the strategy.

Dataset ML Model: Time series analysis with numerical attributes

Dataset Used: Quandl

The HTML formatted report can be found here on GitHub.

# Algorithmic Trading Model for Mean-Reversion vs. Trend-Following Strategy for a Group of Stocks Using Python

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: This project aims to construct and test an algorithmic trading model and document the end-to-end steps using a template.

INTRODUCTION: This algorithmic trading model compares a simple mean-reversion and trend-following strategy for a group of stocks. The model will use a trend window size of ten days for long trades only.

ANALYSIS: In this modeling iteration, we analyzed ten stocks between January 1, 2016, and July 9, 2021. The models’ performance appeared at the end of the script.

CONCLUSION: For all the stocks during the modeling time frame, the long-only trading strategy with either mean-reversion or trend-following approach did not produce a better return than the buy-and-hold approach, except for LUV and PFE. We should consider modeling these stocks further by experimenting with more variations of the strategy.

Dataset ML Model: Time series analysis with numerical attributes

Dataset Used: Quandl

The HTML formatted report can be found here on GitHub.

# Algorithmic Trading Model for Mean-Reversion vs. Trend-Following Strategy for an Individual Stock Using Python

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: This project aims to construct and test an algorithmic trading model and document the end-to-end steps using a template.

INTRODUCTION: This algorithmic trading model compares a simple mean-reversion strategy with a trend-following for a single stock. The model will use a trend window size of ten days for long trades only.

ANALYSIS: In this modeling iteration, we analyzed the stock prices for Costco Wholesale (COST) between January 1, 2016, and July 9, 2021. The mean-reversion model produced a profit of 101.20 dollars per share, while the trend-following model returned a profit of 154.21. The buy-and-hold approach yielded a gain of 248.74 dollars per share.

CONCLUSION: For the COST stock during the modeling time frame, the long-only trading strategy with either mean-reversion or trend-following approach did not produce a better return than the buy-and-hold approach. We should consider modeling this stock further by experimenting with more variations of the strategy.

Dataset ML Model: Time series analysis with numerical attributes

Dataset Used: Quandl

The HTML formatted report can be found here on GitHub.

# Algorithmic Trading Model for Mean-Reversion with Relative Strength Indicator Using Python Take 4

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: This project aims 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 simple mean-reversion strategy for a stock. The model enters a position when the price reaches either the upper or lower Relative Strength Indicator thresholds for the last X number of days. The model will exit the trade when the stock price crosses the upper or the lower RSI line for the same window size.

In iteration Take1, we set up the models using an RSI window size for long trades only. The window size varied from 10 to 50 trading days at a 5-day increment.

In iteration Take2, we set up the models using an RSI window size for long and short trades. The window size varied from 10 to 50 trading days at a 5-day increment.

In iteration Take3, we set up the models using an RSI window size for long trades only. The window size varied from 10 to 50 trading days at a 5-day increment. In addition, we varied the upper and lower RSI thresholds to examine their effects on the return.

In this Take4 iteration, we will set up the models using an RSI window size for long and short trades. The window size will vary from 10 to 50 trading days at a 5-day increment. In addition, we will vary the upper and lower RSI thresholds to examine their effects on the return.

ANALYSIS: In iteration Take1, we analyzed the stock prices for Costco Wholesale (COST) between January 1, 2016, and April 23, 2021. The top trading model produced a profit of 143.51 dollars per share. The buy-and-hold approach yielded a gain of 211.45 dollars per share.

In iteration Take2, we analyzed the stock prices for Costco Wholesale (COST) between January 1, 2016, and April 23, 2021. The top trading model produced a profit of 51.19 dollars per share. The buy-and-hold approach yielded a gain of 211.45 dollars per share.

In this Take3 iteration, we analyzed the stock prices for Costco Wholesale (COST) between January 1, 2016, and April 23, 2021. The top trading model produced a profit of 143.51 dollars per share. The buy-and-hold approach yielded a gain of 211.45 dollars per share.

In this Take4 iteration, we analyzed the stock prices for Costco Wholesale (COST) between January 1, 2016, and April 23, 2021. The top trading model produced a profit of 51.19 dollars per share. The buy-and-hold approach yielded a gain of 211.45 dollars per share.

CONCLUSION: For the stock of COST during the modeling time frame, the long-and-short with variable RSI thresholds trading strategy did not produce a better return than the buy-and-hold approach. We should consider modeling this stock further by experimenting with more variations of the strategy.

Dataset ML Model: Time series analysis with numerical attributes

Dataset Used: Quandl

The HTML formatted report can be found here on GitHub.

# Algorithmic Trading Model for Mean-Reversion with Relative Strength Indicator Using Python Take 3

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: This project aims 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 simple mean-reversion strategy for a stock. The model enters a position when the price reaches either the upper or lower Relative Strength Indicator thresholds for the last X number of days. The model will exit the trade when the stock price crosses the upper or the lower RSI line for the same window size.

In iteration Take1, we set up the models using an RSI window size for long trades only. The window size varied from 10 to 50 trading days at a 5-day increment.

In iteration Take2, we set up the models using an RSI window size for long and short trades. The window size varied from 10 to 50 trading days at a 5-day increment.

In this Take2 iteration, we will set up the models using an RSI window size for long trades only. The window size will vary from 10 to 50 trading days at a 5-day increment. In addition, we will vary the upper and lower RSI thresholds to examine their effects on the return.

ANALYSIS: In iteration Take1, we analyzed the stock prices for Costco Wholesale (COST) between January 1, 2016, and April 23, 2021. The top trading model produced a profit of 143.51 dollars per share. The buy-and-hold approach yielded a gain of 211.45 dollars per share.

In iteration Take2, we analyzed the stock prices for Costco Wholesale (COST) between January 1, 2016, and April 23, 2021. The top trading model produced a profit of 51.19 dollars per share. The buy-and-hold approach yielded a gain of 211.45 dollars per share.

In this Take3 iteration, we analyzed the stock prices for Costco Wholesale (COST) between January 1, 2016, and April 23, 2021. The top trading model produced a profit of 143.51 dollars per share. The buy-and-hold approach yielded a gain of 211.45 dollars per share.

CONCLUSION: For the stock of COST during the modeling time frame, the long-only with variable RSI thresholds trading strategy did not produce a better return than the buy-and-hold approach. We should consider modeling this stock further by experimenting with more variations of the strategy.

Dataset ML Model: Time series analysis with numerical attributes

Dataset Used: Quandl

The HTML formatted report can be found here on GitHub.