Sharpe Ratio: Calculation, Application, Limitations


William Sharpe introduced a simple formula to help compare different portfolios and help us find the most feasible of them all. Let’s understand its mechanism in this article.

What is Sharpe Ratio?

Sharpe ratio is a measure for calculating risk-adjusted return. It is the ratio of the excess expected return of investment (over risk-free rate) per unit of volatility or standard deviation.

Let us see the formula for Sharpe ratio which will make things much clearer. The sharpe ratio calculation is done in the following manner

Sharpe Ratio = (Rx – Rf) / StdDev(x)

x is the investment
Rx is the average rate of return of x
Rf is the risk-free rate of return
StdDev(x) is the standard deviation of Rx

Sharpe Ratio can be used in many different contexts such as performance measurement, risk management and to test market efficiency. When it comes to strategy performance measurement, as an industry standard, the Sharpe ratio is usually quoted as “annualised Sharpe” which is calculated based on the trading period for which the returns are measured. If there are N trading periods in a year, the annualised Sharpe is calculated as:

Sharpe Ratio = √N (E(Rx – Rf) / StdDev(x))

Sharpe ratio in Python

If you would like to find the Sharpe ratio on your own, you can try the following Python code:

# Load the required modules and packages
import numpy as np
import pandas as pd
import pandas_datareader as web
# Pull NIFTY data from Yahoo finance
NIFTY = web.DataReader(‘^NSEI’,data_source=’yahoo’,start=’6/1/2012′, end=’6/1/2016′)
# Compute the logarithmic returns using the closing price 
returns = np.log(NIFTY[‘Close’] / NIFTY[‘Close’].shift(1))
volatility = returns.std() * np.sqrt(252) 
sharpe_ratio = (returns.mean() – 0.05) / volatility

The above program gives the following output:

Visit QuantInsti website to download the Python code:

Disclosure: Interactive Brokers

Information posted on IBKR Traders’ Insight that is provided by third-parties and not by Interactive Brokers does NOT constitute a recommendation by Interactive Brokers that you should contract for the services of that third party. Third-party participants who contribute to IBKR Traders’ Insight are independent of Interactive Brokers and Interactive Brokers does not make any representations or warranties concerning the services offered, their past or future performance, or the accuracy of the information provided by the third party. Past performance is no guarantee of future results.

This material is from QuantInsti and is being posted with permission from QuantInsti. The views expressed in this material are solely those of the author and/or QuantInsti and IBKR is not endorsing or recommending any investment or trading discussed in the material. This material is not and should not be construed as an offer to sell or the solicitation of an offer to buy any security. To the extent that this material discusses general market activity, industry or sector trends or other broad based economic or political conditions, it should not be construed as research or investment advice. To the extent that it includes references to specific securities, commodities, currencies, or other instruments, those references do not constitute a recommendation to buy, sell or hold such security. This material does not and is not intended to take into account the particular financial conditions, investment objectives or requirements of individual customers. Before acting on this material, you should consider whether it is suitable for your particular circumstances and, as necessary, seek professional advice.

In accordance with EU regulation: The statements in this document shall not be considered as an objective or independent explanation of the matters. Please note that this document (a) has not been prepared in accordance with legal requirements designed to promote the independence of investment research, and (b) is not subject to any prohibition on dealing ahead of the dissemination or publication of investment research.

Any trading symbols displayed are for illustrative purposes only and are not intended to portray recommendations.