Inspired by T Smith idea to implement Gary's Antonacci's dual momentum approach to ETF
selection in "IN OUT" strategy.
-The execution code has been completely changed to keep levarage under control and avoid
insufficient buying power warnings.
-To calculate returns I used widely used in industry momentum with excluding period.
-Modified components that are more in line with the strategy.
-The IN OUT part of the strategy has not changed except for some cosmetics
to make it more readable for myself.
"DUAL MOMENTUM IN OUT" nearly doubled "IN OUT" Net Profit while maintaining risk metrics at the same level.
Compounding Annual Return
30.164%
Sharpe Ratio
1.667
PSR
97.773%
Beta
0.057
Drawdown
19.300%
Annual Standard Deviation
0.154
Here is my second version of "DUAL MOMENTUM-IN OUT".
Jack Pizza
Damiano Bolzoni I don't understand why people only focus on returns and ignore things like drawdown. Yeah you can buy and hold QQQ and possibly get the same returns with 40-60% drawdowns.
Damiano Bolzoni
Elsid Aliaj you are totally right. People should take into account drawdowns too. So...do you know what was the worst drawdown for QQQ between 1-1-2013 and 12-31-2019?
I can give you a hint...far below 40%
Guy Fleury
Some basic questions for any trading strategy: Did it survive? Did it at least beat market averages? Will it survive going forward? How far can it go? How much money can it “literally” print? We simulate over past data to gain some insight into what could be done to answer those questions.
The structure of a trading program is simple: it is a single do-while loop. While the clock is still ticking, initiate acyclical long(short) positions for whatever reason you might have, close them out later at a profit or loss and cumulate the results.
Most of the programs I see have scheduled trading times (like: self.Schedule.On(self.DateRules.EveryDay()...) or whatever. Such a command does not ask: is there a profit to be had? It just executes and comes back with the results, that they be good or bad. Meaning that initiating such a daily routine is at the heart of what is supposed to help you outperform long-term market averages. We definitely need more than that...
The following chart is based on Vladimir's version 2.3. Changed a few things around including some of its structural design and trading procedures. It is based on 3x-leveraged ETFs (TQQQ, TMF) which in turn were leverage modulated around 1.4x. The initial capital was set to 1M with a start date of 2010-3-1 to make sure both ETFs were active. Data on QQQ prior to 2010 could have been used to demonstrate the benefits of trading a market average tracker. Trading TQQQ in this strategy amplifies QQQ's beta by a factor of 3. It also increases volatility. This is compensated by higher returns.
The strategy had an 89.515% CAGR. More than enough to pay all the added leveraging fees. However, it has a 53% hit rate which makes the strategy perform close to a slightly biased coin. It also comes close to the historical upside biased experienced in stocks over the long term. It is like saying that you are not getting more than what the market is giving to everyone else. Nonetheless, the return is impressive. And there has to be some reason why. For one, the average win per trade was 17.88% while its average loss was -7.53%. That is enough to explain the outperformance and this even if the hit rate had been 50%.
The strategy could be considered another variation on a theme (see the different versions of In & Out strategy). I applied some of the same techniques in this version as I did in others. The above chart does illustrate that it can be done.
.ekz.
What an interesting (and educational) discussion. Thanks to all for sharing your work and knowledge.
I'd like to learn more of the background, as it seems this is a continuation of a prior thread.
Where can I read more about what this dual momentum strategy actually is? IE: a high level summary on how it works. Is there a previous post somewhere?
Guy Fleury
As a follow-up. Would you have the nerves to hold on for more?
The above chart required pushing on the machine and accepting more volatility which translated into a higher max drawdown, meaning higher risk. But with it came higher returns as illustrated above.
You have a basic template for a trading strategy. It buys and sells according to instructions. And it shows some built-in alpha. The question then becomes: is this excess return sufficient to support leveraging costs? It goes with another related question: can you increase that alpha further by some means or other?
When I design or modify a trading strategy, it is always based on the mathematics of the “game”. The more your program trades, the more it is faced with probability and statistics. Like you do not win every trade, you are not right all the time. You win some and you lose some. We all accept that, but we usually do not want to accept its accompanying conclusion. We are not that good at predicting where stocks are going or how much they will rise or fall. So we design trading “excuses”. Something that will trigger trades (in and out) on our behalf.
You play QQQ. It is like playing 100 stocks where the average outcome is QQQ. All you can get is QQQ's return while you are holding it. Based on the metrics of the above chart, the program switched in and out 100 times. It had a 59% hit rate with an average win of 14.45% and an average loss of -7.43% per trade. Numbers pointing to an overall positive return.
A hundred times, over the trading interval, the program jumped to bonds at the first sign of potential turmoil. That is a lot more than needed or required. But, you could not know which of those would save you from real damage especially since you were leveraging whatever the outcome might be. You were protecting yourself a lot more often than needed. But this should be considered as part of the cost of being in the trading business.
You could say that 90 times the switching to safety was not needed. However, it is that switching around, technically taking chunks of QQQ's return, that helped the strategy exceed the result of the prior posted simulation. Both simulations used TQQQ and TMF as primary assets. Leveraging stayed the same at 1.4x. The other modifications seem to have proven themselves worthwhile or at least worth studying in more detail.
For those wishing to start with a lower initial capital, the strategy is scalable down.
Vladimir
T. Smith,
I found a solution.
Here is the updated DUAL MOMENTUM IN OUT v2.4
It uses "Intersection of ROC comparison using OUT_DAY approach by Vladimir" for In-Out which has
three pairs as a source, two parameters and concensus of all three for exit signal.
Changed Dual Momentum parameters RET = 252; EXCL = 21;
Happy New Year to all
Beaux Walton
I am absolutely loving this thread, and have already learned so much! Thank you all for your incredible work.
I have a question regarding "poor man accounts" (ie: those with less than 100k). When I run backtests with a smaller account size (under 10k), everything runs smoothly. However, I can't understand how that is, as with such a small account and not utilising leverage I simply can't afford the 100 SPY shares. If I tried to deploy this live, nothing would happen as I don't have sufficient equity. How would one scale this down to work with whatever equity is on hand? (I'm still learning, so forgive me if all of this is painfully obvious.)
Again, thank you to all the Quantconnect community members who are happy to share their experience with the rest of us. We really do appreciate you taking the time to educate us. Happy new year!
Beaux Walton
My apologies! I see where I'm going wrong! It's not 100 shares of SPY, it's 100 minutes after opening. Ahhhh!
Thank you all for not pointing and laughing at the new guy.
Pcnpj
Scales well with 2x leverage. Can't seem to find any 3x leveraged equivalent ETFs for FDN and TLH for a 3x test.
Guy Fleury
The following charts show a scaled-down version to 100k and a 1M version of my variation to this theme. Both operate on the same principles and conditions as the two prior charts. It shows that returning to the initial capital to 1M simply added a zero to the equity as displayed in the second chart below. Now, that final equity number is a big number. Obviously, this is pushing toward the limits, but still not beyond since the strategy did not blow up and could do even more if requested (one path is to increase a single number).
100k as initial capital
1M as initial capital
The performance difference, compared to the simulation in the previous post comes from trading more for a higher average win per trade which came in at 15.70% compared to 14.45% in the prior test. This might not appear as much, but trade by trade, the added profits are compounding repeatedly and it does make a difference even if the win rate was down a little to 56% versus 59% in the previous simulation.
Used @Vladimir's version 2.3 as template. Added and discarded stuff, changed things here and there, all relatively easy to do. Most of it to force the strategy to trade more and at a higher profit margin. I pushed on the machine to reduce inter-trade delays while using modulated leverage in order to find the strategy's trading limits. I think they are in sight. It is where I usually add more protective measures knowing the overall return will be reduced. Afterward, I will add more gaming procedures.
The changes made are ordinary. Yet, we have the charts above. There is no magic there. The modifications were incrementally small and not drastic changes. Nonetheless, the code was considerably altered. These changes did respect the math of the game. If you increase by any means the number of trades and the average profit per trade, overall profit will simply rise.
Due to the very structure of this trading strategy, it technically cannot go bankrupt. Its bet size is proportional to the ongoing equity. When the strategy loses money, the bet size is reduced, and likewise, when the strategy makes money, bets get larger. Notwithstanding, you could still lose most of the strategy's equity to the point where no trade could be executed due to insufficient remaining funds. All you would lose would be the money put into the strategy.
So, how would you play this thing?
Take 10% or 20% of your portfolio and put it in this strategy as the high-risk part of your portfolio. Keep the rest for a more mundane portfolio with an expected secular outcome (say ~10% or better). Buy something like QQQ or SPY and hold for the duration, it should give you something near the expected long-term market average.
The Math For Such A Scenario
First, consider you lose your speculative bid. Net result: 90k ∙ (1+0.10)^20 + 10k ∙ 0 = 605,475 which is equivalent to 100k at 9.42%. The effective portfolio risk should be valued at this 0.58 basis points loss. Thereby risking less than 1% return of your long-term expected market return. Technically, risking not making 67,275 over those 20 years which you were also at risk of not making.
You win your bet, but at a lesser rate than the chart above (it is at 125.95%). You get your 10% on 90k plus the outcome of your long-term speculative bet. The math:
90k ∙ (1+0.10)^20 + 10k ∙ (1+0.80)^20 = 1,275,429,097. That is equivalent to a 60.43% portfolio CAGR for the 20-year period. If your bet turns out at a higher rate, say 0.90, then the math says: 90k ∙ (1+0.10)^20 + 10k ∙ (1+0.90)^20 = 3,759,602,821 which is a 69.34% equivalent CAGR on the $100k invested in this portfolio.
For the 80/20 mix, you would get: 80k ∙ (1+0.10)^20 + 20k ∙ 0 = 538,200 for the losing scenario. This is equivalent to an 8.78% CAGR on your 100k. Whereas, with a winning bet:
80k ∙ (1+0.10)^20 + 20k ∙ (1+0.90)^20 = 7,518,532,892 or a 75.31% overall portfolio CAGR.
Even if some think this is impossible, the above charts show nonetheless that it is doable, it is feasible, and it is executable. Of course, the future will be different. But, you do have a wide margin of error. Which game do you want to play? Can you risk 1% less on your future CAGR for a 50%+ return on your overall portfolio? Naturally, should you embark on such a journey, be ready for a wild ride. On the other hand, for your comfort, it is all on auto-pilot...
Vladimir
Guy Fleury,
It is not clear from your extensive study on which version of DUAL MOMENTUM IN OUT this was done.
FYI, the latest version of DUAL MOMENTUM IN OUT v2.4 is significantly different from the previous ones.
Guy Fleury
@Vladimir, I used the first occurrence of version 2.3 located HERE
Vladimir
Guy Fleury,
Can you share the way you create a leverage to avoid warnings of insufficient buying power?
Guy Fleury
@Vladimir, leverage was set at 1.4x. Therefore, theoretically, I should not have those warnings.
Vladimir
Guy Fleury,
I tried the same way you did and got a bunch of invalid orders and warnings about insufficient
buying power.
Can you activate and print the holdings chart for any of your backtests and check the logs?
Guy Fleury
@Vladimir, sorry, but I do not think the way you do it is the same way I did. I changed that program considerably, including trading times. Changed its trading philosophy and objectives. As you know, I use math, leveraging, feedback loops, and compounding to control a trading strategy. If I did as everybody, I would get the same results as everybody.
I would add that if there were many insufficient buying power warnings, it would reduce the number of trades, and that would appear counterproductive. It would kind of choke the strategy to inaction and produce less. As expressed in a prior post I put a lot of emphasis on increasing the number of trades and the average net profit per trade. The sum of all trading profits and losses and therefore the net result of a trading strategy is totally explained by those two numbers.
So, the question would be: if there were insufficient buying power warnings, would they be to the benefit of the strategy or not? If it was, I would keep them in even if it reduced the number of trades. We are playing a “hold the puck game”. While you hold you can make a profit or a loss and none of either otherwise.
What I find interesting in that long post are the equations at the end of it which propose a way to handle a high-risk/high-potential strategy combined with a lesser one. We look at risk in terms of max drawdown and volatility (sigma). This might apply when dealing with a simulation.
We design trading strategies over past market data to see how they would have behaved if we had done this or that. Whereas in real life, it is going forward that is important. And what we perceived as risk in past data might better be represented as differences in opportunity sets and their respective probability of occurrence. A totally different world.
The post ended with: “Can you risk 1% less on your future CAGR for a 50%+ return on your overall portfolio?“
That 1% is not a major risk or any type of substantial added drawdown. It is only a 1% opportunity cost at best. In the example provided, it is: do you lose that 10k or not? Overall, you would still win the game. I would dare say: who should care about that 1% in the first place? It would take 20 years to find out if you kept it or not. And if you win, I do not think it will matter at all. It is like taking a side bet where you say: let it run. What have you got to lose? 1% on your long-term CAGR. Geez...
Vladimir
Guy Fleury,
Can you activate and print the holdings chart for any of your backtests and check the logs?
Leandro Maia
Vladimir,
regarding the buying power issue, did you try in Initialize:
self.Securities["QQQ"].SetLeverage(2.0)
You would need one line of that for each security you would hold. It works for me...
Vladimir
Leandro Maya,
here's a backtest with your recommendation.
Turn on the "Holdings" chart to see account leverage.
The engine does not keep the leverage and gives a lot of "Insufficient buying power" warnings.
Guy Fleury
@Vladimir, looked up the log. At times, it does show some insufficient buying power warnings. Probably due to the leverage modulation process pushing too hard. I will look closer into it to see if it brings any benefits.
What I have shown in the presented charts is the return progression as modifications were made. Just part of my strategy analysis and evaluation process: Can the strategy survive? Can it scale and how far? Can it be leveraged and by how much? What are the operational limits? What would it take for it to blow up? Where does it get most of its performance? Does the return come from anomalies that might not happen in the future? Would I withstand emotionally such a wild ride?
Further down this transformational process, I expect after more modifications and more constraints that the expected CAGR will go down. By how much, I do not know. But, what I do know now, is that I would not let it roam free in its present state. More work needs to be done...
I want to know where the profits are coming from and would they be sustainable going forward. Where is my risk/reward compromise? One of the most basic questions: how come, when pushed to its limits, is it making so much and not breaking down? I need to answer why since it has the potential to blow up the strategy in my face. On the other hand, these procedures could be most useful in other trading strategies. It will certainly take time to answer these questions to my satisfaction.
Presently, I think I have shown that there is a wide range of results that could have been achieved over past market data. A factor of over 3,000 times more than the original trading script (that is 300,000% more just by changing things around!). All this without having the strategy blow up, at least, not yet. That in itself is remarkable. It is probably the highest performing strategy ever seen in the QC forums.
Should you want to learn more on how I do these things, you can find a lot of it on my website.
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!