- Why Log Returns - Quantivity
- Value at Risk - Investopedia
- Approaches to VaR - Stanford
- Uniform Distribution - R
- Monte Carlo Method in R - alookanalytics blog
- Calculating VaR with R - R-Bloggers
- Monte Carlo Package - R
- Fixed Income Risk: Calculating Value at Risk (VaR) for Bonds
- Portfolio & Risk Analytics - Bloomberg Terminal
- Risk Management for Fixed Income Portfolios - Credit Suisse
- Fixed Income VaR - Krzysztof Ostaszewski
- Manipulating Time Series Data in R with xts & zoo - RPubs
VaR = mean * delta_t - Z * sigma * sqrt(delta_t) * pi
- mean = Expected portfolio return
- sigma = Expected portfolio standard deviation
- delta_t = periods (typically days) to forecast VaR into the future
- Z = Z-Score of (1 - a), where a is the confidence level
- pi = Portfolio value (optional)
Assume an initial portfolio value of $1000.00. Assume we have a 95% confidence level (a = 0.05). Assume the following:
mean <- 0.04 # Expected portfolio return
sigma <- 0.05 # Expected portfolio standard deviation
delta_t <- 1 # 1 day forecast
alpha <- 0.05 # 95% confidence interval
pi <- 1000.00 # Portflio value = $1,000.00
# qnorm function used to calculate z-score
VaR <- parametricVaR(mean=mean, sd=sigma, alpha=alpha, delta_t=delta_t)
# Portfolio VaR
piVaR <- VaR*pi
Thus, VaR = -$42.5 or -4.25%. This means we have 95% confidence that over the next day the portfolio will not lose more than $42.5.
Ri = mean * delta_t + sigma * epsilon * sqrt(delta_t)
- Ri = Simulated return on the ith trial
- mean = Expected portfolio return
- sigma = Expected portfolio standard deviation
- delta_t = periods (typically days) to forecast VaR into the future
- epsilon = vector of random numbers generated from a normal distribution
# Set seed for the rng (random number generator)
# to get consistent sequence of random numbers
set.seed(42)
n <- 10000 # number of periods to simulate
epsilon <- rnorm(n) # vector of random standard normal distribution values
mean <- 0.1 # Expected portfolio return
sigma <- 0.25 # Expected portfolio standard deviation
delta_t <- 1 # 1 period VaR forecast
# Call mcVaR function
sim_returns <- mcVaR(mean=mean, sd=sigma, epsilon=epsilon, delta_t=delta_t)
# Visualize the distribution
hist(sim_returns, breaks = 100, col = "green")
As the number of simulated returns increases (n in rnorm(n)), the distribution forecast more closely matches a normal distribution. In order to get the expected VaR given some confidence interval, 1 - a, apply the following function in R:
a_vals <- c(0.01,0.05)
quantile(sim_returns, a_vals)
Steps:
- Sort vector of log returns for past n days
- Index bottom alpha percent of returns
- Take maximum value in former indexed vector
Assume a sorted log return vector, v, with the following attributes:
- n = 100
- a = 0.05
- lowest_5 = (-0.50, -0.18, -0.10, -0.08, -0.07)
Thus, the VaR = max(lowest_5) = -0.07. This means we have 95% confidence that over the next period the portfolio will not lose more than 7%.
- Rename and document portfolio dataframe
- Program function for Historical Simulation technique
- Program Conditional VaR (CVaR) function
- Add portfolio weights into VaR calculation
- Document VaR functions
- Write Bloomberg API data import functions
- Research techniques to apply VaR to Fixed-Income Portfolio
- Test VaR for CFE Portfolios
- Analyze and document results of VaR test in (8.)