Found that the docker container is closing for every few days due to ibgateway not responding. As a workaround, planning to save the manageable positions state to files/objectstore and load while starting back.
Is it possible to use the ObjectStore in the lean cli platform while running the app with lean live in the docker container? If supported, what is the python code to save the string representation of object to ObjectStore?
Any other suggestions to save the object states locally in the files?
Thanks
Mia Alissi
Yes, it is possible to use the ObjectStore in the Lean CLI platform while running the app with
lean live
in the Docker container. The Object Store is an organization-specific key-value storage location to save and retrieve data. It is shared across the entire organization, and you can access data across all projects in an organization using the same key.Here is an example of how you can save a string representation of an object to the ObjectStore in Python:
In the above code,
your_object
is the object you want to save, andyour_key
is the unique key you want to associate with this object. Thepickle.dumps()
function is used to convert the object into a byte stream, andcodecs.encode()
is used to convert this byte stream into a base64 encoded string.To view the contents of the Object Store, you can run
lean object-store ls
in your terminal. This command opens File Explorer to show the storage directory. You can delete and rename files in the ObjectStore directly from the File Explorer.As for saving the object states locally in the files, you can use Python's built-in file handling functions. However, please note that the files saved locally may not persist if the Docker container is reset or crashes.
Sources:
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.
Ram Panguluri
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!