The S&P 500 index (SPX) is an American market index based on the stocks of 500 large companies. It’s one of the world’s most important market indexes and, therefore, predicting its movements is the goal of many finance analysts. In previous posts we have reproduced the SPX through clustering of stocks or even through powerful autoregressive models. In this case, providing** **an algorithm to predict the movements of the index is out of the scope of this post. However, we can at least **narrow the range of expected future movements**. I will focus on the expected weekly logarithmic returns, although the same analysis can be easily extrapolated to any other time window.

As the SPX 5-day logarithmic returns seem random, predicting them is a major challenge. However, we *can* observe some **subtle structure in this chaos**. The mean weekly returns size seems to cluster over time, with periods of higher and lower volatility. Since the series appears to be random, to calculate a range of expected values I simulated this randomness. However, not all randomness are made equal and the range of expected movements is not constant over time. So the final problem I would like to solve here is whether there **is a way to define a dynamic range of expected movements **over time.

The answer is yes. There *is* a way to define a dynamic range of randomly expected movements for the 5-day logarithmic returns of SPX.

## Random walk

The technique that I used to define expected movements is to **compare to simulated random movements**. To do so, I used a model called random walks. Random walks move a given number of steps in random directions–up or down for the index–for given step sizes. Therefore, we need 3 parameters to define our randomness: number of steps, the probability of going up or down, and step sizes.

#### Number of steps

In our simulations, we will give 1 step per day. Since we want to simulate weekly trajectories this choice is trivial; we will run 5-step simulations that represent a week of the index.

#### Probability of going up

The probability of going up changes over time. It may be approximated by the fraction of upwards movements in a given period of time, disregarding how strong those movements actually were. I chose the previous 2.5 years to compute this parameter. When the probability of going up is 0.5, it means that up and down movements are equally probable.

#### Step sizes

The step size indicates how much to move in a given direction. Because **upwards and downwards movements are not perfectly symmetrical**, I used a different time step when moving up or down. The upwards step size is computed as the mean of the positive daily movements in the previous 2.5 years, green. The downwards step size is computed as the mean of the negative daily movements in the previous 2.5 years, red.

## Simulations

Once we have computed all the necesary parameters we can run the random walk simulations. The algorithm to run the simulated 5-day movement is as follows:

- Compute the probability of going up:
**ppos**as the fraction of positive movements in the previous 2.5 years. - Compute positive step size
**pstep**as the mean upwards movement in the previous 2.5 years and the negative step size**nstep**as the mean downwards movement in the previous 2.5 years. Please notice that nstep is a negative number. - Compute the 5-day movement as:

\(movement=r_{B(5,ppos)} \cdot (pstep-nstep)+5\cdot nstep\)

where \(r_{B(5,ppos)}\) is a random number from the binomial distribution with n=5 and probability ppos.

## Expected movements

To finally define the range of expected movements I simulated 10,000 random 5-day trajectories that the SPX could have taken for each day. These trajectories **could go up or down** so I called expected movements all the movements larger than the bottom 1% of the simulations and smaller than the top 99% of simulated movements. (Please be aware that the movements keep their sign at all times).

Although the range of expected values over time is slightly delayed–because it computes the values of the parameters with past information–it still captures the randomness limits. So random walk simulations give us a dynamic range of expected values over time. Now it’s up to you to predict the extraordinary events, because after all, knowing what to expect is not as fun as **dealing with the unexpected**.

Good luck in your adventure!

## related posts

### add a comment

what do you think about shannon entropy? Then the probability of the next random walk step would be determined by an increase in the entropy of the series.