Friday, 12 November 2010

Stock Market: Random Walk

Decided to get serious about stock market investment. First up a null hypothesis model of a random stock market so potential "trends" can reject that hypothesis.

Price movements

Market efficiency (ME) is the theory that any stock considered under-priced will on average see higher buying desire any stock considered over-priced will on average see higher selling desire. This will always bring stock prices back to a value where on average investors seeking gains can't make their mind up whether it will rise or fall. New information that upsets this equilibrium will be assimilated as quickly as investors realise that a stock is more or less valuable than they thought. Diffusion of information for the casual investor is slow (RNS and news) by which time professional traders (with automated computer help) will already have shifted prices. So the fastest way to determine an over-bought/under-bought situation is by watching the price itself!

It occurs to me writing this, that logically ME combined with Price Diffusion (PD) are a tautology anyway. How long does it take price to reach its "actual" value? Surely any market that fails to reach its actual value is simply suffering from a longer PD! thus allowing ME to always explain any pattern. Any how do we determine "actual" value anyway? Its like "fitness" in evolution: the only way to know it, is measure it post-hoc once we have seen how the organisms fared. Since neither ME nor fitness can make a prediction they can't ever be tested or rejected on evidence... now where is the science in that Dawkins! Evolution may have evidence but unlike the discovery of DNA there is no material mechanism behind evolution to discover! By analogy ME can't ever be supported by a material theory.

But all that said, it seems the professionals are in reality extremely inefficient as recent movements in oil-stocks show. An amateur friend has been studying these for a long time and has made several predictions of under-bought months in advance of actual price movements e.g. Xcite Energy (price-movements resulting not from surprise oil discovery but re-evalua
tion of the existing p1 proven reserves, company personalities and strategy). Up 334% in the last 3 months!

Obviously every market transaction is an "exchange" (which is why it is called the stock exchange) and the exchange of stocks as with any goods requires a buyer and a seller. However if there are more people with a desire to buy than there are people with a desire to hold their stocks then they will be prepared to buy at a higher price and the price rises. Likewise if people no longer want to hold and can find a buyer then they will be prepared to sell. Now the reason to sell may be motivated by two things. Scenario 1 where someone has bought at a low price and already made a good profit so that as the price increases the law of diminishing returns means that they are gaining a falling percentage with each price movement coupled with rising risk means that they may sell even while their is considerable upside. The other reason to sell is obviously where the seller perceives a considerable downside within their trading window.

Definition (my own): Trading Window = the period of time over which the a trader measures their return. A long trading window means that the trader is willing to tolerate lar
ge falls in stock price because they are willing to wait for the stock price to recover. A very short trading window will lead a trader to sell the moment they perceive/experience downside. Long trading windows from my amateur experience see much higher returns, while very short trading windows nearly always result in net loss. Why? because often selling is based upon actual downside (cutting losses) while when the price rises the decision is to hold. This way stock is most often sold at a loss, which on average realises loss in the portfolio and so the capital declines.

So to model the exchange we can see a probability distribution of price perception around the current price with orders being put in above and below the current price (CP) as traders anticipate price changes. Orders are put in at varying distances from the CP based upon the Trading Window since the longer one waits the more probable the stock will achieve a certain price (on average and assuming randomness). As the attitudes of stock holders and buyers change the distribution will skew above and below the current price with the "trend" heading in the direction of the mean (mean weighted by size and distance of orders from the cur
rent price).

A Simple Model
To begin with a simple model with random up and down movements was sort. This is a Random Walk model. But a problem was found.

Assume the market is restrained to simply move up or down, that is create a win or a loss as with coin flips. Let a function w(s) be the result on price s of a win, and l(s) be the result on price s of a loss. There are 4 axioms that must be true for a stock chart:
  1. w(s) - s = s - l(s)
    The distance up must be the same as the distance down so that on average the market does not drift and create profits or losses intrinsically (it is supposed to be random and unpredictable).
  2. l(w(s)) = w(l(s))
    A win followed by a loss must be the same as a loss followed by a win so that the sequence of random results doesn't drift the market.
  3. w(l(s)) = sA loss followed by a win must return the stock price back to s.
  4. If we notate a sequence of 4 losses: l[4](s) then
    lim (n->0) l[n](s) -> 0
    A stock value can never fall below 0 even after a huge number of successive losses approaching infinity.
So the question is what functions fit the description of w(x) and l(x)?

5.1 From rule 1: w(s) = 2s - l(s) and
l(s) = 2s - w(s)
5.2 Let us assume that stock value 's' was arrived at by a loss from a previous stock value 'r' so that:
s = l(r)

5.3 From 5.1,5.2 l(l(r)) = 2l(r) - w(l(r))
5.4 From 5.3, 3 l[2](r) = 2l(r) - r
it can be shown that, continuing this:
l[n](r) = n*l(r) - (n-1)rComment This general relationship holds true for all stock values.

Does applying the l(s) function produce a linear change in the stock, s? If it does then the difference between any two stock values related by l(s) will be the same. Therefore,
5.5 Assume: l[n+2](r) - l[n+1](r) = l[n+1](r) - l[n](r)
5.6 From 5.4,5.5 (n+2)*l(r) - (n+1)r = 2*(n+1)*l(r) - 2*nr - n*l(r) + (n-1)r
Expand and simplify each side gives:
l(r) - r = l(r) - r
5.7 Result 5.6 is True so we accept that assumption 5.5 that l(s) is linear is consistent with axioms 1 and 3 (which were used in the derivation). Therefore:
5.8 l(r) = r - i (obviously a loss reduces the value of r)
5.9 Addition is commutative so 5.8 is consistent with axiom 2.
6.0 Successive applications of l[n](r) = r - ni
Axiom 4 demands that:
lim (n->0) (r - n*i) -> 0
6.1 Yet only (r/i+1) losses will send the share price negative.

This was my problem. Axioms 1 and 3 imply that the random walks are linear, but axiom 4 contradicts this.

The solution was to realise that axioms 4,2 are true for real stock values, while axioms 1,2,3 are true in Log(s) space.

So the value after taking a random walk in this model is:

s(n+1) = s(n) * i^wins / i^losses, which simplifies to:

s(n+1) = s(n) * i^(wins - losses)

Where s(x) is the stock price at iteration x, i is the percentage change of the stock with each step.

This approaches 0 as losses approaches infinity (for a given number of wins) according to axiom 4. In Log(s) space this becomes:

Log[s(n+1)] = Log[s(n)] + (wins - losses) * Log[i]

With I = Log(i) it becomes

Log[s(n+1)] = Log[s(n)] + wins*I - losses*I

This is the linear model that axioms 1,3 require.

An interesting implication then of a random stock market is that for a given stock value S the probability of S*110% must be the same as the probability of S/110%. If we start with £100 the probability of that stock being £110 after a trading session must be the same as it being £90.9. In other words if the market is random then the probability of gaining £10 must be the same as losing £9.9! We might think then that on average we can't help but make a profit! Yet as the random graph here shows this is not the case. Calculated for 2770 steps in Excel the price actual drops in this example. Recalculating the page again and again with F9 gives random graphs with no apparent trend up or down. Drawing a similar graph with linear steps, rather than log steps, went negative on the 15th trial: an impossible result! as if it still remained to be proven that this cannot be the model of stock movements! The reason that the log model doesn't make intrinsic profit is that as the price rises the absolute size of the down steps increases also, so the probability of returning to our original price after what seems a disproportionate step up is still 50%.

Investment Maths showed how the average return (mean return) on a portfolio is independent of its diversification. However diversification is utilised not to increases returns, but to reduce risk. Perceived inverse interactions between sectors of the market inspire the creation of portfolios across these sectors so that failure in one sector is gain in another sector thus cancelling risk. The most famous example is gold price versus the dollar and oil. These relationships are unfortunately dynamic and unpredictable, as the last few years have shown in the previous example, so there is risk in even holding the assumptions that a diversified portfolio is based upon!

Next up is using the above model to examine variance between portfolios of varying size...

1 comment:

Mutual Funds said...

Im not going to say what everyone else has already said

"The Jewish Fallacy" OR "The Inauthenticity of the West"

I initially thought to start up a discussion to formalise what I was going to name the "Jewish Fallacy" and I'm sure there is ...