Intro
Superior algo returns can be thought of as being the result of two components: a great strategy regarding ‘what stocks to buy’ (the stock selection component, SEL) and a ‘clever timing’ (the in & out component, I/O) regarding when we are ‘in’ the market and hold the stocks versus when we are ‘out’ of the market and hold alternative assets such as bonds. We often focus on optimizing SEL and tend to neglect I/O; thus, for an important discussion of recent I/O tactics, see here.
Focus of this thread: Optimal SEL + I/O combinations
It is worthwhile to separately optimize SEL and I/O. However, the ultimate total return will also be determined by a certain synergy or dissonance between the two components. So, it seems that we won’t get around the arduous task of individually testing (all possible) combinations to identify optimal SEL + I/O pairs, which is the eventual focus of this thread. I reckon a preparatory step can be to dig up all the hidden SEL and I/O treasures from this forum and beyond to see what inputs are available for the combinations.
Ultimate objective
Let's get rich together, why not?
Biggleswurth
Ian McCann
It looks like this isn't doing so well since mid february. Possibly due to meme stocks becoming more popular and thus potentially harder to predict?
Peter Guenther
Thanks for sharing this insight, Ian McCann. I assume you are referring to the QualUp stock selection (?). I think you are right, the algo picks up certain meme stocks. This is due to the momentum logic. I am trading a QualUp-ish logic manually (will move to auto trading at some point), so had to check here on QC, and to add to your point: The in & out logic also seems to play a major role. Returns for the following combos since mid Feb; they differ vastly:
[Qual Up] + [InOut]: -32.79% <---------> [Qual Up] + [DistilledBear]: -0.69%
As a reference, since the beginning of the year:
[Qual Up] + [InOut]: +28.50% <---------> [Qual Up] + [DistilledBear]: +50.84%
So, I guess you are right, meme stocks are distorting the picture and therefore timing is a key driver of returns. A certain component of the returns is probably not highly predictive for the future and comes with elevated risk/volatility.
Samuel Schoening
It is a beautiful concept this. Do not be disheartened by the recent drawdown, the market as a whole has been flailing without direction in the past few months. My own algorithm that had been effectively infallible through the past few years got battered by a series of unprecedented events we see unfolding right now. My hedges (TLT, SCO *2x inverse oil, GLD *miraculously falling amid inflation panic and a brainless Bitcoin mania, and UVXY *has been inflated for the entire year and has lost some of its inverse correlation with overall market). I am speaking as someone in a similar boat, keep up the good work!
Vasil Lazarov
Hi, sorry for the silly question! I'm new to the platform. Is the source code of the algo, discussed here, uploaded somewhere, where one can see latest version and revisions, or we have only the separate examples kindly shared by people in the thread?
Derek Melchin
Hi Vasil,
All the public versions of the strategy are attached throughout this thread and a this second thread. To view the source code in the QC IDE, click the Clone Algorithm button in one of the attached backtests above. In this thread, the latest algorithm shared is available here.
Best,
Derek Melchin
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.
Peter Guenther
Thanks for your words of support and for sharing your insights regarding hedges, Samuel Schoening! Agreed, let’s continue the quest for amazing returns and against drawdowns, return fluctuations, etc.
Welcome to the discussion, Vasil Lazarov! Derek Melchin has provided a cool overview there. One additional thought: There are multiple algos in this thread that do things differently, particularly in terms of how they select stocks and when they are invested in the equity market versus bonds. So, the thread is not necessarily building toward one algo (with a latest version) but instead is a selection of multiple algo ideas that we can develop further (i.e., in the sense of 'a marketplace of ideas'). Feel free to try out things and leave a post if something interesting pops up.
Peter Guenther
I just quickly wanted to feature a recent algo here that buys call options (instead of the stocks) based on the selection of the DistilledBear + QualUp combo discussed in this thread. So, this could be interesting for folks who are open to trading options.
.ekz has developed the algo and has shared it here: link
Also, see the modifications by Derek Melchin (efficiency gain) and spacetime (error fix).
Strongs
Hi guys, I have used a Piotrosky F-score as fundemental screener for the stocks
Peter Guenther
Very nice work, Strongs! Thanks for sharing. This is quite sophisticated code including the different classes etc., so plenty there to learn from your approach.
It is also a new stock selection strategy, so the combo would be: [F-Score] + [DistilledBear].
I think this gives us the following stock selection strategies in this thread:
[TQQQ], [ValuationRockets], [QualUp], and [F-Score]
which can be combined with the following in & out strategies:
[InOut] and [DistilledBear]
So, eight possible combinations to choose from. Very cool!
.ekz.
How timely!
I just learned about the Piotrosky F-score recently, and was mulling over how to implement it.
It's moment like this that make this platform / community so great.
Fantastic work Strongs and thanks!
Anthony B
Has anyone traded any of the variations? Does live testing match the backtests during the same time period? Tried live testing the F-score variation but the algo does not open trades while backtests during the same period show open orders.
Chak
Yes, it does work.
Unfortunately, without backtest/live trade results it's hard to answer your question.
Derek Melchin
Hi Anthony B,
We've outlined reasons why backtests can produce different trades than live trading over the same period. Refer to the documentation here.
Best,
Derek Melchin
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.
Davidii111
Hello,
Im also trading from EU with IB. @Dimitar Dimitrov did you find a solution for the ETF problem?
Derek Melchin why do QC limit europeans to trade EU ETF:s? Isn't it the IB/broker which sets the limitations?
Varad Kabade
Hi Davidii111,
Interactive Brokers do not allow EU residents to trade ETFs as they follow restrictions set by the EU. Refer to this thread for more information.
Best,
Varad Kabade
Zicai Feng
hi pplz, i have transformed Strongs' P-score backtest into an Algo Framework, so for those who are keen on Algo framework…(i tried to maintain the original codes as much as possible, obviously if u start Algo Framework from scratch, you would write it differently and neatly)
As per some comments above, think the view is that we have squeezed enough juice out of the alpha/factor building stage for this strategy. probably harder to improve further without dangerous datamining. However, the areas that can potentially have more upside are portfolio construction, risk management etc. So hopefully having the Algo Framework in place can help facilitate that.
(btw, this algo framework version produces result largely inline with the base version, however, i notice some difference, eg for SubscriptionManager.AddConsolidator for the etfs (eg gold), it updates different timestamped data if the consolidator is called in the QCAlgorithm class, vs if its called in the AlphaModel class)
Peter Guenther
Thanks for sharing, Zicai Feng! This is good work and useful pointer, eg regarding risk management. I am currently looking into options for risk management, inspired by other people's work. Hopefully there will be something to share at some point in the future.
Tom Penrose
Hey guys,
I've been lurking on this thread for a while. I'm new to all of this but I have played around with the different versions of this strategy and I was wondering; the strategy looks at several safe haven assets, but it never buys them. Could it be beneficial to buy these assets rather than just switching exclusively to TLT/TMF?
Maybe I'm missing a piece but I would think it would help a bit to expand on the out component of the strategy.
Peter Guenther
That is a valid thought, Tom Penrose. Indeed, the focus has been strongly on the equity component, while the ‘out’ asset mostly has been ‘bonds by default’. I think that some people tried substituting in gold, but total returns dropped, if I recall correctly. So, it might be a question of timing: When do we go into bonds versus when do we go into alternative assets such as gold? In the main In & Out thread, we are musing about whether inflation expectations may provide a useful signal to decide when to prefer gold over bonds. Still work in progress.
Peter Guenther
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!