Scaling and Feature Selection for LSTM Financial Forecasts
Summary
The document discusses preparing financial data for an LSTM intended to predict index direction or returns. It compares using price levels with returns or differences, and explains that the concern about values exceeding a scaling range reflects both nonstationary price levels and the choice of scaling method. Suggested options include differencing prices, winsorizing values under min-max scaling, or using z-scores; the appropriate choice depends on the model setup and solver behavior.
It also addresses interpreting learned features, adding indicators such as moving averages and volatility, pooling data across index constituents, and applying dimensionality reduction. Neural networks may combine inputs in ways that do not map cleanly to familiar indicators, making interpretation difficult. The question reports a test accuracy and return figure, but gives no experimental design or benchmark, so these figures do not establish predictive quality. Pooling constituents is presented as worth exploring when they plausibly share the target-generating distribution.
Key ideas
- Price differences or returns can address nonstationarity more directly than scaling raw price levels.
- Winsorization and z-score scaling are alternatives to min-max scaling when new observations exceed the historical range.
- Neural networks may combine inputs in ways that do not correspond to interpretable indicators such as moving averages.
- Pooling constituent data is worth considering when the modeled relationship is plausibly shared across stocks.
- Reported accuracy and returns cannot be judged without details about the evaluation design and benchmarks.
Tags
Full text
# Scaling (Data prep) & Feature selection for the financial Data for LSTM Models # Scaling (Data prep) & Feature selection for the financial Data for LSTM Models Overview I'm training an index e.g. FTSE100, where I have 8 years of past data (daily). I also have a list of its constituents. For each stock, I have the following features: `Date`, `Open`, `Close`, `High`, `Low`, `Volume Traded` SCALING I decided to predict whether to buy/sell the index. Instead of using close values, I decided to optimise for percent change, hence I create a new variable `percent_change`, which is not bounded by 1. Does this make it a bad metric, and should I use close prices instead? Why I didn't use close values? I wasn't sure how to scale it to run it properly. Currently, my model input is 10 previous percentage changes, e.g. `[t0, t1, ... , t10]` predicting `[t11]` where `ti` is the percentage change on day `i`. If I was to use scaling, I would constantly come across new values. Additionally, if tomorrow brings a new all time high, I will need to rescale the data and re-train the model. Additionally, I thought about replacing percent change by actual index denoted by `pi`. I thought about scaling just the moving window period `[p0, p1, ... , p10]`, however, the predictor `[p11]` could be outside the bound of 1. Question: Does LSTM easily handle inputs and outputs > 1? FEATURE SELECTION Please advise me which independent variable to use: `percent change` or `close price` (and how should I scale it). I've trained the model on 2500 observations (500 epochs) giving me a 53% accuracy on the test set (is it good?). I also made 30% returns over 600 test days. Currently the only features I'm using are rates of change for the past 10 days. Which features did my model learn? I'm not sure. Did it learn moving averages, linear gradients/approximations volatility etc.? Or should I include them in my model as `[t0, t1, ... , t10, MA10days, MA3days, Gradient3day, Volatility3day]` ? TRAINING THE MODEL Since I have 100 constituents, would it make sense to run/pre-train the same model on all of these stocks? All stocks are highly correlated with the index, and I thought about calculating MA, Gradients and so on for each of the `Close, Open, High, Low` and then running PCA to select only a few components. IF YOU MADE IT THIS FAR I know this is a long question to ask, and I thank you for any help given, I will reward the 100 points that I have to the best answer! Thanks ## Answer by madilyn (score 3, accepted) https://quant.stackexchange.com/a/37672 > If I was to use scaling, I would constantly come across new values. Additionally, if tomorrow brings a new all time high, I will need to rescale the data and re-train the model. You're actually facing 2 underlying problems: - This is less of a problem of scaling than a problem of stationarity. A simple solution to this is to take first differences of close prices instead of raw close prices. - The more trivial issue is the robustness of your scaling step. There's various ways to counter this. In the case of min-max scaling that you're using, one possible way to address this is winsorization, where you artificially censor all features $>1$ to 1. If you don't want to censor your data, you could use z-scores instead. Without knowing the exact training setup, it's likely that you're scaling your data to improve the convergence of your LSTM solver, and unless your solver has a specific sensitivity to z-scoring or censoring, both approaches are practically feasible. (This sort of sensitivity may arise from more advanced tricks like meta-learning, e.g. learning an LSTM to optimize your LSTM.) > Which features did my model learn? Depending on the software package that you used, it should have a results output or results object, which should give you feature scores or feature importances. However, neural networks are often used to combine features so the answer should be less of selecting features than finding new ones. > Did it learn moving averages, linear gradients/approximations volatility etc.? These new features often have no simple, intuitive interpretation, so it can be quite meaningless to attempt to interpret the learned features as conventional quantities such as moving averages. This is a common weakness of neural networks. > Since I have 100 constituents, would it make sense to run/pre-train the same model on all of these stocks? It depends on what you're trying to model. If there's reason to believe that whatever you're trying to predict is drawn from the same ground truth distribution across all constituents, then sure, it's worth trying.
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.