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
Jack Pizza
I don't know what you guys are really trying to achieve, but when changing it to 2 days from 15, sharpe ratio plummets. CAGR drops and DD goes from 16.5 to about 22%
Gv
Wow....quite a bit of progress from Quanopian on this one. I am still getting my head around QC framework.
Can a kind soul care to explain below lines of code:
# Setup daily consolidation symbols = self.SIGNALS + [self.MRKT] + self.FORPAIRS for symbol in symbols: self.consolidator = TradeBarConsolidator(timedelta(days=1)) self.consolidator.DataConsolidated += self.consolidation_handler self.SubscriptionManager.AddConsolidator(symbol, self.consolidator) # Warm up history self.lookback = 252 self.history = self.History(symbols, self.lookback, Resolution.Daily) if self.history.empty or 'close' not in self.history.columns: return self.history = self.history['close'].unstack(level=0).dropna() self.update_history_shift() def consolidation_handler(self, sender, consolidated): self.history.loc[consolidated.EndTime, consolidated.Symbol] = consolidated.Close self.history = self.history.iloc[-self.lookback:] self.update_history_shift() def update_history_shift(self): self.history_shift = self.history.rolling(11, center=True).mean().shift(60)Peter Guenther
Goldie Yalamanchi , Nathan Swenson , and Elsid Aliaj: I tend to agree with Elsid and would not reduce the wait days too much. What I take away from Guy's table (reported elsewhere) is that the performance is relatively stable from 5-15 wait days, so there might be some scope to play around with reducing the wait days in this range. I would not go down to the 1 or 2 days, although the returns in the backtest look better. I would rather go to where we achieve some stability in the sense that results look relatively similar over a range of a parameter's values. I would also assume that by reducing the wait days we become more dependent on the return flips and that they provide precise signals in terms of pulling the wait days up when it is beneficial to do so. When these signals are less precise in the future compared to the backtest, we might be ending up with too few wait days. I will also try and run some tests to get a feel for what the new dependencies are ...
Jack Pizza
Performance from a full 2008 backtest actually goes down. And DD sky rockets to 24%.
Maybe if you backtest just 2020 the numbers look better but the whole picture looks much worst.
Austin
"What I take away from Guy's table (reported elsewhere) is that the performance is relatively stable from 5-15 wait days, so there might be some scope to play around with reducing the wait days in this range. I would not go down to the 1 or 2 days, although the returns in the backtest look better."
I agree, if the QC Optimizer wasn't pay-as-you-go I'd have run a couple of optimizations over the many parameters involved in this algo to look at stability and out-of-sample viability. As far as goals to measure against, parameter stability seems MUCH more important than backtest return % over many years. That is, as long as one's goal is to create a model that can describe the future, not soley describe the past. Jared mentioned in a different thread that QC is working to make the Optimizer feature work with nodes you're already paying for, and after that feature is pushed in ~10 days I'll run more tests and share my findings here...
Peter Guenther, if memory serves I remember you asking what market phenomonon this In/Out algo appears to be harnessing to capture such nice backtest results. Did the community ever come up with a market phenomonon this algo is exploiting, or is this experiment soley focused on the backtest?
In the mean time I'm working on a futures strategy, and since I've loved the discussion around this algo so much, I'm planning on sharing it if I can get it working / add value to the community :) these open sourced conversations are great!
Peter Guenther
Austin: Looking forward to your analysis results! This will be very interesting in terms of seeing the sensitivities and where there are any flimsy parts that need fixing, further development, or a more substantial overhaul. The futures version that you are working on also sounds very exciting and thanks for planning to share it! I am sure the community will love it and I fully subscribe to your positive note regarding having these open algo conversations, they are great.
Yes, I believe that you are right: currently, the source of the returns is not fully understood regarding its specific mechanics. I reckon a working hypothesis is that the algo signals pick up ‘jitter’ in the equity market that translates into a boost in bond prices. What was driving investors’ jitter often may not eventuate. Nevertheless, ‘riding the jitter wave’ in bonds vs remaining invested in equity seems to pays off.
Vladimir
Peter Gunther,
I'm sure you won't answer this, my last post on this thread, just as you haven't answered
many of my previous ones.
I showed you where are the flimsy parts that need fixing, further development,
or a more substantial overhaul.
In the United States, only one person has veto power.
You have given this right to any of the 8 sources who are not fully understood regarding its specific mechanics and are therefore unreliable.
Happy curvefitting!
Rock247it
Vladimir
Rock247it
Can someone get my name off this??? How do I remove my name???
On the upper right corner of the thread there is Follow Discussion bell, click on it.
I tried and it's working for me.
Peter Guenther
Impressive burst of passion there, always great to see, and, I reckon, a useful reminder of the several streams/camps we have in this thread with, sometimes, very different views of the world. For further reference, a list (~ chronological order):
1. Engineers – type “Rich data modelists”
2. Engineers – type “Coding experts”
3. Engineers – type “Parameter minimalists”
4. Live traders
5. Sensitivity assessors
Looking forward to these varied streams/camps’ further contributions, although I must say that I am a bit worried about our “parameter minimalists” fraction, but we shall see.
Thunder Chicken
Peter Guenther
Stream: Parameter minimalists
Since much of the discussion lately has been focussed in the Rich data modelists stream, here is a contribution to our Parameter minimalists stream. Specifically, this is a great algo that Dan Whitnable posted on 22 Oct 2020 (see the Quantopian archive). Dan noted that it builds on ideas by Tentor Testivis and others (see his original notes). The algo distils a bear signal by comparing three return pairs. Let’s call the algo the “Distilled Bear” in & out algo; bear in a positive sense = strong. The algo is quite efficient in terms of total return per parameters used.
The Distilled Bear in & out algo
Holdings: In = QQQ, Out = TLT/IEF
Backtesting period: Jan 1 2008 to Dec 18 2020
Total return: 1843%
Sharpe ratio: 1.77; Max drawdown: 14.1%; Compounding annual return: 25.7%
Thunder Chicken
Peter Guenther -
What would be interesting is to see the distilled bear combined with the Momentum Strategy with Market Cap and EV/EBITDA' strategy introduced by Jing Wu, 6 Feb 2018.
Damiano Bolzoni
Peter Guenther have you tried to backtest the strategy between 1/1/2012 and 31/12/2019? What I found is that the strategy shines between 2008 - end 2012, and then again in 2020. Otherwise underperforms a simple buy-and-hold of QQQ (or SPY). The main reason for the great returns over the 2008-2020 timeframe seems to be those two periods....
Thunder Chicken
I think it depends what you hold during that period Damiano Bolzoni. If you hold 2x Treasury 7-10 yrs and 20 years, you'd outperform. The interesting aspect of 2x or3x treasury holdings is simply, we don't ever expect the price to goto zero, much like TQQQ, SSO, or SPXL would.
Damiano Bolzoni
Thunder Chicken I'm running the strategy as posted here, so I will hold whatever the strategy tells to hold...the eyepopping results posted here are backed by 2 timeframes, and otherwise the strategy underperforms a simple buy-and-hold (with the same asset)
Peter Guenther
Damiano Bolzoni: Thanks for sharing these results regarding testing subsections of the backtesting period. Great stuff! I reckon you tested the In & Out, latest version? I recall that Radu Spineanu, back then on Quantopian, was running tests from 2012 onwards and also mentioned subdued performance. Not sure whether you have these readily available, but if so, would you be happy to share some numbers so that people can get a feel for the performance differences (e.g. the period you mentioned, 1/1/2012 and 31/12/2019, and then: In & Out (e.g. holding QQQ) +XXX%, SPY +XXX%, QQQ +XXX%)? That would be very cool.
Irrespectively, I see it the following way: For me, the In & Out is an insurance package that I take out to protect my nicely curated equity stock portfolio from steep drawdowns and then hopefully even benefit from a sell high-buy low type of scenario. Yet, such drawdowns are rare. During calm times, I pay an ‘insurance premium’ that, like any insurance, doesn’t really pay off but instead costs money when nothing super-bad is happening. The insurance premium are losses and/or missed gains due to nervous moves in an out of the market as soon as signs of market stress occur. The algo has multiple radars running (signals) to assess market stress and, hopefully, capture it early via the multiple radars.
The problem is, and this could be an interesting path to explore, that we do not know when to switch our radars on versus off and just be invested in equity without the insurance package and associated costs.
It’s also important to note that, at least in my personal view, the In & Out is not necessarily intended to make money in and of itself as a standalone strategy. This is where a great stock selection strategy is required which hopefully generates returns above the market in times without steep drawdowns. The In & Out is a (possibly costly) guard of our amazing stock selection’s returns. Your data will be useful to assess how costly this guard is. Maybe others are cheaper, for example The Distilled Bear? This will be very interesting to explore further.
Thunder Chicken
Damiano Bolzoni - You'd be correct. It is near impossible to beat a bull market. Most hedge funds and mutual funds do not beat a straight bull market, by any appreciable amount. I have attach the backtest for the period you indicated.
Strategy Net Profit: 314.710%
Strategy Probabilistic Sharpe Ratio: 1.728
Strategy Beta: .328
Please note the Sharpe Ratio and Beta.
-TC
Thunder Chicken
Nathan Swenson - Are you just generating the signal daily, around 11:30, on QC, in order to determine if you have a signal or not?
Nathan Swenson
Thunder Chicken,
Yes, I have my live algo setup to paper trade. I just check it daily for trades and trade my accounts manually. Currently in equities. I still have flex v4 running. I'm still not sure of the best version to run. The new bear distill looks interesting.
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!