10.12.2019 Views

Python for Finance

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Chapter 9

The output is shown here:

Another argument against using standard deviation in the Sharpe ratio is that it

considers the deviations in both directions, below and above the mean. Nevertheless,

we know that investors worry more about the downside risk (deviation below mean

return). The second issue for the Sharpe ratio is that for the numerator, we compare

mean returns with a risk-free rate. Nevertheless, for the denominator, the deviations

are from the mean return instead of the same risk-free rate. To overcome those two

shortcomings, a so-called Lower Partial Standard Deviation (LPSD) is developed.

Assume we have n returns and one risk-free rate (Rf). Assume further that there are

m returns that are less than this risk-free rate. We estimate LPSP by using only those

m returns and it is defined here:

The following program shows how to estimate LPSD for a given set of returns:

import scipy as sp

import numpy as np

mean=0.15;

Rf=0.01

std=0.20

n=200

sp.random.seed(3412)

x=sp.random.normal(loc=mean,scale=std,size=n)

def LPSD_f(returns, Rf):

y=returns[returns-Rf<0]

m=len(y)

total=0.0

for i in sp.arange(m):

total+=(y[i]-Rf)**2

return total/(m-1)

answer=LPSD_f(x,Rf)

print("LPSD=",answer)

('LPSD=', 0.022416749724544906)

[ 315 ]

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!