Back

Algo Framework ETF Momentum Rebalancing using Mean Variance Optimization

Hello All!

Yesterday we presented a webinar for Interactive Brokers on using Mean Variance Optimization for ETF Portfolio Rebalancing. We implemented it in the Algorithm Framework -- a new way we're offering for users to design algorithms which is more modular and extensible.  

The Framework was built using the most common abstractions we see in the community. It has 5 modules - Universe Selection, Alpha Creation, Portfolio Construction, Execution and Risk Management. If you're interested I'd recommend checking it out as a way to improve your algorithm foo! 

The key module we discuss here is the Mean Variance Portfolio Construction Model. This takes the historical returns of the assets presented by the Historical Returns Alpha Model and uses them to construct the portfolio! Its fascinating stuff on the cutting edge of Quant finance so I'd highly recommend learning the new framework.

Check out the video and slides below!

https://www.youtube.com/watch?v=YcuMzLmOzH0

 

https://www.slideshare.net/quantconnect/quantconnect-etf-momentum-asset-allocation
Update Backtest






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.



Hi all!

I am also getting errors when trying to backtest this algorithm.

Best,

Andrew

0

andrew_czeizler, this is an old post. Now we've already put "HistoricalReturnsAlphaModel" and "MeanVarianceOptimizationPortfolioConstructionModel" into the LEAN framework library. Please see the attached algorithm. 

You'll find the model source code on Github

https://github.com/QuantConnect/Lean/tree/master/Algorithm.Framework
0


I cloned the algo from above, and I went to run the backtest and I got a bunch of insufficient buying power errors.  Any idea as to why this is happening?  Below is an example of the errors I am seeing.

 Backtest Handled Error: Order Error: id: 101, Insufficient buying power to complete order (Value:8129.9063), Reason: Id: 101, Initial Margin: 4065.9531329395, Free Margin: 1253.9592675246086301998343

 Backtest Handled Error: Unable to compute order quantity of DBC. Reason: The portfolio does not have enough margin available.. Returning null.
0

Update Backtest





0

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.


Loading...

This discussion is closed

 
";