13  Group 12

Managers: Julie Luftglas, Priel Zimberg, and Thiago Molon

13.1 The setup

p12_list  <- c("VALE3.SA",  "PETR3.SA", "CSAN3.SA", "ABEV3.SA", "RENT3.SA", "LREN3.SA", "RADL3.SA", "HYPE3.SA", "MDIA3.SA", "BRFS3.SA", "TOTS3.SA", "SQIA3.SA", "WEGE3.SA", "RAIL3.SA", "SBSP3.SA", "EGIE3.SA", "CCRO3.SA", "ENEV3.SA", "STBP3.SA", "ITUB4.SA","BBAS3.SA",  "SANB11.SA",    "B3SA3.SA")
p12_w     <- c("0.1432610332" , "0.0099774435" , "0.0030409937" , "0.0345260994" ,"0.0119591851","0.0042846775" , "0.0355244722" , "0.0740462817" , "0.0453380925" , "0.0113319981" , "0.0240854384" , "0.0395698086" , "0.4160391972" , "0.0116140229", "0.0067039882" , "0.0124718950" , "0.0012684350" , "0.0475395738" , "0.0146208298" , "0.0417926527" , "0.0052964620", "0.0019407557" , "0.0037666638" )
p12_exc   <- c("BRL", "BRL","BRL","BRL","BRL","BRL","BRL","BRL","BRL","BRL","BRL","BRL","BRL","BRL","BRL","BRL","BRL","BRL","BRL","BRL","BRL","BRL","BRL")
p12_wlist <- cbind(p12_list, p12_w, p12_exc)
colnames(p12_wlist) <- c('ticker','weights','Currency')
#Download data Financial
p12 <- yf_get(tickers = p12_list, first_date = start, last_date = end,freq_data = "daily",thresh_bad_data = 0.5)
p12 <- p12[, c("ticker", "ref_date", "price_adjusted" ) ]
p12 <- merge(p12, p12_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
p12 <- merge(p12, exchanges, by = "ref_date")
p12$BRL.USD[p12$Currency == "USD"] <- 1
# Adjusting currency
p12$price_adj <- p12$price_adjusted * p12$BRL.USD
# Calculating return
ret <- p12 %>%
       group_by(ticker) %>%
       tq_transmute(select = price_adj,
                    mutate_fun = periodReturn,
                    period = "daily",
                    col_rename = "ret")
p12 <- merge(p12, ret, by = c("ref_date", "ticker"))
# Data tabulation
p12$ret_product <- p12$ret * as.numeric(p12$weights)

# Creating a df of portfolios return
p12_ret  <- p12 %>%                      
            group_by(ref_date) %>%
            summarise_at(vars(ret_product),
                         list(p12_return = sum)) %>% as.data.frame()
#Calculating cumulative return per day
for(i in (1:nrow(p12_ret) ) ) {
p12_ret$p12_cum[i] <- Return.cumulative(p12_ret$p12_return[1:i])
}
#Calculating cumulative return total
p12_sharpe <- data.frame(matrix(NA, nrow = 1,ncol = 4))
colnames(p12_sharpe) <- c('p12_return', 'p12_sd', 'p12_rf' , 'p12_sharpe')
p12_sharpe$p12_return <- Return.cumulative(p12_ret$p12_return)
p12_sharpe$p12_sd <- sd(p12_ret$p12_return[2:nrow(p12_ret)])
p12_sharpe$p12_rf <- (1+0.03)^(nrow(p12_ret)/252) -1
p12_sharpe$p12_sharpe <- (p12_sharpe$p12_return - p12_sharpe$p12_rf)  / p12_sharpe$p12_sd

13.2 The portfolio

This is the portfolio of this group:

      ticker      weights        Currency
 [1,] "VALE3.SA"  "0.1432610332" "BRL"   
 [2,] "PETR3.SA"  "0.0099774435" "BRL"   
 [3,] "CSAN3.SA"  "0.0030409937" "BRL"   
 [4,] "ABEV3.SA"  "0.0345260994" "BRL"   
 [5,] "RENT3.SA"  "0.0119591851" "BRL"   
 [6,] "LREN3.SA"  "0.0042846775" "BRL"   
 [7,] "RADL3.SA"  "0.0355244722" "BRL"   
 [8,] "HYPE3.SA"  "0.0740462817" "BRL"   
 [9,] "MDIA3.SA"  "0.0453380925" "BRL"   
[10,] "BRFS3.SA"  "0.0113319981" "BRL"   
[11,] "TOTS3.SA"  "0.0240854384" "BRL"   
[12,] "SQIA3.SA"  "0.0395698086" "BRL"   
[13,] "WEGE3.SA"  "0.4160391972" "BRL"   
[14,] "RAIL3.SA"  "0.0116140229" "BRL"   
[15,] "SBSP3.SA"  "0.0067039882" "BRL"   
[16,] "EGIE3.SA"  "0.0124718950" "BRL"   
[17,] "CCRO3.SA"  "0.0012684350" "BRL"   
[18,] "ENEV3.SA"  "0.0475395738" "BRL"   
[19,] "STBP3.SA"  "0.0146208298" "BRL"   
[20,] "ITUB4.SA"  "0.0417926527" "BRL"   
[21,] "BBAS3.SA"  "0.0052964620" "BRL"   
[22,] "SANB11.SA" "0.0019407557" "BRL"   
[23,] "B3SA3.SA"  "0.0037666638" "BRL"   

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

13.2.1 The performance

The current cumulative return of this Portfolio is 7.84 percent.

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

The current Sharpe of this portfolio is 3.1576.

ggplot(p12_ret, aes(x= ref_date, y= p12_cum) ) +  geom_line(color = "bisque3", size = 1.25) +
  labs(y = "Portfolio return", 
       x = "Time",
       title = "Group 12: Julie Luftglas, Priel Zimberg, and Thiago Molon") + theme_solarized()