Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Feature matrix generation with future price

Hello,

I'm new to Quantopian. I'm trying to build a feature matrix to run machine learning in a supervised manner.

The features can be anything relating to a stock in a trading day (fundemantal and/or technical). For example, some features can be high, low, close, market cap, PE ratio. Based on these features, I want to make a prediction on how high the price will be three calendar months in the future (the label).

What's the best way to go about what I'm trying to do?

I already know how to generate the features using a daily scheduled function that accumulates the features in a pandas dataframe (let me know if there is an easier way to generate the features). However, I do not know how to query for a stock price three calendar months in the future.

I don't think what I'm trying to do is untypical, so I'm sure some of you folks have tried to do something similar and I want to learn from your wisdom.

1 response

How do you generate the features using a daily scheduled function? Are you talking about research environment or backtesting?

I would suggest to code each feature calculation as a pipeline factor, so that you can easily swap them between research and backtest environment. Also you might have a look at factor tear sheet. That's not related to machine learning but it is used to analyse the ability of a pipeline factor (or a feature in your case) to forecast price change. That NB would show you how to use Q API to conduct your own research and I am pretty sure you might reuse lots of the code in there.