# How to calculate Sharpe Ratio from $returns? I have a pairs strategy that I am trying to calculate the sharpe ratio for. Currently I am using python for my analysis and calculation. I have a dataframe that contains the cumulative returns in$'s for each day. I am confused on how to convert this information into something that I can calculate the sharpe ratio from.

Could anyone point me in the right direction on how to use cumulative returns (in \$'s) to find the sharpe ratio? Any help is appreciated! Thanks

Let's say your cumulative return series is $$\{R_i \mid i=0,1,...,N-1\}$$ of length $$N$$ days.

There's 3 conventional ways to do this at this stage. You may convert the cumulative dollar return curve into arithmetic returns:

$$\displaystyle{r_i}= \dfrac{R_i-R_{i-1}}{R_{i-1}}$$

Or dollar returns:

$$\displaystyle{r_i=R_i-R_{i-1}}$$

Then take the ratio:

$$\displaystyle{SR_{1d} = \dfrac{E\{r_i\}-r_f}{std\{r_i\}} }$$

where the risk-free rate $$r_f$$ is often taken to be $$0$$. Finally, you annualize it:

$$\displaystyle{SR_{1y}=SR \cdot \sqrt{252}}$$

Here's an example of how you can do it in Python:

import numpy as np
import pandas as pd

# Simulate cumulative returns of 100 days
N = 100
R = pd.DataFrame(np.random.normal(size=100)).cumsum()

# Approach 1
r = (R - R.shift(1))/R.shift(1)

# Approach 2
r = R.diff()

sr = r.mean()/r.std() * np.sqrt(252)

• I still seem to be getting an abnormally large value for my sharp ratio (~5). I should mention that this is being calculated from returns on a pairs trading strategy. Is there anything that would change because of this, or should I assume that something among my prior calculations is off. – jod51 May 15 '18 at 23:54
• It doesn't matter what kind of strategy you're testing this on. 5 isn't unusual, for strategies like that you probably just have wrong slippage assumptions. – madilyn May 16 '18 at 1:16
• @madilyn is this python code missing the annualization of the SR? Because I'm getting something ridiculous after converting to an annualized ratio. – cheez Nov 15 '18 at 14:31
• You are right, the last line should read sr = r.mean()/r.std() * np.sqrt(252). – madilyn Nov 16 '18 at 3:02
• You should include that in the answer above, some people (myself included) don't always read the comments and might miss it, thanks. – Goose Jan 30 '19 at 5:49