How skewed are the prices of stocks? The 3 moment CAPM takes into account the mean, variance and skewness of asset returns. An investor prefers high positive skewness and low risk, because this corresponds to higher returns. I also did an experiment with fractional Brownian motion.

Fractional Brownian Motion The fractal brownian motion describes fractal movements. The Hurst exponent H is the main parameter of this model. This exponent has a value between 0 and 1 and is a measure of self similarity of timeseries. A value of 0.5 corresponds with a random walk. H bigger than 0.5 indicates a tendency to trend, while H smaller than 0.5 corresponds with a tendency to oscillate around a mean. H can be estimated from a so called rescaled range. Luckily the Python pyeeg package already has a function that does that. 1 2 3 4 5 6 7 8 9 10 11 12 13 14

... H = pyeeg.hurst(returns) R = zeros( ( len(c), len(c) ) ) for i in range(1, len(c) + 1): for j in range(1, len(c) + 1): doubleH = 2 * H R[i - 1][j - 1] = (i ** doubleH + j ** doubleH - abs(i -j) ** doubleH) / 2 sigma = cholesky(R) path = sigma.dot( standard_normal( len(c) ) ) + c[0] path = abs(path) ...

Here is a generated chart.

3 moment CAPM The 3 moment CAPM takes into account the mean, variance and skewness of asset returns. An investor prefers high positive skewness and low risk, because this corresponds to higher returns. I also added the probability of positive returns as an optimization parameter. But that still was not selective enough, so I also select stocks that recently dropped in price by a certain amount. 1 2 3 4 5 6

...

S = stats.skew( returns skews.append( S ) pinc = pPos( returns ) pincs.append( pinc )

)

7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27

beforeLastReturn = c[ len( c ) - 2 ] / c[ len( c ) - 3 ] - 1 if beforeLastReturn > -1 * float( argv[1] ) * ev: continue t = file.replace('.csv', ''), ev, madC, S, pinc records.append( t ) ( a,b,residuals ) = fitline( mads, evs ) ( aSkew, bSkew, residuals ) = fitline( mads, skews ) ( aPinc, bPinc, residuals ) = fitline( mads, pincs ) for t in records: symbol, evC, madC, S, pinc = t if evC > a * madC + b: if S > 0 and S > aSkew * madC + bSkew: if pinc > aPinc * madC + bPinc: ...

If you liked this post and are interested in NumPy check out NumPy Beginnerâ€™s Guide by yours truly.

NumPy3MomentCAPM

Published on Jan 7, 2012

... S = stats.skew( returns ) skews.append( S ) ... H = pyeeg.hurst(returns) The 3 moment CAPM takes into account the mean, variance and ske...