Hi all,
This question take place when live trade algorithm crashes. My strategy actions sometimes depend on what were previous states. For example, what was the profit of the last 5 trades. It is just an example. When the strategy developed is live trading, and the strategy crashed, I would like to recover the last state when I re-deploy it. Otherwise, the strategy is starting from scratch, instead of continue the expected logic. Of course, this issue doesn't happen on backtesting.
I don't expect to save complex objects. A simple list of numbers seriealized in a json could be enough. I guess I could use a key/value store db through rest, but I guess it is something too complex. I wonder if there is a better way, that doesn't evolve to use thirty party services.
Thank you.
Peter Guenther
Very relevant question, Gabriel Moncarz. I was trying to do something similar for my In & Out algo and needed to save certain information, for instance, when the algo exits the market so that this action is not ‘forgotten’ when live trading crashes.
For an implementation highlighting the relevant lines in the algo, see here.
Or for an implementation in a somewhat tighter/less complex algo code, see here.
All the best.
Gabriel Moncarz
Thank you very much Peter. I didn't know about Object Store. It is all that I need, if it also work on Lean side. do you know if it work when I deploy the strategy locally with Lean for real money, or it just work on QuantConnect side, which of course has sense.
Thank you again.
Gabriel Moncarz
I confirm it also works with Lean-Cli on a local live trading environment. Reading the source code (thank you open source), I realized that the info of the ObjectStore is persisted on /LeanCLI/storage. So, if you use the same docker instance, after a reset the info is kept. What I am not sure, is how QuantConnect do it on QuantConnect side. Because probably every time a project crashes, I think another docker instance would be open with a new redeploy. My Docker knowledge is more than basic, but I suppose that they are moving the storage directory to the new docker image, but it is just my guess.
Anyway, thank you Peter, because without your help, I was going to look to a similar service outside QuantConnect. Thank you again.
Gabriel Moncarz
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!