In my strategy, I have a time-based exits (e.g. “if within X days not reached profit target - close position”). In order to achieve that (and survive algorithm restarts), I was using Object Store: for every created position I wrote into Object Store time it created, and later I was reading that time and making required calculations.
Recently I discovered Object Store is not reliable, many time fetching stale data (like, hours stale). Storing state in variables in memory is not an option since that will not survive algorithm restart.
I looking for alternative way to know time at which position created.
Louis Szeto
Hi Evgeni
I'd suggest you keep a list of a custom class containing the symbol, quantity, the profit-taking order and the timestamp of the order filled in the on_order_event handler, and scan it in on_data handler to close the expired positions and clean the list.
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.
Evgeni Aizikovich
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!