0
$\begingroup$

Say I have a daily PnL series:

Date PnL
1/1 4
1/2 3
1/3 -1
1/4 5

To calculate the annualized sharpe ratio, can I do: mean(PnL) / std(PnL) * sqrt(252)? This gets me 16.5.

Alternatively, I've read online people say you need to calculate the returns and do the calculation on the returns. If I do percent change on the cumulative sum series, I would get:

Date Pct_Change
1/1 NaN
1/2 .75
1/3 -.14
1/4 .83

This gets me 14.085.

Which is correct?

$\endgroup$
3
  • $\begingroup$ The second one, but more importantly, your time series is way too short. $\endgroup$
    – KaiSqDist
    Commented Nov 19 at 14:39
  • $\begingroup$ Why is the first one wrong? (and yes I know the series is too short ha) $\endgroup$
    – Tempor
    Commented Nov 19 at 14:50
  • $\begingroup$ The first method is sometimes used for futures trading, where percent return is hard to define and dollar P&L is more natural. However the second method is used in all other cases and agrees with the research literature, including Sharpe's original paper. $\endgroup$
    – nbbo2
    Commented Nov 20 at 19:25

1 Answer 1

0
$\begingroup$

You're comparing apples to oranges. If you're using 4-month returns, you need to annualize them for consistency with the annualized standard deviation. Similarly, if you're using annual SD, your returns must also be annualized

import yfinance as yf 
import numpy as np 

data = yf.download("^GSPC", start="2023-01-01", end="2023-12-31")
data['Daily Return'] = data['Adj Close'].pct_change()
cumulative_return = (1 + data['Daily Return']).prod() - 1
std_daily_return = data['Daily Return'].std()
annualized_std = std_daily_return * np.sqrt(252)
risk_free_rate = 0.04 
sharpe_ratio = (cumulative_return - risk_free_rate) / annualized_std
$\endgroup$
1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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