This thread is meant to continue the development of the In & Out strategy started on Quantopian. The first challenge for us will probalbly be to translate our ideas to QC code.
I'll start by attaching the version Bob Bob kindly translated on Vladimir's request.
Vladimir:
About your key error, did you also initialize UUP like this?
self.UUP = self.AddEquity('UUP', res).Symbol
Robert McLellan
Pardon me for poking my nose in this thread but distilling what I understand of the strategy it hinges on a negative coorelation between the market (represented by SPY) and long term treasury yields. Would then not a simple correlation track between the two be enough of a “get to cash” signal to bail out?
I've cobbled together something similar for my algo by leveraging a sample posted in another thread which shows a pretty good signal in the June-July timeframe of this year.
Robert McLellan
Stole the code from here if anyone is interested.
Jack Pizza
Wouldn't dual momentum of say bonds : cash work as a better predictor than correlation? I saw some of the correlation stuff above and it doesn't seem like it can be a good enough predictor as it's bouncing all over the place.
I have a dual momentum strategy with bond mutual funds, that does well and has moved to cash pretty much all these times corona ect.
Seems like it would work as a good out signal here if cash > bond funds stop trading and move to cash.
Robert McLellan
Well I think the obvious answer is probably to do both and take a look. My comments were based on the view that I see this whole strategy hinging on negative coorelation between bonds and stocks. If that starts to break down the strategy may no longer hold weight.
I'm not saying you're version won't work or isn't better but it seems to provide decent signal for me.
Quantum Bunny
New to this thread, I would imagine someone would have raised this question already. Why not using actual oil, gold, metal prices for a much longer backtesting period pre-2008?
Zimman
Is anyone using this for live auto trading?
Jack Pizza
sorry to hijack thread Vladimir how can i get in contact with you? Want to discuss some potential investment ideas.
Log Up
Based on current situation, what if stocks and bonds both fall? currently stocks are down and bonds are also down due to high inflation worries. in that case we will lose money if we invest in bonds right?
Jack Pizza
Log Up I've been brining these issues up since Quantopian days so a few years nobody cares to listen, they just keep overfitting the strategy.
Also the OUT is completely arbitrary based on faulty correlations which break down. Hence a simpler normal dual momentum strategy works better.
Because if Asset < Risk Free Rate move OUT
Out also has to have a bucket of bonds vs risk free rate of cash, no point in going to bonds when their absolute momentum is negative vs cash.
The strategy would therefore be:
If Asset > Risk Free Cash IN (in to whatever highest momentum asset or hold top 5 assets)
Because if Asset < Risk Free Rate move OUT (either bonds in a low rate env or cash in a rapidly rising rate env)
The SLV < GLD and all the sector non sense is based on faulty correlations that would break the strategy at some point in time along with OUT just being bonds another fault correlation.
Log Up
Jack Pizza I am not much experienced trader myself, but I do agree with the pitfalls of hard coded assumptions/correlations you mentioned. We have many periods in history where stocks and bonds both fell together, so felt should it accommodate to invest only if bonds are faring better than other available alternatives.
Carsten
@Jack Pizza
I had similar issues with the overfitted versions.
The question is, what is robust?
I totally agree, a dual momentum is quite robust.
Voltility should be, but there a some periods, where high volatility as well delivers good gains.
Tested as well first month / second month VIX futures. If you plug them into a Hidden Markov Model you don‘t need to specify a length component as the HMM figures it out. worked very well in the 2008 episod, performed poor in 2015/16 and performed excellent in 2020.
Than there is the good old price vs 200DMA, if one uses the volatility or ATR to decide if the price is significantly above or below the performance is not bad.
Some more thoughts On robust indicator?
Jack Pizza
Carsten it's basically a fools game based on luck, the thing that has shown semi promise is momentum if you can stomach 40-50% drawdowns which basically make it as good as all in on the stock market end of the day lol.
But you see they love hiding that fact by showing monthly drawdowns because well everyone is using monthly drawdowns, instead of we purposely want to mislead you, as if you knew the truth you wouldn't give us your money to invest.
On here it just turns into Ego contests, of I have the most popular thread on Quantopian / qc. Dual momentum backtests are highly flawed too especially with bonds as the out. Even Cash as the out doesn't quantify risk, say you're out everything is honky dory and the dollar collapses 40% overnight…
They geniuses laugh and grin ohh that will never happen, like it hasn't 100 times over globally throughout human history. People's don't appreciate risk, and think it will never happen to them, until it does over and over. Then all the experts go and hide not to be found.
“The day after the U.S. dropped its second atomic bomb on Nagasaki, Japan closed down trading on the Japanese Exchange. Although Japan would surrender less than a month later, officially ending World War II, the Japanese Stock Exchange would remain closed for nearly four years, finally reopening on April 1, 1949. Following reorganization, the TSE emerged as the largest of five post-war exchanges in Japan.”
Ohh it can never happen in their brains, what would you do if your'e invested and the stock market is closed for 4 years, if not totally bankrupt along with the companies or index you had invested in? Even excluding war there is so much counter party risk its insane, like dominoes they'll all fall.
What happens with the DTC Cede and Co. which is technically the rightful owner of almost all Assets in the world since it's their name on the stock certificates and titles, says we own everything sue us in court if you want it?
See where I'm going with this? Every single strategy i've personally tested researched read about, none of them achieve anything above 1:1 performance/dd long term. You'll always have inevitable drawdowns even making the ratio 1:2.
My conclusion from all this is you can't escape drawdowns from a strategy.
My further conclusions from a risk standpoint as far as investing goes is.
Operating Farmland, war happens your farm blows up who cares its just land, replant seed after. Weather ruins crops for a year, again replant next year. Water issues, use new technologies like desalination. Everyone will always need food….
Gold as basic insurance, if you have some sort of trading strategy, trade it through actual futures where you use physical gold as collateral on CME, but you at all times are physically owning it. Internet goes down, CME goes bankrupt, war, yada yada who cares, you have no counter party risk as you physically own it somewhere, after the dust settles it's a long time.
Even gold just because it's worked for human history, there could be some time in the future from say asteroid mining where it becomes basically worthless, or some massive discovery.
I would hold other non food type commodities mostly metals physically and like i said maybe run some momentum strategy if you can stomach the massive drawdowns. Assuming momentum is a psychological phenomena and not another overfitted mined hypothesis.
Hope this confused you a lot but hopefully it helps you from losing a crap ton of money…. I wish i knew what a robust indicator was to limit drawdowns and maximize performance, but I have yet to find it unfortunately.
So invest with a barbell type Taleb mindset, 95% in farmland, gold, 5% gamble on crypto, high flying strategies, if they last a year or two and you make 1000% great take it out put it on the barbell, and repeat.
Always remember there is a lot more risk like 100000000% more than majority of people care to even bother thinking about.
hope this somehow helped lol.
Peter Guenther
A comment on the current overfitting discussion
It is an important part of the In & Out discussion’s evolution that we constantly revisit the overfitting issue. The latest resurgence of the issue was mainly driven by an underperformance of the TLT ETF which is used in the latest in & out versions as the out holdings when we are not in, i.e. not invested in equities. Some comments, as a shorthand, simply seem to refer to the previous In & Out versions as the ‘overfitted versions’, with the TLT underperformance just being an additional proof that the In & Out has been overfitted as claimed in earlier comments in this thread. However, this conclusion does not seem to be valid to me.
Overfitting of what?
In the Amazing returns in & out thread, I try to explicitly pinpoint the three key components/characteristics of the in & out algos:
1. The in holdings selection
2. The out holdings selection
3. The market timer property
Recall that earlier overfitting discussions were mainly about the number of parameters that the In & Out uses and that these are too many and clearly show overfitting. Note that these parameters are neither used for the in holdings selection nor the out holdings selection, the latter of which has led to the current underperformance (the TLT decline). Instead, these parameters are used for the market timer. In the Amazing returns in & out thread, I argue that the market timer has worked remarkably well during the recent equity downturn. The market timer is arguably the soul of the In & Out. Therefore, it appears to me that the recent episode is not very suitable to demonstrate overfitting of the algo along the lines of earlier claims in this thread.
Have the out holdings been overfitted? First, it is important to note that this question has little to do with the previous overfitting discussion. It is a new question since it is about a different component. Second, in my view, overfitting is a process in which models are repeatedly estimated and optimized to fit the data better (i.e., to maximize the total return). Going through the discussion in the in & out threads, I see little evidence for such an approach on the out holdings. It seems to me that bonds were listed as the out holdings in my very first post on Quantopian. Since then this component has basically been ignored, almost neglected. There are no parameters dedicated to this component other than a hard-wired ETF that is listed. I do not recall significant efforts to (over-)fit this component. Quite the opposite, the lack of such efforts has sporadically been noted in this and the other thread.
It seems that the issues we are seeing at the moment are a result of underfitting or lack of fitting, instead of overfitting. Specifically, the out holdings selection has been ignored and requires work.
Jack Pizza
Hey Peter Guenther actually the biggest performance issues seems like the timing model, it goes in right before the collapse. You can easily just swap in BIL (cash) instead of TLT, and see it takes a massive hit because it's IN instead of OUT.
Trying some tests with an MA filter and stop losses.
Jack Pizza
nevermind had a wrong version seems like, I tried adding an MA filter doesn't seem to be working though… added to line 137.
Jack Pizza
Also add momentum approach mentioned in the stock selection forum. Would add it to both the IN and OUT portion so have maybe 4 ETF's in IN and 3 in OUT and select highest momentum one
Jack Pizza
I would add it from the other momentum algorithms, but the ordering is a bit weird and i can't debug easily on here, would probably take the symbol and concat / append it to _IN and _OUT after the momentum check is ran. I'll try working on it later, but maybe if someone has time can do it much quicker.
Momentum would be 1,3,6,12 month with weights of 12,4,2,1
Jack Pizza
A simple stop loss protects losses as opposed to cash. straight cash you are at around 16%/16% Returns/Drawdown, with iEF + stop loss 1%, you're at 20%/!8%
Zimman
Manoj Agarwala , i have been trying to add momentum indicators on your version without success…. how would you add moving average ?
Jack Pizza
Zimman
self.spy = self.AddEquity("QQQ", Resolution.Daily).Symbol
self.sma = self.SMA(self.spy, 50, Resolution.Daily)
Tentor Testivis
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!