# A positive Sharpe ratio when portfolio loses money, can that happen or bug in my code?

I'm having a trouble calculating (annualized from daily performance) Sharpe ratio, even though I've read some related posts here. Say I have a daily performance, for example: $$[1.15, 1.2, 0.7]$$ means that after 3 trading days my cumulative (for, say 1 dollar investment) wealth is: cum_wealth=$$1*1.15*1.2*0.7=0.966$$ which states that I actually lost money. When I calculate the Sharpe ratio I follow these steps:

1. Subtract $$1.0$$ to get percentage: $$X=[0.15, 0.2, -0.3]$$
2. Calculate sample expectance: $$\hat{E}=(0.15+0.2-0.3)/3=0.0166$$
3. Calculate sample standard deviation: $$\hat{\sigma}=0.224$$
4. Assuming the risk-free rate is 0%. Divide and annualize: Sharpe=$$E/\sigma * \sqrt{252}=1.176$$

I've constructed the example above specifically to show that I get positive Sharpe ratio when actually the portfolio loses money, which is counter-logic (if the math is correct)... What am I missing? Regards

• It can happen. The Sharpe Ratio uses the Arithmetic Average return. Whether you lose or make money is determined by the Geometric Average return. They are not necessarily of the same sign. The size of the discrepancy depends on the variance, which in your example is very high. So it is not too surprising. Feb 6 '19 at 15:59
• I see, so you're saying that the formula is OK, and I don't need to change anything? Feb 6 '19 at 16:32
• To calculate the Sharpe ratio, you're supposed to subtract off the risk free rate. That's not the source of your issue though. Your issue is $\operatorname{E}[R]$ vs $\operatorname{E}[\log(1+R)]$ which I discuss in my answer. Feb 6 '19 at 17:49
• Hi, @MatthewGunn, regarding the risk-free rate, you're correct, I didn't mention that I assume it is 0%. I'll read your answer and reply to it. Feb 6 '19 at 17:53

I'll expand on @AlexC's excellent comment. Let $$R$$ denote a random variable that takes the values .15, .2, and -.3 with equal probability.

We can see that both:

$$\operatorname{E}[R] > 0 \quad \quad \operatorname{E}[\log(1+R)] < 0$$

While the expected return $$\operatorname{E}[R]$$ is indeed positive, the expected log return $$\operatorname{E}[\log(1+R)]$$ is negative which leads the value process $$v_T = \prod_{t=1}^T (1 + R_t$$) to decline almost surely in the long run.

By the law of large numbers, the logarithm of the geometric mean return converges (as $$T \rightarrow \infty$$) to the expectation of the log return. The geometric mean return is:

$$\left( \prod_{t=1}^T (1 + R_t) \right)^{\frac{1}{T}}$$

Take the log to obtain:

$$\frac{1}{T} \sum_{t=1}^T \log (1 + R_t)$$

By the law of large numbers: $$\frac{1}{T} \sum_{t=1}^T \log (1 + R_t) \xrightarrow[]{\text{a.s.}} \operatorname{E}[\log (1 + R)]$$

• Thank you for the thorough answer. Just to be sure, I should change step (1) to the following: $X=log(X)$ (element-wise $log$)? Feb 6 '19 at 18:01
• @NatanZB You're calculating the Sharpe Ratio correctly if the risk free rate is zero. The Sharpe Ratio as originally defined is the mean arithmetic return. The issue is that a positive Sharpe Ratio doesn't imply the value process is increasing in the long run (i.e. you make money). Feb 6 '19 at 18:23
• Correctly as in the original post or after applying what I wrote in the previous comment? Thanks (I assume RF rate is 0) Feb 6 '19 at 18:25
• @NatanZB Original post. Feb 6 '19 at 18:27
• Thanks once more. I was suspecting I did something wrong because I was sure that a positive/negative Sharpe indicates positive/negative returns =\ Feb 6 '19 at 18:29