12 Group 11
Managers: Benedita Coura, Isabella Adler, and Maria Luiza
12.1 The setup
<- c("AMER3.SA", "RADLY" , "BEEF3.SA", "JBSS3.SA" , "VBBR3.SA" ,"MELI34.SA" , "AAPL" ,"CRFB3.SA", "DIS", "ITSA4.SA" , "QETH11.SA")
p11_list <- c( "0.050", "0.080" , "0.070" , "0.100" , "0.220" , "0.100" , "0.170" , "0.050" , "0.090" , "0.050" , "0.020" )
p11_w <- c("BRL", "USD","BRL","BRL","BRL","BRL","USD","BRL","USD")
p11_exc <- cbind(p11_list, p11_w, p11_exc)
p11_wlist colnames(p11_wlist) <- c('ticker','weights','Currency')
#Download data Financial
<- yf_get(tickers = p11_list, first_date = start, last_date = end,freq_data = "daily", thresh_bad_data = 0.5)
p11 <- p11[, c("ticker", "ref_date", "price_adjusted" ) ]
p11 <- merge(p11, p11_wlist , by = "ticker")
p11 # 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(p11, exchanges, by = "ref_date")
p11 $BRL.USD[p11$Currency == "USD"] <- 1
p11# Adjusting currency
$price_adj <- p11$price_adjusted * p11$BRL.USD
p11# Calculating return
<- p11 %>%
ret group_by(ticker) %>%
tq_transmute(select = price_adj,
mutate_fun = periodReturn,
period = "daily",
col_rename = "ret")
<- merge(p11, ret, by = c("ref_date", "ticker"))
p11 # Data tabulation
$ret_product <- p11$ret * as.numeric(p11$weights)
p11
# Creating a df of portfolios return
<- p11 %>%
p11_ret group_by(ref_date) %>%
summarise_at(vars(ret_product),
list(p11_return = sum)) %>% as.data.frame()
#Calculating cumulative return per day
for(i in (1:nrow(p11_ret) ) ) {
$p11_cum[i] <- Return.cumulative(p11_ret$p11_return[1:i])
p11_ret
}#Calculating cumulative return total
<- data.frame(matrix(NA, nrow = 1,ncol = 4))
p11_sharpe colnames(p11_sharpe) <- c('p11_return', 'p11_sd', 'p11_rf' , 'p11_sharpe')
$p11_return <- Return.cumulative(p11_ret$p11_return)
p11_sharpe$p11_sd <- sd(p11_ret$p11_return[2:nrow(p11_ret)])
p11_sharpe$p11_rf <- (1+0.03)^(nrow(p11_ret)/252) -1
p11_sharpe$p11_sharpe <- (p11_sharpe$p11_return - p11_sharpe$p11_rf) / p11_sharpe$p11_sd p11_sharpe
12.2 The portfolio
This is the portfolio of this group:
ticker weights Currency
[1,] "AMER3.SA" "0.050" "BRL"
[2,] "RADLY" "0.080" "USD"
[3,] "BEEF3.SA" "0.070" "BRL"
[4,] "JBSS3.SA" "0.100" "BRL"
[5,] "VBBR3.SA" "0.220" "BRL"
[6,] "MELI34.SA" "0.100" "BRL"
[7,] "AAPL" "0.170" "USD"
[8,] "CRFB3.SA" "0.050" "BRL"
[9,] "DIS" "0.090" "USD"
[10,] "ITSA4.SA" "0.050" "BRL"
[11,] "QETH11.SA" "0.020" "USD"
Checking the sum of weights. The sum of weights is:
12.2.1 The performance
The current cumulative return of this Portfolio is -2.17 percent.
The current standard deviation of daily returns of this Portfolio is 2.29 percent.
The current Sharpe of this portfolio is -1.0584.
ggplot(p11_ret, aes(x= ref_date, y= p11_cum) ) + geom_line(color = "aquamarine", size = 1.25) +
labs(y = "Portfolio return",
x = "Time",
title = "Group 11: Benedita Coura, Isabella Adler, and Maria Luiza") + theme_solarized()