10  Group 9

Managers: Arthur Camis and Arthur Pillete

10.1 The setup

p9_list  <-c("CVCB3.SA","USIM5.SA","VALE3.SA","GGBR4.SA", "NTCO3.SA")
p9_w     <- c("0.3" , "0.3", "0.15", "0.10","0.15")
p9_exc   <- c("BRL","BRL","BRL","BRL", "BRL"  )
p9_wlist <- cbind(p9_list, p9_w, p9_exc)
colnames(p9_wlist) <- c('ticker','weights','Currency')
#Download data Financial
p9 <- yf_get(tickers = p9_list, first_date = start, last_date = end,freq_data = "daily", thresh_bad_data = 0.5)
p9 <- p9[, c("ticker", "ref_date", "price_adjusted" ) ]
p9 <- merge(p9, p9_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
p9 <- merge(p9, exchanges, by = "ref_date")
p9$BRL.USD[p9$Currency == "USD"] <- 1
# Adjusting currency
p9$price_adj <- p9$price_adjusted * p9$BRL.USD
# Calculating return
ret <- p9 %>%
       group_by(ticker) %>%
       tq_transmute(select = price_adj,
                    mutate_fun = periodReturn,
                    period = "daily",
                    col_rename = "ret")
p9 <- merge(p9, ret, by = c("ref_date", "ticker"))
# Data tabulation
p9$ret_product <- p9$ret * as.numeric(p9$weights)
# Creating a df of portfolios return
p9_ret  <- p9 %>%                      
            group_by(ref_date) %>%
            summarise_at(vars(ret_product),
                         list(p9_return = sum)) %>% as.data.frame()
#Calculating cumulative return per day
for(i in (1:nrow(p9_ret) ) ) {
p9_ret$p9_cum[i] <- Return.cumulative(p9_ret$p9_return[1:i])
}
#Calculating cumulative return total
p9_sharpe <- data.frame(matrix(NA, nrow = 1,ncol = 4))
colnames(p9_sharpe) <- c('p9_return', 'p9_sd', 'p9_rf' , 'p9_sharpe')
p9_sharpe$p9_return <- Return.cumulative(p9_ret$p9_return)
p9_sharpe$p9_sd <- sd(p9_ret$p9_return[2:nrow(p9_ret)])
p9_sharpe$p9_rf <- (1+0.03)^(nrow(p9_ret)/252) -1
p9_sharpe$p9_sharpe <- (p9_sharpe$p9_return - p9_sharpe$p9_rf)  / p9_sharpe$p9_sd

10.2 The portfolio

This is the portfolio of this group:

p9_wlist
     ticker     weights Currency
[1,] "CVCB3.SA" "0.3"   "BRL"   
[2,] "USIM5.SA" "0.3"   "BRL"   
[3,] "VALE3.SA" "0.15"  "BRL"   
[4,] "GGBR4.SA" "0.10"  "BRL"   
[5,] "NTCO3.SA" "0.15"  "BRL"   

Checking the sum of weights. The sum of weights is:

10.3 The performance

The current cumulative return of this Portfolio is -0.92 percent.

The current standard deviation of daily returns of this Portfolio is 3.64 percent.

The current Sharpe of this portfolio is -0.324.

ggplot(p9_ret, aes(x= ref_date, y= p9_cum) ) +  geom_line(color = "darkorchid2", size = 1.25) +
  labs(y = "Portfolio return", 
       x = "Time",
       title = "Group 9: Arthur Camis and Arthur Pillete") + theme_solarized()