Asset Classes

Free investment financial education

Language

Multilingual content from IBKR

Close Navigation
Learn more about IBKR accounts
Sharpe Ratio: Calculation, Application, Limitations

Sharpe Ratio: Calculation, Application, Limitations

Posted December 16, 2019 at 3:55 pm

Apoorva Singh , Rekhit Pachanekar
QuantInsti

Excerpt

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)

Where,
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
sharpe_ratio

The above program gives the following output:

Visit QuantInsti website to download the Python code:
https://blog.quantinsti.com/sharpe-ratio-applications-algorithmic-trading/

Disclosure: Interactive Brokers

Information posted on IBKR Campus that is provided by third-parties does NOT constitute a recommendation that you should contract for the services of that third party. Third-party participants who contribute to IBKR Campus 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 its permission. The views expressed in this material are solely those of the author and/or QuantInsti and Interactive Brokers 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 buy or sell any security. It should not be construed as research or investment advice or a recommendation to buy, sell or hold any security or commodity. 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.

IBKR Campus Newsletters

This website uses cookies to collect usage information in order to offer a better browsing experience. By browsing this site or by clicking on the "ACCEPT COOKIES" button you accept our Cookie Policy.