Using Recent Data and Returns for LSTM Stock Forecasting
Summary
The discussion addresses whether a long historical price series is suitable for forecasting a stock whose behavior has changed over time. It notes that an LSTM can be configured with a chosen number of time steps, so each training sample can use a recent window of observations. This allows testing shorter lookback periods rather than requiring every sample to use the entire available history.
The response also highlights a central modeling concern: prices and their features may be nonstationary, especially when past volatility and momentum differ from more recent behavior. It recommends forecasting returns instead of raw prices and constructing features that are more stable over time. These are general modeling suggestions, not evidence that a particular window or feature set will improve accuracy; the document gives no validation results or method for selecting the lookback period.
Key ideas
- An LSTM input window can be set to use a selected number of recent time steps.
- Historical regime changes can make price targets and input features nonstationary.
- Predicting returns rather than raw price levels may provide a more stable target.
- Features should be designed to remain useful across changing market conditions.
- The best lookback period requires validation and is not established by the discussion.
Tags
Full text
# Answer by autoencoder (score 2) # In stock prediction with LSTM, is there a need to get a dataset for a specific time period in order to predict future close price? I am currently trying to predict the close price of the TSLA stock for March 2022 using LSTM model. Initially, I was using TSLA stock data starting from 2012 to of course March 2022. However, I was wondering if this is effective as the TSLA stock has undergone great changes in terms of its volatility, behavior, and momentum over the years. Below you can see the stock's price history starting almost 2014. After 2020 its behavior and momentum change drastically. Is there any way to extract only those last n months' data that can help predict future prices with higher accuracy? ## Answer by autoencoder (score 2) https://quant.stackexchange.com/a/71204 The LSTM layer expects input of shape `(batch_size, n_timesteps, n_features)`, you could adjust `n_timesteps` so that each sample uses only last n-month's data. Also as you already noticed, the prices have undergone dramatic changes over time, this affects the modeling: your target is not stationary, and your features are probably also not stationary. (Given your context, I'm assuming you are using prices to predict prices.) You'll be much better off by predicting price returns and making some features that are stable over time.
Shown in full with attribution under the source's licence. Licence: CC BY-SA 4.0 (Stack Exchange)
This summary was written by Stratmill's research agent from the original; it is not a copy of the source.