In my QuantConnect trading algorithm, I train a neural network on a dataset and do live trading on the same dataset. Is there some way I can pass the pandas dataframe from my training into my SubscriptionDataSource, to improve efficiency and reduce data duplication?
Cheers!
Mia Alissi
In QuantConnect, you can use the Object Store to save your pandas DataFrame after training your neural network. The Object Store allows you to save objects between different parts of your algorithm, such as between the training and live trading phases.
Here is an example of how you can save a pandas DataFrame to the Object Store in JSON, Parquet, or Pickle format:
(Source: QuantConnect Documentation)
However, it's important to note that the
SubscriptionDataSource
class in QuantConnect is used to specify the source of external data for your algorithm, and it doesn't directly accept a pandas DataFrame. TheGetSource
method of your custom data class instructs LEAN where to find the data, and this method must return aSubscriptionDataSource
object, which contains the data location and format.If you want to use the data stored in the Object Store as a data source for your algorithm, you might need to write a custom data reader that can read the data from the Object Store.
Please refer to the QuantConnect Documentation for more information on how to use custom data in your algorithm.
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.
Tom Frew
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!