#install.packages("magrittr")
library(quantmod)
library(PerformanceAnalytics)
library(magrittr)
options("getSymbols.warning4.0"=FALSE)
options("getSymbols.yahoo.warning"=FALSE)
#tiger 200, KOSEF 蟲螻豈10, KODEX 螻覓(H), TIGER 覿一誤手覦磯
symbols = c("102110.KS", "148070.KS","132030.KS", "329200.KS")
getSymbols(symbols, from= "2019-01-01", to = "2020-08-25",warnings = FALSE, auto.assign = TRUE, src="yahoo")
prices = do.call(cbind, lapply(symbols, function(x) Ad(get(x)))) %>% setNames(symbols)
rets = Return.calculate(prices) %>% na.omit()
head(rets)
library(tidyr)
library(dplyr)
library(corrplot)
cor(rets) %>%
corrplot(method = 'color', type = 'upper',
addCoef.col = 'black', number.cex = 0.7,
tl.cex = 0.6, tl.srt=45, tl.col = 'black',
col =
colorRampPalette(c('blue', 'white', 'red'))(200),
mar = c(0,0,0.5,0))
covmat = cov(rets)