Professional Documents
Culture Documents
Num Py Jarque Bera
Num Py Jarque Bera
Num Py Jarque Bera
net
...
The expected return is estimated by the geometric mean function below. Actually it calls a scipy.stats function with positive values. This requires a bit of cheating in the form of taking the absolute value etcetera.
1 def geomean( arr ): 2 filtered = abs( arr ) 3 indices = flatnonzero( filtered ) 4 filtered = take( filtered, indices ) 5 6 return scipy.stats.gmean( filtered)
CAPM
So we need to have the slope and intercept of the security market line.
1 2 3 4 5 6 7 8 9 10 11 12 13 ... returns = [] returns.append( get_returns( c ) ) ev = geomean( returns[ 0 ] ) evs.append( ev ) stdC = std( returns[ 0 ] ) stds.append( stdC ) A = vstack([stds, ones(len(stds))]).T (p,residuals,rank,s) = linalg.lstsq(A, evs) a,b=p ...
After that its just a question of selecting the points above the SML, which should be undervalued
If you liked this post and are interested in NumPy check out NumPy Beginners Guide by yours truly.