Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Any way to use data.history without having to go through each day? How do you import data all at once with date range?

I would like to train a Naive Bayes classifier on data I get through the data. history function. I start with an empty data frame and then I get the data when the market closes on a particular day and append it to my data frame and retrain my model on the whole data. So my model learns as it trades. Is there any way I can pre-train the data before I enter paper trading? This would be like training the model in backtesting and using the trained model for paper trading where it will be trained with the new data as well as the backtesting data.

2 responses

Hello, Posted this question a couple days ago. Wondering if anybody had an answer? I found that you can do this in research by importing data with a date range, but is there any way you can do this is to paper trade?

Take a look at this post for some ideas on using ML in both the research and the algo environments (https://www.quantopian.com/posts/machine-learning-on-quantopian). There are actually three posts so maybe look through them all.

Be careful simply appending data each day to a data frame. The data will not be split adjusted. If there is a 2:1 split then it will look like the stock price dropped by 50%. Stock splits actually happen more often than one would think. Especially if the resolution is daily, it's probably better to periodically fetch all new training data using either pipeline or data.history each time one wants to re-train the model. That way it will all be split adjusted and cleaned up for you.

Good luck.