LEAN is the open source
algorithmic trading engine powering QuantConnect. Founded in 2013 LEAN has been built by a
global community of 80+ engineers and powers more than a dozen hedge funds today.
Alpha League Competition: $1,000 Weekly Prize Pool
Qualifying Alpha Streams Reentered Weekly Learn
more
Just published the 8th video of my algorithmic trading course using Python and the QC platform. Below you can find the backtest and code from that video. Simply click the “Clone Algorithm” button to copy the code to your own projects.
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.
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.
Log Up
1.2k Pro
,
Hi Louis Thanks for the video! I have one question: when we execute self.SetHoldings(self.portfolioTargets), what happens to the securities which are already in portfolio and in portfolioTargets too? I suppose if the ratio is same then nothing will happen, but if it's changed then it will be bought/sold according to the ratio specified? Am I interpreting it right? Thanks.
0
Louis Szeto
STAFF Pro
,
Hi Log Up
There would be no effect on other existing positions. The SetHoldings method is actually placing MarketOrder in quantity representing a proportion of the portfolio value for an asset.
If you want to rebalance the portfolio, you could consider
1. Liquidate all positions and use SetHoldings with a list of PortfolioTarget
2. using the Framework and InsightWeightingPortfolioConstructionModel. Active insight weights sum up larger than 1 will rebalance when new insight arrives. This could avoid excessive orders when singular order is desired instead of a whole portfolio change.
Best Louis
0
Edited by Louis Szeto
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.
Log Up
1.2k Pro
,
HI Louis Szeto , thanks for the reply. Let's say I have SetHoldings with TSLA as 0.1(10%) previously, and in next iteration of OnData I set it to 0.2(20%) of my portfolio, then what will happen in this case?
0
Louis Szeto
STAFF Pro
,
Hi Log Up
For the same asset, it would hold the new set ratio (i.e. 20%). The other assets would not change their existing positions although (they will not automatically rebalance/adjust).
Best Louis
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.
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...
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!