This is the original name of the algorithm that I created as a result of a successful collaboration
on the Quantopian forum thread "New Strategy - In & Out" in October 2020.
Unfortunately, the collaboration did not continue on the QuantConnect forum.
At least I am very uncomfortable with the strange names used by Peter Gunther in the algorithms,
such as "Distilled Bear", variable names and decision making logic.
This algorithm unlike those from Peter Gunther has three pairs as a source, two parameters and
concensus of all three for exit signal.
I did not optimized parameters, so you can get better results.
I want to thank Jared Broad and his team for giving me the opportunity to recover one of
my favorite algorithms.
Happy New Year to all
.ekz.
Thats fantastic, Nate Miller
I was going to do exactly this! Add comments to help new folks (like myself) have context.
From a previous comment I also learned that Vladimir is sensitive about variable names, so that is something to be mindful of (read the first message in this thread). Thats a small price to pay for his contribution to the community, i think. That said, i could never figure out what "RET" stood for. Now I know it is a Time constant, so thanks for that :-)
I do agree that keeping the name of the strategy consistent is helpful for collaboration, and I'm Looking forward to doing just that, when i have more free time.
Gv
Vladimir.....Doesn't it makes sense to select something like top 10% performers from QQQ underlying stocks rather than including individual stocks like MSFT, NFLX etc?
Chak
Vlad provided the code sample as a template.
Jack Pizza
Vladimir i actually found the parameters to be quite robust through a range where maybe CAGR went down 2-3% and DD up 2% or so.
But I did run across some weird massive performance difference for some values.
For example changing RET to say 80 increases DD 2x to almost 30% for some weird reason while other multiples usually do not.
This is strictly speaking about VOLA and RET.
Vladimir
Elsid Aliaj,
The original strategy has two constant parameter:
VOLA = 126; BASE_RET = 85; Did you find anything better?Jack Pizza
For the full backtest no, for single years yes for 2020 VOLA 100 and RET 50 worked better, but full backtest lowered CAGR by 2-3 and increased drawdown by 3, so not worth it in my opinion.
Also obvious observation heavy returns are driven by bonds. Would love to see some sort of black swan implementation with options but might be outside the scope of this discussion.
So if even bonds breakdown their negative correlation to stocks you can have protection. The returns would more then cover the cost.
Vladimir
Gv
Vladimir.....Doesn't it makes sense to select something like top 10% performers from QQQ
It definitely makes sense, but we're not ready for it now.
The backtest can run 60-90 minutes.
.ekz.
@elsid: I am working on an options variant, and will share when done. It's my first algo on QC, so it may take some time.
All: I think the strategy may benefit from walk forward analysis. If we find that the strategy can in fact be walked forward, then periodic optimizations to VOLA and RET will become part of the live deployment process. For example, we might find that re-optimizing these every 18 months might be the right frequency. WFA would help us determine this, or if WF is even applicable to the strategy. Just a thought.
Jack Pizza
Ikezi Kamanu yes that would be something to consider. Are you working on the options strategy to use options for all the trades? Or just as black swan insurance? Are you familiar with Talib's work?
.ekz.
Yes, I was considering using options for all the trades, but it should be trivial to add black swan insurance.
I am yet to read Talib's book, although I do have a copy.
Mikko M
Here is a version that dynamically selects top 10 gained (ROC 252) tech companies instead of using a fixed set of stocks.
Jack Pizza
That's cool would be super interested in it, especially the black swan parts.
Basically the whole premise is take whatever strategy and use a tiny fraction for insurance which makes sense. Just like you insure your home.
Enjoy your strategies performance with a 1-2% insurance drag. Only thing is I'm not sure if you can insure your whole portfolio that cheaply in case of total collapse.
Think the numbers worked out too 1-3% per 16% of drawdown.
.ekz.
I've adopted portfolio insurance with VIX calls. 30DTE, 30 Delta. We could add that to the strategy. Here is a link with more detail.
https://seekingalpha.com/article/613051-buying-vix-calls-as-a-portfolio-hedgeWe can chat about this off-thread so we don't digress / tangent off the main conversation. I'd imagine QC has some mechanism for direct conversations.
https://seekingalpha.com/article/613051-buying-vix-calls-as-a-portfolio-hedgeLeandro Maia
Ikezi,
I would also be interested in these hedge strategies, although I would probably not be able contribute much. And I'm sure I wouldn't be the only interested. So perhaps, instead going to direct conversation, we could set a separate thread.
Thunder Chicken
Ikezi Kamanu and Leandro Maia
I don't believe VIX options are available on Quantconnect. I have requested the index a few times. No dice. So, I don't believe options would be available on the platform. I am sure Jared Broadmight be able to point us in the right direction, but I am unsure. They might have a solution with external data but I am unaware of it.Jared Broad
-TC.
Guy Fleury
@Vladimir. nice work. I particularly like that smooth equity line, it shows built-in alpha. Or, if you prefer, you can't have that line without built-in alpha. And that can be taken advantage of.
The following charts used your latest version (1.1).
In the first chart below, leverage is at 1.4x, it uses TQQQ and TMF, and managed a 92.5% CAGR over the 2008-2020 period. It has a beta of 0.091, which in itself is remarkable. It means the strategy fluctuated a lot less than the market in general. It did not trade TQQQ or TMF prior to February 2010. Still, the strategy held on to a 506,659.63% gain, going from 100k to $506,759,628 over the trading period.
You could go for more by pushing for a leverage of 1.5x. Doing so increased the strategy's beta to 0.10 and its CAGR to 107.6%. This more than doubled the ending equity to $1,353,637,166. Again, all based on the original stake of 100k. Note that there were other changes to the strategy as well.
Increasing the initial capital to 1 million would add a zero to the above equity numbers. The strategy is scalable to that level.
It should be observed that we can quit a trading strategy any time we want. It would result in getting what is displayed as equity at the top of the chart at that time.
Based on your chart, where was the risk after the first year? What you could lose was only part of the accumulating paper profits. And with such an equity curve, quitting along the way would more represent a stop-profit scenario and some lost profit opportunities. You would be losing the last few years of compounding. For instance, 100k ∙ (1+0.40)^12 - 100k ∙ (1+0.40)^10 = 2,776,845. Almost as much as you would have gained in the first 10 years (2,892,547). There was no preferred time to quit on such an equity curve. And if you added two years to this scenario, those two years could be worth 5,442,616 and raise the total outcome to 11,112,007. The point being that it is the last few years that might count the most, and to get there you have to survive all the prior years.
If you did the same calculations for the difference between year 14 and 12 but at a CAGR equivalent of 0.80, you would get: 100k ∙ (1+0.80)^14 - 100k ∙ (1+0.80)^12 = 259,130,229. IMHO, that is what is at stake. And one could do even more.
It is our job to try to extract the most we can from a trading strategy. We are allowed to game it after we have shown ourselves that it could be worthwhile and gained confidence in these newfound trading methods.
Thunder Chicken
Guy Fleury - You are going to need to be very careful with TQQQ. I'd recommend a 2x or keeping your exposure to TQQQ low. A few bad days on QQQ, let's say down 5% per day for 5 days, which he saw 9 months ago, could easily wipe out your portfolio. I am also assuming this algorithm works flawlessly, which is highly suspect on a walk forward.
Be cognizant of the potential risk you are taking and consider diversifying across assets. Just a thought.
-TC
Guy Fleury
@Thunder Chicken, I am well aware of the dangers of trading 3x-leveraged ETFs. These are not instruments to be held over the long term. Look at the long-term chart of SQQQ for instance. It has not looked up very much. And you can find a lot of those.
However, this is a trading strategy where you do not hold that long. And it is “very sensitive” to price fluctuations. Technically, all it does is trade QQQ where price variations are multiplied by 3. It is still trading the average of the 100 stocks in QQQ. Top ten holdings account for 55%(AAPL, MSFT, AMZN, TSLA, FB, GOOGL, GOOG, NVDA, PYPL, ADBE). And such names have not been that bad over the past 12 years, nor has QQQ.
Nonetheless, the strategy switches to bonds at the first sign of trouble. As the chart shows, even the bad few days of 9 months ago (or the whole of 2020 for that matter) did not do that much harm since the strategy more than recovered. Regardless, we can override our trading strategy at any time we want and execute a massive manual stop-loss. Doing so, at any time during the simulation period would have resulted in substantial profits (high returns) up to that time.
We can not stop the market from fluctuating, but we can move to the sidelines and that is what this bond switcher does. It has, on average, a very low pain threshold. Just like the other versions of the In & Out strategy. Even though each of those programs have different trading procedures, they all had sensitive bond switching procedures. These can be improved upon but that is another story.
You seemed worried about things the program might not even let happen. It will switch to bonds at the slightest downward pressure and remain in bonds for as long as it takes thereby avoiding those bottomless pits to oblivion. But, still, we should use caution.
This is why we do simulations in the first place. It is to see if the trading methods used would have been successful. Once we have that, we can concentrate on: can these trading procedures hold up going forward?
Here is a little fact. It takes 21 successive 10% loss on QQQ to lose 90% of its value. Due to the 3x leverage, it would take only 7 successive 10% loss on QQQ for TQQQ to lose 90% of its value. It is the reason why, should you want to play TQQQ, you should have a sensitive switcher. But we should also note that going for higher risk can lead to higher returns. And the question becomes: how much risk can you withstand? Or, can you play the game in such a way that the total risk is reduced to your acceptable level? You would see TQQQ really fly should QQQ have 21 successive 10% gains!
Guy Fleury
In a previous post somewhere it is said: “And one could do even more.” I do not like to say things like that without showing that it can be done. Actually, even before saying that, the test had been done. But, I was advised not to push it and settled for what was presented. Still, one could do more.
So, here it is. Leverage went up to 1.6x. Other stuff was changed too, but the most impactful was coming from the compounding of profits generated by the compounding of the bet size. The result: almost doubled the outcome compared to the last chart presented.
I do not dare to again say you could push for more. But...
Vladimir
Guy Fleury,
This strategy has two opponents.
Menno Dreischor
The reality is, that it is likely, it will not just fail to meet expectations, but generate
negative alpha in the long run.
Arthur Asenheimer
But personally I wouldn't risk my money for it for the reasons mentioned above.
Can you support this strategy there with a less risky version of your algorithm.
Vladimir
The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
To unlock posting to the community forums please complete at least 30% of Boot Camp.
You can continue your Boot Camp training progress from the terminal. We hope to see you in the community soon!