gs_quant.timeseries.econometrics.sharpe_ratio

sharpe_ratio(series, currency=<RiskFreeRateCurrency.USD: 'USD'>, w=None, curve_type=<CurveType.PRICES: 'prices'>)[source]

Calculate Sharpe ratio

Parameters
  • series (Series) – series of prices or excess returns for an asset

  • currency (RiskFreeRateCurrency) – currency for risk-free rate, defaults to USD

  • curve_type (CurveType) – whether input series is of prices or excess returns, defaults to prices

  • w (Union[Window, int, None]) – Window or int: size of window and ramp up to use. e.g. Window(22, 10) where 22 is the window size and 10 the ramp up value.

Return type

Series

Returns

Sharpe ratio

Usage

Given a price series P, risk-free rate R, and window of size w returns the rolling Sharpe ratio S:

\(S_t = \frac{(E_t / E_{t-w+1})^{365.25 / (D_t - D_{t-w} - 1)}}{volatility(E, w)_t}\)

Excess returns E are defined as:

\(E_t = E_{t-1} + P_t - P_{t-1} * (1 + R * (D_t - D_{t-1}) / 360)\)

where D is the date for a data point. The Actual/360 day count convention is used.

Examples

Get rolling sharpe ratio of a price series (with window of 252).

>>> sr = sharpe_ratio(generate_series(100), USD, 252, CurveType.PRICES)

See also

volatility()