Hi,
Is there some (example) code available somewhere that would enable conducting this kind of analysis (portfolio
construction):
- https://blog.thinknewfound.com/2019/07/ensemble-multi-asset-momentum/
-
https://docs.wixstatic.com/ugd/7c4c63_b3f66bbea0f648e19e535b1da004aeba.pdf
-
https://docs.wixstatic.com/ugd/7c4c63_735bc38a987340cc8db85691a41dbfe4.pdf
So to be able to create average/ensemble weights based on a set of
parameters (like rebalance date, look back periods for momentum and
whatever the parameters are).
Would appreciate a simple SPY-TLT momentum switching example where lookback period and rebalancing date/day would be shown.
Thanks.
Kind regards,
Klemen
Alethea Lin
Hi Klemen,
You can look through some of the basic portfolio construction code on GitHub and some sample framework algorithms for inspiration. We do have 5 specific examples, but please be creative and try to implement this portfolio construction model in QC! If you run into any questions about the API, please do not hesitate to reach out again.
Secret Information
I don't know how to take a simple portfolio creation, let's say, for the sake of example, this one discussed here Adaptive Asset Allocation: ReSolve Asset Management . As you can see it trades only at the end of monthÂ
self.Schedule.On(self.DateRules.MonthEnd("SPY"), self.TimeRules.BeforeMarketClose("SPY", 15), Action(self.allocate))
and has three other paramters
self.momentum_lookback = 126 self.correlation_lookback = 126 self.volatility_lookback = 21
What I want to create (and have no idea how to do it as a beginner in QuantConnect) is many sub portfolios (tranches) each parametrized in a different way and with rebalancing every trading day of the month (not only last trading day of the month) to hopefully crete a more roboust "model" (avoid overfitting to turn of the month and other cherry picked/lucky paramters).
For example I want to have momentum_lookback in the range of 120 to 130, correlation_lookback in the range of 110 to 140 and volatility_lookback in the range of 15 to 25. This means I am simultaneously running 21(number_of_tranding_days_of_the_month) * 11(number of distinct values for momentum_lookback parameter) * 31(number of distinct values for correlation_lookback parameter) * 11(number of distinct values for volatility_lookback parameter). From all this tranches (slightly differently paramterized portfolio constructions) I need to then, every day, consolidate positions and do the trading (delta from current portfolio holdings to desired portfoolio holdings).
Please look at the links I provided in original question. Does this makes sense now? How to do this in QuantConnect? Can you maybe guide me on how to extend Adaptive Asset Allocation: ReSolve Asset Management ?
Douglas Stridsberg
Hi Klemen,
There are, broadly speaking, two ways to approach this:
- Create an Alpha Model (see documentation for more information on what Alpha is) that takes as inputs momentum, correlation and vol lookbacks. Create one instance of this model for each set of parameters. Aggregate the resulting insights inside a Portfolio Construction model.
- Break down the mathematics into what the "average" covariance matrix would have been for the different lookback values and use that matrix to compute the minimum variance weights. It's not immediately clear to me how to do this or if it's even possible, but what I am certain of is that there are ways to compute these values more efficiently than creating an Alpha model for each pair.
Good luck and feel free to ask for help once you've given it a try! I imagine approach #1 is easier to start with. Once you've created an Alpha model to calculate one set of values, you can simply extend this out to all values.This is a really robust approach but can come at the cost of computational inefficiency since you're looking at such a huge number of pairs (11*31*11 = 3751), each one which would need an instance of your Alpha model.
Â
Jared Broad
To do the code above then at some level, you'll need an abstraction before passing it to QuantConnect's basic API to implement. You won't get that stuff "out of the box" -- but its code, so you can build whatever you need. The API provides a thousand different types of lego blocks it is up to you how you clip them together.Â
public class KlemenPortfolio { // Do Stuff, }
Â
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.
Secret Information
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!