Waves, Market Crashes     (or Bubbles?)     a continuation of part II

In part II we looked at the magic formula:

(1)        P(n+1) = [ 2-(2π/T)2 ] P(n) - P(n-1) + (2π/T)2 P0


  • T is some kind of period (like T = 5 days)
  • P0 is some parameter (maybe a 10 day Moving Average)
  • P(n) is today's stock price and P(n-1) is the price yesterday
  • P(n+1) is the next stock price in the sequence ... namely tomorrow's price.
If P0 is a constant, say 50, then a sequence defined by Equation (1) looks like Figure 1 where, as T decreases, the frequency of oscillation increases.

Now suppose that, instead of being constant, P0 is assumed to decrease. Then we'd get a sequence which looks like Figure 2.

Now suppose that, as P0 decreases, so does T. Then we'd get a sequence which looks like Figure 3 where the stock price falls ... and oscillates more rapidly.

>I'd say you were going broke! Your $50 stock is headin' South ...

Figure 3

Figure 1

Figure 2

Pay attention. I want you to watch very closely ...

Figure 4a, b, c

>Yeah, so?
Can you see the oscillations and ... ?
>Sure, sure ... but who's that last guy, Figure 4c, without any label?
That's DOW, in 1929.
>You're trying to tell me something, right?
Well, there have been attempts in the past few years to predict market crashes. These seem to have centred on identifying certain periodicities in a market index, like the S&P 500. It all started in the early 1990s, I think, with a French fellow, Didier Sornette, who tried to predict the failure of materials by listening to the noises they make as the breaking point approached.
He heard noises when he stretched mylar, little squeals, and their frequency increased until the mylar strip ruptured. Then he applied this to the prediction of earthquakes, listening to the increasing frequency of the sounds made by microcracks forming in the soil.

>Don't tell me! Now people are trying to predict ... uh, market earthquakes?
Crashes, yes ... rapidly increasing oscillation frequency is (they say) a precursor to a market crash.

>And can they predict a market crash?
Well, I believe they try to fit a 7-parameter log-periodic curve to past market behaviour
... and identify the time when there'll be a crash, like Figure 5A.

>What's that Tc?
That's when the crash is predicted to occur and, after finding some "good" log-periodic fit, they try to extract the time of the crash, namely Tc.
The ritual is often associated with the Lomb Periodogram
... which I learned about from Max

>Can you predict a crash?
I don't know, but let's investigate what that log-periodic stuff does.
First off, there's that equation which they try to fit to a market index (as in Fig. 5A).

As t, the time, approaches Tc, the log becomes infinite and the cosine oscillations are more rapid and ...

Figure 5A

Figure 5B

>Yes, I can see Figure 5, but shouldn't the curve drop like a rock? We're talking Crash, right?
Uh ... it seems that the singularity when t = Tc identifies the crash. One looks at recent market gyrations and tries to fit a curve lby picking appropriate values for A, B, C etc. and, in particular, Tc. If successful, the value of Tc indicates a time, in the future, when a crash will occur.

>Or an earthquake or the mylar breaks or the concrete fractures or ...

>I assume you're going to talk that log-periodic equation, from Fig. 5A?
No, I'm going to talk about Equation (1) ...

>Wait! What about the log-periodic equation?
I'll let Sornette (now in California, presumably worried about San Andreas) ... I'll let him do the

In the meantime, I think we can get singularities with our Equation (1) if we ...

>What's this singularity stuff?
Where something about the graph becomes infinite or undefined, like the value or the frequency or ...

>And you get that with Equation (1)?
Yes, we'll play with Equation (1). Check it out:
If Figure 6a we're decreasing the value of T and we get the oscillations becoming more rapid as time progresses.
But look what happens when I decrease the value of T more rapidly. There's a time when ...

Well, yes ...

Figure 6a, b

>But decreasing that T? Sounds like fiddling to me. How do you justify ...?
Remember how Equation (1) was derived?

  • As the price moves above some "benchmark" (that's P0), investors sell to lock in their gains.
  • Selling drives the price down.
  • When the price moves below P0, investors buy, thinking the stock is cheeep.
  • For some reason (a war? bad news? coffee prices increase?), stock changes occur more quickly ... higher volatility.
  • Investors, seeing this, react more quickly.
  • Faster investor buying and selling increases the volatility, changes occur more rapidly.
  • Investors, seeing this, react more quickly.
  • Faster investor buying and selling increases ...

>Yeah, I get it. Doesn't that have a name ... like feedlot?
Feedback. Positive feedback. It makes for instability, like when you're recording your voice on a tape recorder and the recorder loudspeaker is playing back what you're saying and the microphone picks up this playback and it's amplified once more by the tape recorder which plays back this amplified ...

>And you get this terrible squeal. Yeah, I did that once and ...
Pay attention. The result of this increase in the frequency of trading could be that, at some point in time, everybody is selling at the same time. A crash ...

>Doesn't that have a name ... like cattle herd?
Herding behaviour.
Let me modify Equation (2) somewhat. We'll measure the deviation of prices from P0 via the variable p.
That is, we put P = P0 + p so that Equation (1) becomes:

(3a)        p(n+1) = [ 2-(2π/T)2 ]p(n) - p(n-1)

Now we divide each side by p(n) and get:

(3b)        p(n+1)/p(n) = [ 2-(2π/T)2 ] - p(n-1)/p(n)

Now we set x(n+1) = p(n+1)/p(n) and get:

(3c)        x(n+1) = [ 2-(2π/T)2 ] - 1/x(n)
Okay, now we'll set [ 2-(2π/T)2 ] = A and play with Equation (4).

(4)        x(n+1) = A - 1/x(n)

Suppose we try A = 3 and start with some x-value, say x(1) = 0.8.
x(2) = 3 - 1/x(1) = 1.75
x(3) = 3 - 1/x(2) = 2.43
x(4) = 3 - 1/x(3) = 2.58 etc. etc.
The sequence of increasing x's is shown in Figure 7.
They approach the value shown as a blue dot with a red centre.

Figure 7
Of course, had we started with a larger value for x(1) - greater than the blue dot with red centre - the sequence would converge again to the same eventual value ... but decreasing.

Wait! Notice that we can get our sequence of x's to go UP or DOWN. The limiting value (BlueDot/RedCentre) depends upon the value of A ... and A will change.
Can I call this BlueDot/RedCentre the magic dot?
Thanks. Remember that A = 2-(2π/T)2 so changing T will change A. In fact, A is necessarily less than 2 so ...

>Huh? Your example has A = 3 ... in Figure 7.
Well, that was just to illustrate how the sequence of x's change, for Equation (4):
From the initial x go vertically to y = A - 1/x, then
go horizontally to y = x, then
go vertically to y = A - 1/x etc. etc.

In fact, for A < 2 we may have something like Figure 8a where the curve y = A - 1/x doesn't even intersect the line y = x.

Suppose we start with x(1) = 2 and y = 1 - 1/x.
Then next value is x(2) = 1 - 1/x(1) = 1 - 1/2 = 0.5
and the next is x(3) = 1 - 1/x(2) = 1 - 1/0.5 = -1
and the next is x(4) = 1 - 1/x(3) = 1 - 1/(-1) = 2
and the sequence repeats.

On the other hand, if T is very small then A = 2-(2π/T)2 can become negative.

For A = -4, we'd get Figure 8b and the magic BlueDot/RedCentre.
The sequence of x's converge to a value about -4.24 so the x's aren't oscillating BUT, since x(n) is the ratio p(n)/p(n-1) it describes wild and violent oscillations in the p(n) ... of increasing magnitude.

Okay ... let's do it this way:

Figure 8a

Figure 8b

Masochists may be interested in the following:


We can solve Equation (3a):
(3a)         p(n+1) = [ 2-(2π/T)2 ]p(n) - p(n-1) = A p(n) - p(n-1)
like so:

  • Put p(n) = un
  • Get un+1 = A un - un-1
  • Divide by un and get     u = A - 1/u   or   u2 - A u + 1 = 0
  • Solving this quadratic equation gives:
    u = u1 = B + SQRT(B2 - 1)   or   u = u2 = B - SQRT(B2 - 1)   where B = A/2
  • The general solution to Equation (3a) is then:
    p(n) = L u1n + K u2n   where K and L are constants (as yet unknown).
  • Suppose we know the values at n = 0 and n = 1 (namely p(0) and p(1)) hence we get:
    L u10 + K u20 = K + L = p(0)
    L u11 + K u21 = Ku1 + Lu2 = p(1)
  • We can then solve these two equation for K and L to get:
    K = {p(1) - p(0) u2}/(u1 - u2)
    L = {p(0) u1 - p(1)}/(u1 - u2)
For example, if A = 3 so B = A/2 = 1.5 then
        u1 = 1.5+SQRT(1.52-1) = 2.618
        u2 = 1.5-+SQRT(1.52-1) = 0.382

If p(0) = 4 and p(1) = 3 (meaning the first two prices, P(0) and P(1), differ from P0 by "4" and "3" respectively), then:
        K = {p(1) - p(0) u2}/(u1 - u2) = {3 - 4(0.382)}/{2.618 - 0.382} = 0.658
        L = {p(0) u1 - p(1)}/(u1 - u2) = {4(2.618) - 3}/(2.618 - 0.382) = 3.34

Hence p(n) = 0.658 * 2.618n + 3.34* 0.382n

Note that 0.382n approaches "0" as n gets larger and the p(n)-values tend to grow like 0.658 * 2.618n so the ratio of successive terms ... that's our x(n) = p(n)/p(n-1) ... these x(n) values approach the limiting value u1 = 2.618 which is that BlueDot/RedCentre in Figure 7.

Now comes the interesting part:

Look at the expressions for u1 and u2, namely   B +/- SQRT(B2 - 1)
If B2 is less than "1", they're both complex numbers:
Real part = B and Imaginary part V = SQRT(1-B2).
Let's call them u1 = B + i V and u2 = B - i V.
We can rewrite them in polar form: u1 = R eiλ and u2 = R e-iλ
That makes u1n = Rn eiλn and u2n = Rn e-iλn.

Figure 9
But eiλn and e-iλn are each linear combinations of cos(λn) and sin(λn).
Hence u1n and u2n are each linear combinations of cos(λn) and sin(λn).
Hence the solutions of Equation (3a) can be written as linear combinations:

(5)        p(n) = C cos(λn) + D sin(λn)     where (of course) C and D are constants.

The onset of oscillatory behaviour occurs for B2 < 1 meaning -1 < B < 1 meaning -2 < A < 2 meaning
-2 < 2-(2π/T)2 < 2 and this requires T > π. Hence, there are oscillations as T decreases, until T falls below π after which at least one of the two solutions u1 or u1 has a magnitude greater than "1" so that the iterates of Equation (3a),
namely p(n) = L u1n + K u2n, become unbounded (as suggested in Figure 6b, above, where T decreased to some critical value).

If we believed this stuff, we'd look at recent market (or stock) oscillations and try to identify some critical T-value below which we'd get unbounded solutions and a cRaSh

... or maybe a bubble

In our idealized mathematical world (!), the critical value is T = π = 3.1416
... and , if we repeat the situation in Figure 1 (where we cleverly chose
T greater than π) we can generate Figure 10 by playing with the Equation:

(3a)         P(n+1) = [ 2-(2π/T)2 ] P(n) - P(n-1) + (2π/T)2 P0

with P(1) = $50, P(2) = $49, P0 = 50
... and T a wee bit more and a wee bit less than 3.1416

Figure 10

Figure 11
Here's an example:
  • We start with P(1) and P(2) equal to the S&P closing prices
    on Aug 3/4, 1987.
  • We choose a decreasing T according to T = To f n
    where we choose To and the fraction f so as to get a good fit.
  • We predict P(3), P(4), etc. using Eqn (3a).
  • We take P0 as the N-day moving average of our P(n).
  • We continue through mid-October, trying desperately to modify our To and f   and N to get a good fit to actual S&P values.
  • By October 15 we have a reasonable fit (To= 7 and f = 0.99 and N = 2) which has an RMS error of about 2%.
  • We look ahead a few days and find that our predicted P(n+1) for October 20, 1987 involves a 1-day drop of 22% !!
  • On Oct 15 we confidently predict a market cRaSh
    ... on Oct 20, 1987

>Harumpf! Hindsight is 20/20. Let's see you predict the next crash.

Okay, just for fun, eh? Here's what we'll do:

  1. We'll look at the 5-day moving average of S&P500 closing values from May, 2000 to Jan 23, 2003.
    (We'll use 5-day average to get something a wee bit smooother than daily values.)
  2. We'll pick a To and a reduction factor f so that, with T = Tn = To f n, Equation (3a) looks like:
    magic equation         P(n+1) = [ 2-{2π/Tn}2 ] P(n) - P(n-1) + {2π/Tn }2 P0
  3. For P0 we'll choose the 5-day moving average of actual S&P values.
  4. We'll start with P(1) and P(2) equal to the actual S&P 500 values.
  5. Then we'll use the magic equation, above, and run through a bunch of values for To and f and pick out the values that minimize the RMS error between the P(n) and the actual S&P values. (The Root-Mean-Square error is expressed as a percentage of the starting S&P value else an RMS error of 1.2345 is meaningless, eh?)
  6. After identifying the "best" choice (for To and f) we extrapolate, using the predicted values in the magic equation (for the P(n) and P0).
  7. We're now out on a limb. Our only numbers are the predicted values. The actual S&P 500 values are history. We're looking into the future. Moving averages can only be calculated using our predictions. The future evolution of the S&P ...

>Okay! Okay! So what do you get? Will there be a crash? TELL ME!
Well, I should point out that we can easily get violent oscillations which might lead us to believe that a crash is imminent and ...

>Yeah, yeah. So what do you get?
Also, what's your definition of a crash? A 25% one-day drop in the S&P?

>So what do you get?
We really should pay attention only if we have a good match, meaning a small RMS error else ...

>What do you get?
Here's are a few pictures of the S&P and our prediction(s) to Jan 23, 2003
... and our extrapolation to August, 2003: Click!
>Yeah? So?
No crash, at least before August, 2003.
>You're sure? And what about after August? And what about the effect of a war? And what about ...?
Hold on ... I'll check.
>Very funny. I assume you have a spreadsheet?
Yup. It looks like this.
>So, can I play with it?
Nope. You might take it seriously.
>I promise NOT to take it seriously. I promise ...
Imagine this:

Somebuddy uses the spreadsheet.
It predicts a crash.
They sell everything.
The market goes up 30%.
They sue gummy and ...

>I promise NOT to sue and ...
Well ... okay. RIGHT-click here and Save Target (such as it is) ...

See also Elliott Waves