Value at Risk and Expected Shortfall Calculations
Autor: Sharon • April 13, 2018 • 846 Words (4 Pages) • 707 Views
...
FNESPHis
{
x
cm
a
e
for(i in 1:NCOL(x))
{
y
Var
es
es
e[i,1]
}
EXPSH
EXPSH
EXPSH
}
Inputs to function-
z = CSV file having the daily returns of different assets with their Market Value in the following format-
[pic 6]
p = p value (1- probability that the loss will be less than the Var)
n= no of days for which ES is to be calculated
Function Call-
FNESPHis(read.csv("CurrencyReturns.csv"),0.05,1)
Monte Carlo Method
- Single Asset Portfolio
R Function for VAR-
FnVarUSDMC
m
sd
mc
var
var
}
Inputs to function-
file = CSV file having the daily returns of the asset in the following format-
[pic 7]
p = p value (1- probability that the loss will be less than the Var)
am = Amount invested in the asset
n= no of days for which VAR is to be calculated
Function Call-
FnVaRUSDMC (read.csv("USDINR.csv"),.05,1000,1)
- Multi Asset Portfolio
R Function for VAR-
FNVarPMC
{
x
cm
a
v
for(i in 1:NCOL(x))
{
m
sd
mc
var
var
v[i,1]
}
VARP
VARP
VARP
}
Inputs to function-
z = CSV file having the daily returns of different assets with their Market Value in the following format-
[pic 8]
p = p value (1- probability that the loss will be less than the Var)
n= no of days for which VAR is to be calculated
Function Call-
FNVarPMC(read.csv("CurrencyReturns.csv"),0.1,1)
R Function for Expected Shortfall-
FNESPMC
{
x
cm
a
e
for(i in 1:NCOL(x))
{
m
sd
mc
var
es
es
e[i,1]
}
EXPSH
EXPSH
EXPSH
}
Inputs to function-
z = CSV file having the daily returns of different assets with their Market Value in the following format-
[pic 9]
p = p value (1- probability that the loss will be less than the Var)
n= no of days for which ES is to be calculated
Function Call-
FNESPMC(read.csv("CurrencyReturns.csv"),0.05,1)
VAR Calculations for Equity Portfolio
Analytical Method
R Function for VAR-
FnEquityVar
{
retInd
m
sd
VarInd
a
beta
for(i in 2:NCOL(z)-1)
{
ret
slope
slope
beta[i-1,1]
...