Skip to main content

A simple quantified strategy enhanced

Today I came across the following post: When SPY Falls 2 Times More Than Average Change on the Quantified Strategies blog by Oddmund Grotte. As I am looking for a more quantified approach for my investing / trading, I decided to do a back test on the strategy explained in the post. The strategy is as follows:

  • We calculate the 25 day moving average of the absolute value of the daily differences.
  • When the SPY moves down by more then 2 times the calculated moving average, we go long on the close.
  • We exit again on the next days close.
So this is a nice reversion to the mean strategy. It basically takes advantage of the fact that prices never move in a straight line, but rather move up and down around a certain average price. When price has moved away to far from the average, there is a higher probability that the price will move back to the mean.

My back test achieved about the same result as Oddmund's. Then I enhanced it a little bit by filtering out entry days that on average seem to be losing days. Like Oddmund I also found that entering on Thursday closes reduces the total return of the strategy. So I filtered these out.

We therefore should add to the strategy:
  • No entries on Thursday closes
Here is my back test result. I added the S&P500 cumulative daily differences for comparison.
SPY Strategy
As you can see the strategy is pretty stable. There are no large draw downs (visually). In fact, it looks like it is performing best when the index is in general moving down. Also this strategy took 148 trades in 8+ years. That is roughly 18 trades per year or 1 trade every three weeks. However the strategy is not clearly out performing a simple buy and hold strategy. If you would have bought an ETF on the SPY you would be up 63%, while the strategy would have made you 49%. Of course, the strategy does not tie up your money like a buy and hold strategy. So with this strategy you could put your money to work using other strategies.

Still, it would be nice if the strategy could, by itself, outperform a buy and hold approach, so I tried to optimize it. I found, that by going long every time the SPY moves down by more than 1 time the moving average, the performance improves substantially.

SPY Strategy enhanced
Notice that the total return (P&L) moved up from 49% to 85%. At the same time the sharpe ratio is only slightly lower (1.12 i/o 1.17). "So were is the catch?", you might say. Well, this back test took more then double the amount of trades, 388 in total. This calculates back to about 48 trades per year or about 1 trade every week. So the extra performance comes at the cost of trading more actively, which will also lead to higher transaction costs and to having our money tied up in a trade more often.

To get a feel for the long term perspective of this strategy, I did the same back tests on data from 1993 until now. Again setting the "price move down" parameter to 1 seems to give better performance. The total return even doubles and the sharpe ratio also gets better.

SPY Strategy back test since 1993

SPY Strategy enhanced back test since 1993
The question now is: can anyone do this for about 20 years; checking the close price daily, calculate, place orders and exit trades? It would be great if we could automate this process, so the execution of the strategy will take little to no time. At the same time we could do the same for other strategies, building a dynamic portfolio. This is something I will be working towards.

And then there is leverage. Imagine executing this strategy (and others) with about 1 to 10 leverage. This would possibly enlarge the total return by a factor of 10 (minus extra cost for leverage). Before even considering this, I want to investigate the strategy more by figuring out the max draw down, the win - loose rate, optimal position sizing, etc. Because if there is a draw down of 10% and we are leveraged 1 to 10 with our full account, we are out of the game.

I am thinking that if I can combine this strategy with others, automate the process and use just a small amount of leverage, I will be well on my way in becoming financially independent.

Popular posts from this blog

How to install Google Drive Sync on Ubuntu 16.04 and higher

Google drive is one of the many handy tools Google offers. It is a file synchronization tool that allows you to backup, store and share and access files in the cloud. I use it to collaborate on files with others or to sync movies that I can then easily publish on Youtube.

Unfortunately there is no native Google drive software for Linux Desktops. Luckily there is a way to have a proper sync setup on Ubuntu 16.04 and higher that uses the Google drive API and some Gui tools. Let me show you how I have this installed on my Ubuntu Desktop.

First I install the Grive2 commandline tool:

sudo add-apt-repository ppa:nilarimogard/webupd8
sudo apt-get update
sudo apt-get install grive

No need to set it up right now. Instead let's first install grive-tools. This is a package that is only available up to Ununtu Vivid, but I have found that is works just the same on Ubuntu 16.04
Run the following from a terminal:

sudo su -c "nano /etc/apt/sources.list.d/thefanclub*.list"
deb http://ppa.lau…

How to back test a manually traded strategy using TradingView

Trading is hard. It takes a lot of practice. One way to practice and build skill and confidence is to back test a system over and over again. In this video I show you how I do this using online charts at Tradingview.

Tools of the trade

In this article I will tell you about the possible tools you have at your disposal for trading. Whether you are building a fence, or building a trading strategy, you need tools to get the work done. In the previous articles we already looked at the question of why, how, what and where to trade. Now it is time to get some tools and setup an infrastructure for trading. We basically need three types of tools.