When this model rebalances a portfolio based on insights, I've noticed a case where the weighting is not percentage equivalent after rebalancing and it underweighs a security to the benefit of others in the portfolio. Are there any explanations as to why this might occur?
Mia Alissi
The behavior you're observing might be due to the specific portfolio construction model you're using. Different models handle rebalancing and weighting differently based on the insights provided.
For example, the
InsightWeightingPortfolioConstructionModel
generates target portfolio weights based on theInsight.Weight
for the last Insight of each Symbol. If the sum of all the last active Insight per Symbol is greater than 1, the model factors down each target percent holdings proportionally so the sum is 1. This could potentially lead to underweighting a security if the sum of the weights of the active insights is greater than 1.Here is how you can set this model in Python:
Source
On the other hand, the
EqualWeightingPortfolioConstructionModel
removes expired insights from the Insight Manager during each rebalance and removes all insights for a security when the security is removed from the universe. This could also potentially lead to underweighting a security if the security is removed from the universe or its insights have expired.Here is how you can set this model in Python:
Source
It's also worth noting that there could be other factors at play, such as the execution model used, the data resolution, or even market conditions at the time of rebalancing. If you're still having trouble, it might be helpful to share your algorithm or a simplified version of it for further investigation.
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.
Dhruv Bhandari
I am using EqualWeightingPortfolioConstructionModel and ImmediateExecutionModel. Here is a repro (Timestamps in seconds from epoch):
Starting Cash = 10000, FreePortfolioValuePercentage = (default) = 0.0025
Insights:
id,ticker,direction,created-time,generated-time,close-time
0,AFL,up,1622606400,1622606400,1654055999
1,BTI,up,1622606400,1622606400,1654055999
2,ENB,up,1622606400,1622606400,1654055999
3,EPD,up,1622606400,1622606400,1654055999
4,ET,up,1622606400,1622606400,1654055999
5,HPQ,up,1622606400,1622606400,1668056400
6,INTC,up,1622606400,1622606400,1654055999
7,MO,up,1622606400,1622606400,1654055999
8,ORCL,up,1622606400,1622606400,1668056400
9,T,up,1622606400,1622606400,1654055999
10,HPQ,up,1654056000,1654056000,1699851600
11,ORCL,up,1654056000,1654056000,1699851600
12,COF,up,1654056000,1654056000,1699851600
13,HCA,up,1654056000,1654056000,1699851600
14,MPC,up,1654056000,1654056000,1699851600
15,MT,up,1654056000,1654056000,1699851600
16,PBR,up,1654056000,1654056000,1699851600
17,PBR.A,up,1654056000,1654056000,1699851600
18,TGT,up,1654056000,1654056000,1699851600
19,VALE,up,1654056000,1654056000,1699851600
Trades:
Time,Symbol,Price,Quantity,Status,Value
2021-06-02T04:00:00Z,EPD,20.4469816,49,Filled,1001.902098
2021-06-02T04:00:00Z,MO,41.541687,24,Filled,997.000488
2021-06-02T04:00:00Z,ET,8.59294392,116,Filled,996.7814947
2021-06-02T04:00:00Z,T,19.06838486,52,Filled,991.5560129
2021-06-02T04:00:00Z,HPQ,27.83640044,35,Filled,974.2740153
2021-06-02T04:00:00Z,AFL,54.33927114,18,Filled,978.1068806
2021-06-02T04:00:00Z,BTI,32.68156346,30,Filled,980.4469038
2021-06-02T04:00:00Z,ENB,33.60213837,29,Filled,974.4620126
2021-06-02T04:00:00Z,INTC,52.91399769,18,Filled,952.4519583
2021-06-02T04:00:00Z,ORCL,76.8986247,12,Filled,922.7834964
2022-06-01T04:00:00Z,ENB,42.85216643,-29,Filled,-1242.712827
2022-06-01T04:00:00Z,EPD,25.11902424,-49,Filled,-1230.832188
2022-06-01T04:00:00Z,ET,10.52317746,-116,Filled,-1220.688585
2022-06-01T04:00:00Z,BTI,40.43521894,-30,Filled,-1213.056568
2022-06-01T04:00:00Z,MO,48.89149034,-24,Filled,-1173.395768
2022-06-01T04:00:00Z,AFL,58.83359373,-18,Filled,-1059.004687
2022-06-01T04:00:00Z,T,19.8552624,-52,Filled,-1032.473645
2022-06-01T04:00:00Z,INTC,42.97076059,-18,Filled,-773.4736906
2022-06-01T04:00:00Z,HPQ,38.23469876,-5,Filled,-191.1734938
2022-06-01T04:00:00Z,MT,31.85662242,35,Filled,1114.981785
2022-06-01T04:00:00Z,VALE,16.291841,69,Filled,1124.137029
2022-06-01T04:00:00Z,PBR,10.5440608,107,Filled,1128.214506
2022-06-01T04:00:00Z,COF,124.1439321,9,Filled,1117.295389
2022-06-01T04:00:00Z,PBR.A,9.493742397,118,Filled,1120.261603
2022-06-01T04:00:00Z,TGT,156.4628962,7,Filled,1095.240274
2022-06-01T04:00:00Z,MPC,99.81733948,11,Filled,1097.990734
2022-06-01T04:00:00Z,HCA,209.8354766,5,Filled,1049.177383
2022-06-01T04:00:00Z,ORCL,71.50151989,3,Filled,214.5045597
HPQ appears underweighted after this 2 year period, and the others overweighted. I think this may be related to your explanation about this model but I'm keen to understand exactly why this is happening?
Thanks in advance.
Mia Alissi
The
EqualWeightingPortfolioConstructionModel
you're using aims to give equal weight to all securities in the portfolio. However, the actual weights can deviate from the equal weights due to several factors.One factor is the price change of the securities. If the price of a security increases significantly after the portfolio is rebalanced, it will take up a larger portion of the portfolio, making other securities relatively underweighted.
Another factor is the execution model. The
ImmediateExecutionModel
you're using places market orders, which are filled at the current market price. If the market price changes significantly between the time the order is placed and the time it's filled, the actual amount of the security bought or sold can be different from the intended amount, leading to deviations from the equal weights.In your case, it seems that HPQ is underweighted after the 2-year period. This could be due to the reasons mentioned above. For example, if the price of HPQ decreased significantly during this period, it would take up a smaller portion of the portfolio even if the number of shares held remains the same.
To understand exactly why this is happening, you would need to look at the price changes of the securities and the order fills during this period. If you have the data, you could plot the portfolio weights over time to see how they change and identify any patterns.
Here is how you can set the portfolio construction and execution models in Python:
Source
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.
Dhruv Bhandari
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!