Hi All,
I don't have luck on my strategy. Hope that anyone can give me some insights of it.
My strategy is that, i will use coarse universe to get several stocks with resolution=minutes. I will then fire the insight at first hour bar for the stocks.
For the insight i fired, i will buy 5% of my total portfolio and hold for 30days
Here are my insights (p.s. backtesting start = 3Jan2022 / end = 5Jan2022). Period is set to be 30days
As i don't want to rebalance daily, therefore, i set both of them are false. Problem: i found that no order can be triggered.
# i managed to create my own fixed weighting portfolio construction model that will allocate 5% for an insight
self.SetPortfolioConstruction(FixedWeightingPortfolioConstructionModel())
self.Settings.RebalancePortfolioOnInsightChanges = False
self.Settings.RebalancePortfolioOnSecurityChanges = False
self.SetExecution(ImmediateExecutionModel())
Then, i tried to play around with the settings, and enable the rebalance portfolio on security change
self.Settings.RebalancePortfolioOnInsightChanges = False
self.Settings.RebalancePortfolioOnSecurityChanges = True
After setup like that, i can see order placed.
Problems: I am not expecting a sell order for SYTA on 5Jan as the insight set to be 30days. and i am not expecting a rebalance for NYC at 2nd row, and a sell of NYC on 4th row.
I changed the Rebalance setup with Insight changes = true
self.Settings.RebalancePortfolioOnInsightChanges = True
self.Settings.RebalancePortfolioOnSecurityChanges = False
The orders are as below, same as above.
I am expecting the following orders
2022-01-03 NYC Buy Market 5% of portfolio
2022-01-04 NYC Buy Market 5% of portfolio
2022-01-04 SYTA Buy Market 5% of portfolio
2022-01-05 NYC Buy Market 5% of portfolio
2022-01-05 TBPH Buy Market 5% of portfolio
May i know what's wrong with my setting?
The problems so far are
- insight period=30days doesn't hold the stock for 30days, it will sold in the next day
- if i disable rebalance, it won't make any purchase
- How can i purchase the stock daily and hold for 30days without rebalancing? Should i give up the portfolio construction and using insight but directly place the order inside ondata event?
Thanks for advise
Li Mike
Same problem.
If I set self.Settings.RebalancePortfolioOnInsightChanges = False, self.Settings.RebalancePortfolioOnSecurityChanges = False, Then my EqualWeightingPortfolioConstructionModel won't fire. I think it should fire daily because my resolution is daily.
Li Mike
Same problem.
If I set self.Settings.RebalancePortfolioOnInsightChanges = False, self.Settings.RebalancePortfolioOnSecurityChanges = False, Then my EqualWeightingPortfolioConstructionModel won't fire. I think it should fire daily because my resolution is daily.
Enjolras Leigh
i am thinking rebalancing is the trigger point to build up portfolio. So, we need to ensure rebalancing is on to purchase the stock. But my use case is purchase different stock everyday and i don't want to rebalance my existing stock.
It seems like i got no talent to create my own portfolio construction model for that, i am thinking to give up the framework but using the classic way to do so
Eric Kao
Would love to get some assistance on this same issue. Over half of my trades are rebalances triggered by taking a new position. Makes it impossible to maintain multiple positions without generating half a dozen rebalancing trades every new directional insight.
I tried updating within the construction model for existing positions' targets to become the current “total position size” / “total portfolio value”, but this is fruitless because the rebalance is triggered upon generating an insight in the alpha model, which occurs beforehand.
Eric Kao
While I'm quite happy to help finance my broker's third yacht, this makes it difficult to cleanly understand the performance of trades. i.e.:
I took a long position on stock ABC and exit in 14 days, but triggered a dozen +/- 1 share rebalancing trades in between. Now I have to calculate an active-time-and-price-weighted-average-entry-condition to calculate profit statistics.
Enjolras Leigh
i used several hours to go through the doc and source code, and i ended up with customize my own CreateTargets function to trigger a purchase when there is an insight.
You can go to the PortfolioConstructionModel.cs and you will know why it behalf like that.
https://github.com/QuantConnect/Lean/blob/master/Algorithm/Portfolio/PortfolioConstructionModel.cs
code snippet as below for my customization that take the insight the purchase stock, and no rebalancing due to a new purchase
Louis Szeto
Hi All
The rebalancing behavior is governed by the PortfolioConstructionModel. You can take a look at their docs. Most of them have a “rebalance” argument which decides the rebalancing frequency. You may set it to a very long period:
Best
Louis
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.
Enjolras Leigh
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!