I have several timeseries datasets of stock data, with fundamental indicators. I would like to build a model that selects stocks for buy and hold.

I understand that to perform this task I have two options:

  1. Train a model for each stock: This way, I understand that it is the most practical, however, the amount of data for each model will be very reduced (Each dataset has less than 1000 lines).

  2. Putting all the data together in a single dataset: I didn't find anything on the internet to support this idea, however, I understand that the model would be more robust and would have a much larger amount of data to be trained.

So, what would be the correct way to perform this type of analysis? Any of you would suggest another way?

Thannk you in advance!

  • $\begingroup$ Do you already have a specific model in mind? $\endgroup$
    – Leevo
    Nov 26, 2020 at 19:17
  • $\begingroup$ I thought about using a Random Forest from sklearn or Xgboost. My dependent variable would be the net margin or closing price. All other variables / features would be independent variables. $\endgroup$
    – Ubler
    Nov 26, 2020 at 20:22

2 Answers 2


I would suggest option two. Because this way your model would have the chance to learn something for one stock, which it can apply for other stocks as well. If you provide the type of stock as an input feature, it should be able to distinguish between the specialities which only occure within one stock and the common things. So it is kind of able to transfer knowledge from one stock to the other.

But at the same time, I would suggest to try out both and choose whatever performs the best. This way you can also justify your choice in the end.


The two methods suggest two different assumptions. The first method implies that the same features on two different stocks lead to different outcomes, and therefore learning from both is counterproductive. The second method implies that if you learn something on one stock it will still be true for the other stock. In other words, a good model for one stock is good for all stocks.

How you choose to model the world is left up to you.

I would suggest when using the second method to check that your features don't leak information. For example concatenating two time-series with different value ranges would allow your model to "know" on what series it's working on.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.