Tag: mean reversion

Algorithmic Trading Model for Mean-Reversion with MACD Signals 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 employs a simple mean-reversion strategy using the Moving Average Convergence/Divergence (MACD) indicator as the entry and exit signals. The model will use a 26-period Exponential Moving Average (EMA), a 12-period EMA, and a nine-period EMA as the signal line for long trades only. The model will initiate a long position when the long EMA line crosses the signal line from below. Conversely, the model will exit the long position when the long EMA line crosses the signal line from above.

ANALYSIS: In this modeling iteration, we analyzed ten stocks between August 1, 2016, and August 27, 2021. The models’ performance appeared at the end of the script. Also, the models without stop-loss produced a better return six out of the ten stocks. Moreover, the simple buy-and-hold approach came out ahead for all stocks except one.

CONCLUSION: For most stocks during the modeling time frame, the long-only trading strategy with MACD signals did not produce a better return than the buy-and-hold approach. 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 with Bollinger Bands and Stop Loss Signals 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 employs a simple mean-reversion strategy using the Bollinger Bands as the entry and exit signals. The model will use a trend window size of 20 days for long trades only. When the stock price reaches the lower band, the model will initiate a long position. Conversely, the model will exit that long position when the stock price reaches the upper band. In addition, the model will also generate an exit signal when the holding reaches a 10% loss at the end of the day. Finally, we will compare two models where one model has a 10% stop-loss limit while the other does not.

ANALYSIS: In this modeling iteration, we analyzed ten stocks between January 1, 2016, and August 6, 2021. The models’ performance appeared at the end of the script. Also, the models without stop-loss produced a better return six out of the ten stocks. Moreover, the simple buy-and-hold approach came out ahead for all stocks except one.

CONCLUSION: For most stocks during the modeling time frame, the long-only trading strategy with Bollinger Bands did not produce a better return than the buy-and-hold approach. 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 with RSI Exit and Stop Loss Signals 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 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. In addition, the model will also generate an exit signal when the holding reaches a 10% loss at the end of the day.

ANALYSIS: In this modeling iteration, we analyzed 15 stocks between January 1, 2016, and July 30, 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 or without RSI as the exit signal did not produce a better return than the buy-and-hold approach, except for F. 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 with RSI Exit and Stop Loss Signals 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. In addition, the model will also generate an exit signal when the holding reaches a 10% loss at the end of the day.

ANALYSIS: In this modeling iteration, we analyzed the stock of AAPL (Apple Inc.) between January 1, 2016, and July 30, 2021. The mean-reversion model without using RSI produced a gain of 26.90% per share, while the model with RSI signals returned a profit of 121.95%. In addition, the buy-and-hold approach yielded an increase of 462.84% 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 with RSI Exit Signal 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 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 14 stocks between January 1, 2016, and July 16, 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 or without RSI as the exit signal did not produce a better return than the buy-and-hold approach, except for NFLX. 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.