Steven S. Skiena
Dept. of Computer Science
SUNY Stony Brook
J. P. Morgan's famous stock market prediction was that ``Prices will fluctuate.''
Bachelier's Theory of Speculation in 1900 postulated that prices fluctuate randomly.
Indeed, simple random processes can generate time series which closely resemble real financial time series.
Such a model makes sense in a world where (1) most price changes result from temporary imbalances between buyers and sellers, (2) stronger price shocks are inherently unpredictable, and (3) under the efficient market hypothesis, where the current price of a stock reflects all information about it.
Such a model does not make sense if you believe in technical analysis, where it assume the price trajectory to this point offers insight into the future.
One downside of conventional random walk models is that they predict returns as being normally or log-normally distributed.
As we have seen, such distributions tend to underestimate the frequency of extreme events.
Still, random walks can be very useful in modeling financial risks and returns.
Estimating the probability distribution for the price of a stock
at a given future time is critical to pricing certain options.
This probability distribution
can be modeled as the distribution of positions after steps of a
random walk.
For this question, there is a closed form which can calculate the probability distribution directly, using a normal or binomial distribution (depending upon the random walk model).
However, simulations of random walks enable one to compute the probabilities of more complicated events...
Suppose you want to know the probability that a stock will hit a given price
at some point between now and time ,
or what is the expected high price reached over this interval.
Suppose you want to know the probability a company will go bankrupt
at some point between now and time .
We can define a company as bankrupt, say, when its capitalization falls to
less than its debt minus its assets.
A simple discrete random walk model holds that in each step,
we move a distance of either up or down, with the probability
of an
upward move and
of a downward move.
The path we take as a function of such moves defined a random walk, and is akin to flipping a biased coin.
What is the probability
that we get exactly
heads and
tails
with a coin that comes up heads with probability
?
For an unbiased coin (), the expected difference between heads and
tails is 0,
but the expected absolute difference between heads and tails
is
.
Continuous random walk models, called Weiner processes or Brownian motion, can also be considered.
A time series is a random walk if
Recall that the white noise series is defined by its variance,
Under such a model, is not predictable or mean-reverting, but has expected
value
.
Price series that tend to increase with time can be modeled as a
random walk with drift:
Such a time series only makes sense if reflects the log price,
since otherwise the impact of
will diminish with time.
Over short time scales, it is not too wrong to compute percentage changes by adding percentages
Successive movements in the random walks models to discussed to date are independent, which contradicts our natural perception about how markets move.
Hurst random walks are discrete random walks which reverse direction
with probability .
A value of generates a coin flipping random walk,
while a value of
generates a walk which moves in only one direction.
Intermediate values of should generate walks with more ``driven''
than simple coin-flipping, although the eye often mistakenly identifies trends
in such walks.
Hurst walks arise in the analysis of fractal phenomenon.
Simulating random walks require a source of random numbers.
Truly random numbers cannot be produced by a deterministic computer.
Linear congruential generators are a reliable source of random
numbers, where
Note that the accuracy of a simulation depends on generating truly pseudo-random numbers. Would a random walk alternating up and down look like a price series?
Statistical tests are available for measuring the validity of a random number generator, but library function should be good until you exceed the period where they start to repeat.
Efficient algorithms exist for constructing numbers from a given, non-uniform distribution using a uniform generator.
Stock volatility (measured by the absolute value of returns) tends to show much stronger short term correlation than returns itself.
Lag | Volatility Corr. | Return Corr. |
1 | 0.441 | 0.021 |
2 | 0.371 | -0.016 |
3 | 0.337 | -0.024 |
4 | 0.311 | -0.016 |
5 | 0.319 | 0.004 |
10 | 0.287 | 0.005 |
20 | 0.249 | -0.012 |
30 | 0.264 | -0.001 |
40 | 0.233 | 0.005 |
50 | 0.209 | -0.002 |
We used an exponentially weighted moving average model to predict volatility.
To incorporate the volatility prediction into our random walk model, we must map volatility to parameters for (1) the simulated number of steps per day, and (2) the step size.
We modeled each trading day by a walk of 1000 steps, and adjusted the step size so as to produce the step size to achieve the desired volatility.
We used a Hurst random walk model with , which gave us the best results.
We did not model any drift, because we where interested in predictions over very short time intervals.
Usually there is a substantial difference between one days closing price and the next day's opening price, reflecting the news that occurred in the interim.
The NYSE is open 9:30AM-3:30PM each day. Does more or less activity happen in the 18 hours until the next session?
This can be established by plotting the average daily ratio of night-to-day changes for Dow stocks:
The average night-move over this period was 0.567 that of the day-move, with a mean of 0.527.
The impact of these moves can be simulated by running the random walk the equivalent of this many steps each night and starting the next day from there.
We used our random walk to predict the range of the expected high achieved over the next 1 day and 10 days:
The leftmost point records the frequency the actually high never exceeded the close of the start period, with the rightmost point recording the frequency the actually high exceeded our prediction of what is possible in the time period.
The random walks do a good, but not perfect job, of predicting the actual distribution.
We also do a good, but not perfect, job of predicting closing prices: