Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Obtain 5 years of data for any two stocks. Perform Monte Carlo simulations for a portfolio of two stocks with weights 0.3 and 0.7. Use

Obtain 5 years of data for any two stocks. Perform Monte Carlo simulations for a portfolio of two stocks with weights 0.3 and 0.7. Use Normal distribution with constant variance for the simulations. Find 99% VaR for $1,000,000 portfolio of two stocks.
Here is the R code that we need to use but J am unable to run it. So What is the result when we run the following R code in R studio ?
library(quantmod) # <=== load the package "quantmod"
library(timeSeries)
getSymbols("TSLA",from="2010-01-01",to="2018-08-13") # <== specify the data span
getSymbols("TGT",from="2010-01-01",to="2018-08-13") # <== specify the data span
TSLA=last(TSLA, "4 years") # select the last 4 years of data
TGT=last(TGT, "4 years") # select the last 4 years of data
ret_TSLA=diff(log(TSLA$TSLA.Adjusted))*100 # returns are in percentage
ret_TGT=diff(log(TGT$TGT.Adjusted))*100 # returns are in percentage
ret_TSLA=na.omit(ret_TSLA) # remove missing values NA
ret_TGT=na.omit(ret_TGT) # remove missing values NA
nsim=10000
w=c(0.6,0.4) #portfolio weights
# mean returns could be included or ignored
#mu=cbind( mean(ret_TSLA),mean(ret_TGT))
mu=c(0,0)
# daily covariance matrix
SIG=cov(cbind(ret_TSLA,ret_TGT)) # covariance between TSLA and TGT
SIG
# Correlation between TSLA and TGT
cor(cbind(ret_TSLA,ret_TGT))
plot(as.data.frame(cbind(ret_TSLA,ret_TGT))) #scatterplot
plot(cbind(ret_TSLA,ret_TGT)) #plot over time
library(MASS)
set.seed(12345) #set seed so that monte carlo simulations are the same each time you run the code
sim_returns=mvrnorm(nsim,mu,SIG) # generate nsim=10000 scenarios for two stocks
sim_portfolio= sim_returns%*%w #compute portfolio returns for nsim scenarios
# Find VaR for $1,000,000 portfolio
value=1000000
VaR=-quantile(sim_portfolio,p=0.01)/100*value # divide by 100 since returns are in percentage
VaR

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

International Finance Putting Theory Into Practice

Authors: Piet Sercu

1st edition

069113667X, 978-0691136677

More Books

Students also viewed these Finance questions

Question

2. Identify three sets of rules that govern language use.

Answered: 1 week ago