Use R function VaR in PerformanceAnalytics todo a vector 120 values containin a daily data on the simple returns for an asset Suppose you have a portfolio consisting only of this asset and that the c
Assuming the vector of daily simple returns is called "returns", the code to find the Value at Risk at the 99% level of confidence using Basic Historical Simulation is:
library(PerformanceAnalytics)
# calculate portfolio value at risk
port_value <- 170
var_99 <- VaR(returns, p = 0.99, method = "historical", portfolio_value = port_value)
# print result
var_99
This will return the Value at Risk at the 99% level of confidence for the portfolio, given the daily returns and portfolio value.
原文地址: https://www.cveoy.top/t/topic/ZBP 著作权归作者所有。请勿转载和采集!