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:


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)
| improve this answer | |
  • 1
    $\begingroup$ 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. $\endgroup$ – jod51 May 15 '18 at 23:54
  • $\begingroup$ 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. $\endgroup$ – madilyn May 16 '18 at 1:16
  • 2
    $\begingroup$ @madilyn is this python code missing the annualization of the SR? Because I'm getting something ridiculous after converting to an annualized ratio. $\endgroup$ – cheez Nov 15 '18 at 14:31
  • $\begingroup$ You are right, the last line should read sr = r.mean()/r.std() * np.sqrt(252). $\endgroup$ – madilyn Nov 16 '18 at 3:02
  • 1
    $\begingroup$ You should include that in the answer above, some people (myself included) don't always read the comments and might miss it, thanks. $\endgroup$ – Goose Jan 30 '19 at 5:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.