Skip to content
All library documents

Building Historical Price Scenarios with Labeled Outcomes and Features

Article Quant Q&A · Author: mickG

Summary

The document considers whether machine learning can produce several plausible future price paths from historical closing-price behavior, for planning trade adjustments. The answer describes the task as supervised learning: define and label outcome classes such as reversals, range days, or failed breakouts, then train a classifier using features available at the forecast time. Decision trees and random forests are mentioned as possible starting models, with features such as recent prices, moving averages, and prior day types.

The central challenge is choosing labels and predictors that contain useful information; a model cannot create predictive signal from closing prices alone. The answer recommends fitting on part of the history and evaluating on separate data, then revisiting features if the model overfits or underfits. It does not provide a concrete labeling scheme, probability calibration method, or evidence that any scenario forecast is profitable or reliable. A market simulation approach is mentioned as an alternative, but not developed. The proposed workflow therefore offers a starting framework, not an off-the-shelf method for generating dependable ranked price trajectories.

Key ideas

  • Define outcome labels that represent the future price scenarios relevant to the planning task.
  • Build predictors from market information available at the time each forecast would be made.
  • Feature selection is central because a model needs inputs with predictive information.
  • Use separate historical data for training and validation to assess overfitting and underfitting.
  • The answer gives a general workflow but does not demonstrate reliable scenario forecasts.

Tags

Full text
# Machine learning to build top 3 price scenarios over n days


# Machine learning to build top 3 price scenarios over n days












I have a time series of closing prices for a given stock. I would like to formulate possible future scenarios for the price.

My intention is not to use these "likely" scenarios to take any position. I just want to have 3 possible scenarios that are somehow likely to happen if history repeat itself. My goal is to use these scenarios in a sort of battleplan to prepare myself in terms of trade adjustments if these (or similar) scenarios are actually going to occur.

I want to try an historical based approach: given the recent price dynamics I want to find the most likely future patterns based on what happened in the past. For example, suppose that most of the time in the past after 3 days of down moves the price has then moved up. If we are now on the third day of down move, I could consider that an upmove tomorrow is the most likely scenario.

I have seen that machine learning should do something like this but I have very limited knowledge in this field. Is there any library/toolbox I can use to easily do what I want to do? I am familiar with R, MATLAB and C#/VB so I would prefer to work with these languages if possible.

Just to add clarity: as said, I want to formulate future scenarios so what I really need is not only the most likely future pattern but also other patterns in decreasing level of likelihood. In other words, I would like to have for example the 3 most likely price trajectories that could happen in the following n days. So the machine should extract these forecasts by learning from past price dynamics. Is it something doable? Thank you.

## Answer by nesvarbu (score 1)

https://quant.stackexchange.com/a/17786

Machine learning is a very wide field. Most often it is used for classification or regression tasks when you have labelled data to train the model. For example you show thousands of labeled pictures with an apple and computer "learns" what set of features gives high probability that picture contains an apple (for example, round, red etc). Now in your case next day scenarios are your labels. First of all you need to label all your historical data with possible scenarios (break out day, failed breakout day, range day, volatile day, reversal day, boring day etc, whatever you use). Once you have labels you can choose whatever model you prefer (probably decision trees or random forest are best for this) and give it some features (last open/close, moving average, last day type etc) and train it (just look for some tutorial how to do that with for example R shouldn't be very hard). Sounds easy? Not so fast. "give it some features" is actually most crucial part. You must have some insights on how to predict next day and which features matters. If you just give closing price model will not learn anything because no one can do that. Features you provide MUST have some predictive power for that. That's why "no free lunch" theorem exists - you must know your domain if you want to train a machine. So from your own question "given the recent price dynamics" is crucial - you must be able to predict next day yourself so you can find some features for the model that have real predictive power so model can learn. Once you have labelled data and select features you should train model not on full historical data but only on part of it and use other part to validate how your model works. If model overfits or underfits - back to feature selection. Do that until you are satisfied with the results. Another approach could be market simulation. Trying to guess market microstructure and simulate possible outcomes. Something like this: https://intelligentjava.wordpress.com/2014/09/16/stock-market-simulation-with-cellular-automaton/

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.