Algorithmic Trading Python

Simple Moving Average Long Strategy

First, we will load the python packages.
Previously we did two videos on LSTM long strategies – one using classification approach and one using regression approach. We seem to achieve a rather decent Sharpe ratio of about 0.9 for the LSTM regression long strategy. In this video, we shall demonstrate the traditional Simple Moving Average long strategy for comparison.
The first few steps are identical to my previous video, so I will not repeat it over here. For apple to apple comparison, we will backtest on the same MFST dataset.
We compute the simple moving average of 20 days. We define the signal for a long position if the previous Adj Close price is larger than the previous simple moving average, else the signal will be no position.
We compute the strategy returns and entry points similar to the previous video.
There are a lot more trades using the simple moving average strategy as compared to the LSTM strategies, We did a zoom in and we could see the buy and sell signals were consistent with the strategy.
If we compare the strategy returns and bnh returns, this strategy did not perform well. We got a Sharpe ratio of 0.56 and a max drawdown of 57% which were worse than the previous LSTM long regression strategy.

The code can be downloaded below
https://github.com/tertiarycourses/Algorithmic-Trading/blob/main/sma-long-strategy.ipynb

Recommended trading platforms

MooMoo https://j.moomoo.com/00i5px

Recommended courses on Algorithmic Trading

1. Basic Algorithmic Trading with Python
https://www.tertiarycourses.com.sg/python-algorithmic-trading-course.html https://www.tertiarycourses.com.my/python-quantitative-analysis-and-algorithmic-trading-malaysia.html
https://www.tertiarycourses.com.gh/python-quantitative-analysis-and-algorithmic-trading-ghana.html

2. Machine Learning for Algorithmic Trading
https://www.tertiarycourses.com.sg/machine-learning-for-algorithmic-trading.html https://www.tertiarycourses.com.my/machine-learning-for-algorithmic-trading-malaysia.html https://www.tertiarycourses.com.gh/machine-learning-for-algorithmic-trading-ghana.html

Other training courses from Tertiary Courses

https://www.tertiarycourses.com.sg/
https://www.tertiarycourses.com.my/
https://www.tertiarycourses.com.gh/

June 14, 2022