You are on page 1of 2

Stock returns entropy, the CAPM and target practice

Entropy is a measure of uncertainty and therefore risk. So I attempted to replace the variance of stock returns in the CAPM with entropy. I also tried to save some pennies by shooting below the open price on entry. This makes the strategy more selective, because of the possibility that we shoot too low.

CAPM and entropy


Entropy is a measure of uncertainty and therefore risk. So I attempted to replace the variance of stock returns in the CAPM with entropy. On the y axis I put sequentially the volume weighted average return, skewness of returns and Jarque-Bera pval.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 ...

ev = average(returns, weights=v[:len(returns) ]) p,bins = histogram(returns,sqrt(len(returns)),range=(min(returns), max(returns)), no entropy = 0 for pi in p: if pi > 0: entropy += pi * log(pi) evs.append( ev ) entropies.append( entropy ) S = stats.skew( returns skews.append( S ) jb = jb_pval( returns ) jbs.append(jb) t = file.replace('.csv', ''), ev, entropy, S, jb records.append( t ) )

( a,b,residuals ) = fitline( entropies, evs ) ( aSkew, bSkew, residuals ) = fitline( entropies, skews ) ( aJb, bJb, residuals ) = fitline( entropies, jbs ) for t in records: symbol, evC, entropy, S, jb = t if evC > a * entropy + b: if S > aSkew * entropy + bSkew: if jb > aJb * entropy +bJb: ...

Target practice
In order to save some pennies I try shooting below the open price on entry. Its not much, but it adds

up in the long run. It might even be enough to compensate for the transaction costs. This makes the strategy more selective, because of the possibility that we shoot too low. The algorithm requires knowing the open price on the trading day. From this a low price is extrapolated using statistical analysis of historical data. The target that we try to hit is the range open to low not including the open price itself. For each security I build up a list of open low returns. Then I calculate for each percentile of the returns, what the probability is, to hit the target.
1 ... 2 r = (o[:-3] - l[:-3])/l[:-3] 3 4 ... 5 6 for i in range(1,100): 7 score = stats.scoreatpercentile(r, float(i) ) 8 p = o[-2]/(1 + score) 9 10 if not isnan(score): 11 means[i] += score 12 13 if p >= l[-2] and p < o[-2]: 14 ratios[i] += 1 15 ...

Below you can see plots for my historical data.

And here are the entries with the CAPM entropy strategy and the shooting method. If you liked this post and are interested in NumPy check out NumPy Beginners Guide by yours truly.

You might also like