In the attached backtest I'm emitting insights as part of a pairs strategy. The code is emitting Up and Down insights as expected, and then going long or short accordingly. Then I have a risk management module that liquidates positions once a certain drawdown threshold is reached.
The problem I'm seeing is that new orders are being created after a position is liquidated, in the absence of any new insights being generated. These new orders happen daily at 3pm (I'm also confused why it happens on this schedule).
I suspect the problem is that even though a position has been liquidated for a given security, there is still an insight associated with that security. I have the insight expiration set to something arbitrarily long for this strategy (30 days), since I don't actually want insight expiration to when a position gets closed. I want a position to close when the risk management module says to, and only enter a new position once there are new insights emitted.
Am I understanding this correctly? I suppose one solution would be to somehow cancel a security's insight after it's liquidated? How can I do this?
Thanks!
Shile Wen
Hi Nick C,
The extra orders are caused by the PCM rebalancing. To address this, I'd suggest passing lambda time: None to the constructor to get EqualWeightingPortfolioConstructionModel(lambda time: None).
Best,
Shile Wen
Nick C
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!