ADBlinnikov
3/10/2018 - 8:21 AM

Sharpe Ratio

import numpy as np

def annualized_sharpe(returns, N=252):
  """ Calculate annualized Sharpe ratio of a returns stream
  based on number of trading periods in a year (N).
  
  Args:
    returns (pandas.Series): daily (or other) returns on investment
    N (int): number of periods in a year
    
  Returns:
    float: Sharpe ratio
  """
  return np.sqrt(N) * returns.mean() / returns.std()