Hi, I'm trying to use ObjectStore to save order fill data. I want to read it in my OnData function to use the data in my buy rules. Is there a way to do this? I'd like it to work like this:
class CalculatingBlackManatee(QCAlgorithm):
def Initialize(self):
def OnData(self, data):
self.ObjectStore.Read()
def OnOrderEvent(self, orderEvent):
self.ObjectStore.Save()
Or to be able to store and recall the data outside the functions so that data from all the functions could be stored or used by all the functions.
My goal is to save/recall/delete certain data so that I can use past variables etc. but right now I'm only able to recall the data under the function that I saved it under.
Derek Melchin
Hi Luke,
Reading and saving in the ObjectStore is an expensive operation because it is reading and writing to a file, not memory. Instead of using the ObjectStore, we can create a class variable inside the `Initalize` method. Any function within the class can then access the variable. See the attached backtest for reference. In addition, it may be helpful to review our Introduction to Financial Python tutorial.
Best,
Derek Melchin
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.
Luke Algo
I actually needed the objectstore I believe, because I was saving past order fill data in relation to lots of the same security. However I did end up getting it to work across functions. I think it worked because the file save location is outside the function if that makes sense. Thanks
Luke Algo
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!