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
Peter Guenther
Good to hear from you, Frank Abraham, and thanks for joining the discussion and sharing these thoughts. Generally I agree, however in this particular instance we have to consider two things:
(1) QC's engine is designed so that future data can never be used, i.e. the look ahead bias that you described is technically ruled out.
(2) The description concerning the center=True setting is referring to data that is completely in the past relative to the point in time when we evaluate the data. See the description above: it is 60 days in the past and then calculating the average price in the [-5, +5] window surrounding that 60-day shift. Or, in other words, the average is calculated using the prices from the period -65 to -55, i.e. the prices between 65 and 55 days ago. These are all historic prices relative to the point in time when we use them. So, no look ahead bias. Hope this clarifies.
Jack Pizza
Peter Guenther Think I mentioned some prior thoughts of having an ultimate 3rd or even 4th out, such as cash, and gold. But I have to re-remember is this strategy based on momentum? How is determining what is out / in?
Or I guess some sort of range if outside this range ultimate out
If it's momentum based can just easily add those to the universe.
Peter Guenther
Thanks for the info, Elsid Aliaj. That's right, I definitely remember.
I reckon one could summarize that the In & Out's out signals are based on stress signs (i.e., extremely negative returns) in six markets (industrials, metal resources, natural resources, US dollar currency, bonds market, and the equity market itself) plus two asset pairs indicating safe haven moves (gold vs silver and utilities vs industrials). When the algo sees stress in one of these markets or pairs, it goes out of equity (QQQ) and into bonds (TLT).
Against this backdrop, the algo is not directly based on momentum. Let me muse about your range idea a bit and get back to you if something interesting comes to mind (and works). I will also have a look into the inflation idea discussed above (i.e., high inflation expectations → avoid bonds) and write a post about it if interesting findings come up.
Martin Molinero
Hi all! Just a small update: On https://github.com/QuantConnect/Lean/pull/5968 we shipped a new version of pythonNet that has shown a nice performance improvement, using as a benchmark the algorithm shared at https://www.quantconnect.com/forum/discussion/9597/the-in-amp-out-strategy-continued-from-quantopian/p4/comment-36557 it went from 47k data points per second to 79k data points per second.
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.
Aalap Sharma
I just started running INOUT_V8 live and I am seeing this error
Runtime Error: NameError : name 'pickle' is not defined at SaveData self.ObjectStore.SaveBytes('OS_signal_dens' in main.py: line 188 Stack Trace: NameError : name 'pickle' is not defined at SaveData self.ObjectStore.SaveBytes('OS_signal_dens' in main.py: line 188
Has anyone seen or resolved it?
Peter Guenther
Thanks for sharing, Aalap Sharma. Much appreciated. I think this will save people a bit of a headache going into Live Mode: Pickle is a python module and a line was missing to import it. The error did not pop up in Backtesting, since the read and write of the algo's state info (here: the signal density history) is only happening in Live Mode.
Attached is the updated v8, now including the import in line 14 of the code.
Let me know if something else pops up, this is very useful information for all.
Aalap Sharma
Thank you Peter Guenther !!! I will test this out
Damiano Bolzoni
Folks, I stumbled upon this:
and also this:
Isn't this “inspired” by what has been discussed on this thread for a year???
"Here is the list of funds used to generate signals for market state:
Invesco DB Base Metals Fund (DBB)
Invesco DB US Dollar Index Fund (UUP)
Consumer Discretionary Select Sector SPDR Fund (XLY)
Consumer Staples Select Sector SPDR Fund (XLP)
In our latest article we used the pair DBB-UUP as an absolute momentum indicator. In that application the return of DBB was compared with the return of the US dollar. In this application we add a new pair: XLY-XLP. The condition that must be satisfied for switching to risk-off allocation is that both pairs indicate a negative return. That happens when the return of DBB is smaller than that of UUP and the return of XLY is lower than the return of XLP over the relative strength evaluation period."
Did I miss something or this guy is selling the basics of IN&OUT as his idea??
Peter Guenther
Great investigative work, Damiano Bolzoni, thanks for sharing! Usually I would have said that it’s not unlikely that different people might come up with similar solutions. However, having read the Seeking Alpha posts by Toma Hentea, I tend to agree with you that we are likely looking at plagiarism here.
First, a small point: The three-month lookback period to calculate returns is exactly the one that I had chosen in the very first post of the In & Out strategy on Quantopian, and it has been the key lookback period of the algo since. So, it is definitely noteworthy that this market timing strategy on Seeking Alpha calculates returns over a three-month period.
Second, and this is very suspicious, the Seeking Alpha author uses “the pair DBB-UUP as an absolute momentum indicator” (i.e., for timing risk on vs off). In my opinion, you do not come up with this pair just like that. Why compare Metals (DBB) and the US dollar (UUP)? For us here in this thread, this pair is organically grown. To quickly recall: I had used DBB in the initial In & Out algo version; Tentor added UUP; Vladimir introduced an in & out algo based on pair comparisons (gold/silver and utilities/industrials; see Intersection of ROC comparison using OUT_DAY approach); and, finally, Dan added the DBB/UUP pair to create a super-algo, mixing the DBB and UUP components of the In & Out into the IoRcuODa. So, it's actually quite a long and intricate way to arrive at this pair and, without this evolution in mind, the pair might even be perceived as non-intuitive (see earlier posts asking for the economic rationale of this pair in particular and the difficulty to fully explain it).
Therefore, it seems that our thread here would at least have deserved a proper reference/mention in the Seeking Alpha article …
Damiano Bolzoni
Hi Peter Guenther didn't want to call it plagiarism and that's why I wrote “inspired” (within quotes). Not sure how much money this guy is making but he's on Seeking Alpha's market place, selling this strategy…
Peter Guenther
Love the “inspired” bit, Damiano Bolzoni!
My personal opinion (others may see it differently): I am absolutely open to someone using the In & Out elsewhere, e.g. to write about it or even to sell strategies based on the concept (if it’s a large-scale ETF, of course, a profit share for all discussion participants would be nice 😊). No problem at all. After all, I deliberately decided to discuss the strategy in a public space and the discussion was very valuable. Without it, I would still be sitting on a version probably pretty similar to the very first In & Out published on Quantopian; no pairs, no percentiles, and so on.
For me personally, the important bit really is the acknowledgement of the concept’s origin and, ideally, a link to our current discussion here on QuantConnect, so that value goes into both directions. Currently, the Seeking Alpha articles don’t bring us anything, it’s only the author generating income. We do not acquire any additional minds from the channel for our discussion, QuantConnect hosting our thread does not benefit from the traffic potential, etc. So, at the moment it’s a very one-sided exchange. And it does not have to be. The fix would actually be relatively simple: acknowledgement + link, why make it entirely one-sided?
Carsten
I was following both, the seeking Alpha and this channel (and the old Quantopian) and learned from the discussion…
Some suggestions which could help to improve the market strategy. Instead running and optimizing the whole strategy, it might be a good idea to measure the effectiveness of the single component. For example I found it very interesting that ALL pairs optimum is 3 month if you just use them single to decide to switch in-out, at least my finding.
Additionally I would be interesting how the momentum optimum was historically, that’s on my list.
An other interesting component would be the VIX,, absolut, relativ or using the term structure (spot VIX to 1-3 month out)
Next would be to feed different pairs into a HMM, just tried this with the VIX and Daly returns and got some decent result.
I would like to stress that all of these I only do in a small python script and if they work I run it in a full simulation (at the moment in zipline, as I need more time to realise it in lean)
I think it would increase the learning curve and awareness to test components singular instead to run them in a full simulation with a lot of other component.
What are your opinions?
Toma
@Peter Guenther I subscribe to your attitude and will act on it. Within a day, I will check all my articles on Seeking Alpha and see where I should add some recognition to those who came out with the ideas that inspired my work. That conversation will be reciprocally advantageous for Seeking Alpha and Quant Connect. Hopefully, Seeking Alpha gets some traffic and in return QuantConnect should get some exposure to the large Seeking Alpha community.
@DamianoBolzoni I do not “sell your strategy”. There is a lot more that I do for the community of Seeking Alpha subscribers. I will acknowledge the few ideas that came from Quantopian mostly, not from QuantConnect. My strategies are much more than what I got from Quantopian/QuantConnect.
Damiano Bolzoni
Toma it doesn’t really matter whether you do “more” for the Seeking Alpha subscribers.
According to plagiarism.org “to use (another's production) without crediting the source” is plagiarism. Even when you don’t earn a financial benefit. Even when you paraphrase it.
Please include sources when appropriate in your posts.
Thanks
Peter Guenther
Thanks for dropping by, Toma. Deal. That sounds like a solid action plan regarding the relevant existing Seeking Alpha articles. Also, good on you for the quick response. I could imagine many in a similar situation who would not have been aware or, worse, would have tried to sit it out. Therefore, the speedy reaction deserves credit. So, I would say: If you discover something of interest in this thread, keep on disseminating on Seeking Alpha, adding a reference + link where relevant. Fingers crossed, we get additional awareness for the concept and a few additional minds and ideas for our discussion here. I am sure, QuantConnect will appreciate the traffic potential as well. Also, if you have an interesting twist in one of your articles, or just want to illustrate an application, feel free to drop a link here and, I am sure, readers of this thread will be interested. (Same if you get a comment on one of your articles that could spur an interesting debate here.)
Thanks also to Damiano Bolzoni for bringing the parties together. The plagiarism definition is also a useful reminder, I didn’t know that they have a whole website on it :)
I reckon we can all shake hands on it, with hopefully new opportunities ahead.
Stephen David Bennett
This is a slightly tangential comment. I've spent about four months experimenting with both this and the similar Vladimir In/Out variant. I made a bunch of changes, tried lots of different things and run a lot of quant connect optimisations. I've pretty much came to the conclusion, other than with brute leverage, I personally can't really improve this in any honest way,
What I am plagued by though are the thoughts that I have not back tested these strategies through enough varied market conditions. We are effectively testing through a 20 year bull run with a few blips. A strategy that can ratchet its way up on a bull run, riding out the troughs in bonds. I would dearly love to see how this would have performed during the 1970s and 80s..
I'd kind of put these thoughts on the backburner but recently I re-read Naseem Telabs “Black Swan” which brought this to the fore again. I've been live trading a variant of this for a while and with each period of drawdown I think “is this the black swan!”
Has anyone created any external data sources which can provide proxies for these signals/etfs going back into previous decades? I started doing it a while ago looking but didn't get that far.
Chak
Stephen David Bennett a good start to improve these public baselines is to incorporate hour and minute timeframes to the Daily Resolutions.
Peter Guenther
Great comments, Stephen David Bennett, thanks for sharing!
I agree that testing the strategy before 2008 would be very interesting. Of course, the challenge that you also point out is that the ETFs providing the relevant signals are not available for most of the time before 2008. In theory, one could reconstruct the ETFs through appropriate universe selections (incl using Morningstar industry sector selectors) and bundle relevant firms in a ‘virtual ETF’. The returns of these virtual ETFs would then provide the relevant signals. In my view, we might not have to go as far back as the 70s or 80s since the world has been a very different place back then, e.g. in terms of market access and participants, central bank and government (crisis) philosophies and strategies, reaction speeds etc., although I do see your point regarding having a long time-series to draw more robust conclusions.
Regarding Taleb, we are still experimenting with this issue in the Amazing returns in & out thread. Here the challenge is that the ‘insurance’ we are taking out (e.g. via put options) to protect us from black swan events is quite expensive (esp. when holding it all the time), substantially grinding down the total return that one can realize. Part of the solution is that one only takes out the insurance selectively/not all the time. We have initial ideas regarding possible conditions (although, of course, this approach conflicts quite a bit with the definition of a black swan = unpredictable event). I reckon another important element which is not yet developed is about ‘taking money off the table’ when the insurance payoff would be high, since otherwise we end up constantly paying without ever realizing a benefit. Yet, this requires again a certain logic regarding when to cash the insurance in.
Manoj Agarwala
Another option to test it for period before 2008 is to use Futures and Mutual Fund prices. Here is link to some data going back to 1995 with this approach in mind but I never got around to fully testing it.
Manoj Agarwala
I love the v8 version but wondering how. the stock splits/dividends are handled here? My fear is that the consolidators used in this algo do not handle these events properly.
Also, I see that this algorithm uses 5 years of history but some of the ETFs do not have 5 years of history when you run it for 2008. I also noticed that the performance changes significantly if you change the 5 year period to 1 year and corresponding extreme percentile from 5 to 1.
Another concern I have is that the extreme percentile of 5 may not work well if we experience long drawn multi year down market.
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!