11 Group 10
Managers: Barbara Giarrante, Julia Dzura and Luiza Meneghin
11.1 The setup
p10_list <- c("ABEV3.SA", "ARZZ3.SA" , "BPAC11.SA" , "IGTI11.SA" , "RDOR3.SA" , "VALE3.SA" , "VBBR3.SA" , "WEGE3.SA" )
p10_w <- c("0.0625000000","0.1250000000","0.1666666667","0.1666666667","0.1666666667","0.0625000000","0.1250000000","0.1250000000")
p10_exc <- c("BRL","BRL","BRL","BRL","BRL","BRL","BRL","BRL" )
p10_wlist <- cbind(p10_list, p10_w, p10_exc)
colnames(p10_wlist) <- c('ticker','weights','Currency')
#Download data Financial
p10 <- yf_get(tickers = p10_list, first_date = start, last_date = end,freq_data = "daily",thresh_bad_data=0.5)
p10 <- p10[, c("ticker", "ref_date", "price_adjusted" ) ]
p10 <- merge(p10, p10_wlist , by = "ticker")
# Download data Exchange rate
getFX("BRL/USD",from=start , to = end)
exchanges <- as.data.frame(BRLUSD)
exchanges$ref_date <- as.Date(rownames(exchanges))
# Merge
p10 <- merge(p10, exchanges, by = "ref_date")
p10$BRL.USD[p10$Currency == "USD"] <- 1
# Adjusting currency
p10$price_adj <- p10$price_adjusted * p10$BRL.USD
# Calculating return
ret <- p10 %>%
group_by(ticker) %>%
tq_transmute(select = price_adj,
mutate_fun = periodReturn,
period = "daily",
col_rename = "ret")
p10 <- merge(p10, ret, by = c("ref_date", "ticker"))
# Data tabulation
p10$ret_product <- p10$ret * as.numeric(p10$weights)
# Creating a df of portfolios return
p10_ret <- p10 %>%
group_by(ref_date) %>%
summarise_at(vars(ret_product),
list(p10_return = sum)) %>% as.data.frame()
#Calculating cumulative return per day
for(i in (1:nrow(p10_ret) ) ) {
p10_ret$p10_cum[i] <- Return.cumulative(p10_ret$p10_return[1:i])
}
#Calculating cumulative return total
p10_sharpe <- data.frame(matrix(NA, nrow = 1,ncol = 4))
colnames(p10_sharpe) <- c('p10_return', 'p10_sd', 'p10_rf' , 'p10_sharpe')
p10_sharpe$p10_return <- Return.cumulative(p10_ret$p10_return)
p10_sharpe$p10_sd <- sd(p10_ret$p10_return[2:nrow(p10_ret)])
p10_sharpe$p10_rf <- (1+0.03)^(nrow(p10_ret)/252) -1
p10_sharpe$p10_sharpe <- (p10_sharpe$p10_return - p10_sharpe$p10_rf) / p10_sharpe$p10_sd11.2 The portfolio
This is the portfolio of this group:
p10_wlist ticker weights Currency
[1,] "ABEV3.SA" "0.0625000000" "BRL"
[2,] "ARZZ3.SA" "0.1250000000" "BRL"
[3,] "BPAC11.SA" "0.1666666667" "BRL"
[4,] "IGTI11.SA" "0.1666666667" "BRL"
[5,] "RDOR3.SA" "0.1666666667" "BRL"
[6,] "VALE3.SA" "0.0625000000" "BRL"
[7,] "VBBR3.SA" "0.1250000000" "BRL"
[8,] "WEGE3.SA" "0.1250000000" "BRL"
Checking the sum of weights. The sum of weights is:
11.3 The performance
The current cumulative return of this Portfolio is 4.63 percent.
The current standard deviation of daily returns of this Portfolio is 2.77 percent.
The current Sharpe of this portfolio is 1.5795.
ggplot(p10_ret, aes(x= ref_date, y= p10_cum) ) + geom_line(color = "cornflowerblue", size = 1.25) +
labs(y = "Portfolio return",
x = "Time",
title = "Group 10: Barbara Giarrante, Julia Dzura and Luiza Meneghin") + theme_solarized()