2 Group 1
Managers: Brian Kim and Pietra Kumagai
2.1 The setup
<-c("WEGE3.SA","JHSF3.SA","BRSR6.SA","WIZS3.SA","PETR4.SA","BEEF3.SA","LREN3.SA","ELET3.SA","ENBR3.SA","SAPR11.SA","FLRY3.SA","ROKU","SNAP","PINS","META","BABA","NFLX","ATXG","TCEHY","KO")
p1_list <- c(0.06,0.06,0.06,0.06,0.06,0.06,0.06,0.06,0.06,0.06,0.04,0.04,0.04,0.04,0.04,0.04,0.04,0.04,0.04,0.04)
p1_w <- c("BRL", "BRL","BRL","BRL","BRL","BRL","BRL","BRL","BRL","BRL","BRL","USD","USD","USD","USD","USD","USD","USD","USD","USD" )
p1_exc <- cbind(p1_list, p1_w, p1_exc)
p1_wlist colnames(p1_wlist) <- c('ticker','weights','Currency')
#Download data Financial
<- yf_get(tickers = p1_list, first_date = start, last_date = end,freq_data = "daily", thresh_bad_data = 0.5)
p1 <- p1[, c("ticker", "ref_date", "price_adjusted" ) ]
p1 <- merge(p1, p1_wlist , by = "ticker")
p1 # Download data Exchange rate
getFX("BRL/USD",from=start , to = end)
<- as.data.frame(BRLUSD)
exchanges $ref_date <- as.Date(rownames(exchanges))
exchanges# Merge
<- merge(p1, exchanges, by = "ref_date")
p1 $BRL.USD[p1$Currency == "USD"] <- 1
p1# Adjusting currency
$price_adj <- p1$price_adjusted * p1$BRL.USD
p1# Calculating return
<- p1 %>%
ret group_by(ticker) %>%
tq_transmute(select = price_adj,
mutate_fun = periodReturn,
period = "daily",
col_rename = "ret")
<- merge(p1, ret, by = c("ref_date", "ticker"))
p1 # Data tabulation
$ret_product <- p1$ret * as.numeric(p1$weights)
p1# Creating a df of portfolios return
<- p1 %>%
p1_ret group_by(ref_date) %>%
summarise_at(vars(ret_product),
list(p1_return = sum)) %>% as.data.frame()
#Calculating cumulative return per day
for(i in (1:nrow(p1_ret) ) ) {
$p1_cum[i] <- Return.cumulative(p1_ret$p1_return[1:i])
p1_ret
}#Calculating cumulative return total
<- data.frame(matrix(NA, nrow = 1,ncol = 4))
p1_sharpe colnames(p1_sharpe) <- c('p1_return', 'p1_sd', 'p1_rf' , 'p1_sharpe')
$p1_return <- Return.cumulative(p1_ret$p1_return)
p1_sharpe$p1_sd <- sd(p1_ret$p1_return[2:nrow(p1_ret)])
p1_sharpe$p1_rf <- (1+0.03)^(nrow(p1_ret)/252) -1
p1_sharpe$p1_sharpe <- (p1_sharpe$p1_return - p1_sharpe$p1_rf) / p1_sharpe$p1_sd p1_sharpe
2.2 The portfolio
This is the portfolio of this group:
p1_wlist
ticker weights Currency
[1,] "WEGE3.SA" "0.06" "BRL"
[2,] "JHSF3.SA" "0.06" "BRL"
[3,] "BRSR6.SA" "0.06" "BRL"
[4,] "WIZS3.SA" "0.06" "BRL"
[5,] "PETR4.SA" "0.06" "BRL"
[6,] "BEEF3.SA" "0.06" "BRL"
[7,] "LREN3.SA" "0.06" "BRL"
[8,] "ELET3.SA" "0.06" "BRL"
[9,] "ENBR3.SA" "0.06" "BRL"
[10,] "SAPR11.SA" "0.06" "BRL"
[11,] "FLRY3.SA" "0.04" "BRL"
[12,] "ROKU" "0.04" "USD"
[13,] "SNAP" "0.04" "USD"
[14,] "PINS" "0.04" "USD"
[15,] "META" "0.04" "USD"
[16,] "BABA" "0.04" "USD"
[17,] "NFLX" "0.04" "USD"
[18,] "ATXG" "0.04" "USD"
[19,] "TCEHY" "0.04" "USD"
[20,] "KO" "0.04" "USD"
Checking the sum of weights. The sum of weights is:
2.3 The performance
The current cumulative return of this Portfolio is -1.95 percent.
The current standard deviation of daily returns of this Portfolio is 2.21 percent.
The current Sharpe of this portfolio is -0.9983.
ggplot(p1_ret, aes(x= ref_date, y= p1_cum) ) + geom_line(color = "brown2", size = 1.25) +
labs(y = "Portfolio return",
x = "Time",
title = "Group 1: Brian Kim and Pietra Kumagai") + theme_solarized()