Progress Update 11
Interesting progress was made this week. I fixed my coding problem with the interactions between all the algorithm models that I discussed in the last update which allowed me to see the results of importing my strategy I created in TradingView's PineScript way back in Progress Update 3. I read a lot more of my book, Conquering The Seven Faces of Risk by Scott Juds learning about strategies like differential signal processing between multiple assets to pick the "fastest horse".
Starting with what I did in QuantConnect this week. I fixed my code to make my algorithm execute versus running into Python runtime errors where I couldn't even see if my trading strategy was working or not. Despite talking about my usage of several models in my previous blog update, I decided to eliminate the complicated multi-model setup to just do everything in one model mostly inside the OnData() method. I did this because I was taking way too long trying to figure out how to program it the nice and neat way of using multiple models. And it wasn't like that strategy was anything super fancy so in my efforts of trying to use multiple models to make parts of my algorithm reusable for other algorithms, I was actually over-complicating things.
Anyways, doing everything in one model allowed me to see how my strategy would turn out. To put it bluntly, it performed horribly. Below is a screenshot of the same settings as the TradingView strategy but with a trailing stop of 1% and a starting balance of $100k. You can see the total trading volume and total fees paid are astronomically high relative to total equity.
I tried messing with several of the settings only to come to the conclusion that the picture above was the best I got it. One of the worst back-tests looks like the picture below. This had the same settings as above except with no trailing stop, $10k starting balance, and my poor attempt at implementing my own fee model trying my best to replicate what I accounted for on TradingView, $0.01/contract fee.
In my efforts of trying to replicate what I made in TradingView in a different coding language that had different quirks than QuantConnect and Python, I came to the quick conclusion that I should scrap it because of three reasons:
- The strategy was over-trading (which I was well aware of) and QuantConnect has a different fee structure than what I programmed into TradingView
- There is the possibility that that back-test on TradingView was significantly over-fitted.
- I go back to college in less than two weeks now and progress on this goal of mine to create a trading bot will be significantly slowed due to my shift in focus towards school-work.
You can look at both pictures above and instantly recognize that the algorithm was over-trading by looking at the total trading volume in the selected period of 32.5 years. You could look at those pictures and come to the conclusion that the algorithm makes ~177 trades per year in the first picture ($575M in volume / 32.5 years = ~$17.7M in yearly volume / $100k starting balance = ~177 trades of $100k per trade). But in reality, a good chunk of time was spent with total equity below $100k. In reference to the first picture, you can see that the only saving grace that it had was that it caught the COVID 2020 crash.
Then, you can also see in both pictures that the sheer presence of the parameters that I had in the TradingView strategy makes it likely that I am over-fitting my back-tests. Over-fitting back-tests isn't just a QuantConnect thing, it is also explained in Conquering The Seven Faces of Risk as "Back-testing deception". This is where you are using previous commonly-known variables to 100% depend on to predict what is going to happen next. Over-fitting your back-test makes your back-test look like sunshine and rainbows, but when you forward-test, it could turn out in the worst way possible.
Lastly, I go back to college in less than 2 weeks. I won't have the amount of time that I have now to work on my personal summer projects. So I want to make as much progress as I can and I won't be able to do so if I am obsessing over a potentially terrible trading strategy.
So with all that said, I am moving onto starting another algorithm project on QuantConnect that I am calling the "Fastest Horse". I plan on doing this one the right way with a multi-model development path. Using all of the models I mentioned in the previous blog update. I started today (as of writing this) and I have already completed the guts of the Universe Selection model to have the algorithm pick ETFs for me that are very liquid and have good momentum.
This new "Fastest Horse" algorithm is based on Scott Juds' "differential signal processing" which uses tools such as momentum crossovers to determine which asset has the most momentum out of the bunch at a select point in time. This will make your equity curve look like a Frankenstein equity curve which is comprised of the biggest moves from a wide selection of assets. Below is a picture of such an equity curve that I created on a free trial of Scott Juds' SectorSurfer.
Now in this test strategy, I am clearly not using ETFs but simply showing what I meant by using the best moves from every asset that you selected. You can see on the left assets I personally picked which all have different colors. You can then see in the equity curve, which upswings are from what asset.
The reason I am choosing (for now) to only have my algorithm pick from a basket of ETFs, is that ETFs don't carry the risks involved in a single stock such as the company filing for bankruptcy or other bad news that can cause too fast a crash for my algorithm to dodge. Also, picking from a basket of equities is better for applying this strategy to longer time-frames (+50 years, etc.) because of the uncertainties of whether or not a company will last that long (especially nowadays).
So that was all from this week, I still feel like I have made tremendous progress despite moving onto a different strategy. So this week will be a race against the horses to get what I want done. (yes that was a pun)
-Jamie



Comments
Post a Comment