7  Group 6

Managers: Gabriel Brosens and Marina Pitanga

7.1 The setup

p6_list  <-c("MSFT","TSLA","ENPH","AMD")
p6_w     <- c(0.6291 , 0.1028, 0.2256, 0.0425)
p6_exc   <- c("USD","USD","USD","USD"  )
p6_wlist <- cbind(p6_list, p6_w, p6_exc)
colnames(p6_wlist) <- c('ticker','weights','Currency')
#Download data Financial
p6 <- yf_get(tickers = p6_list, first_date = start, last_date = end,freq_data = "daily", thresh_bad_data = 0.5)
p6 <- p6[, c("ticker", "ref_date", "price_adjusted" ) ]
p6 <- merge(p6, p6_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
p6 <- merge(p6, exchanges, by = "ref_date")
p6$BRL.USD[p6$Currency == "USD"] <- 1
# Adjusting currency
p6$price_adj <- p6$price_adjusted * p6$BRL.USD
# Calculating return
ret <- p6 %>%
       group_by(ticker) %>%
       tq_transmute(select = price_adj,
                    mutate_fun = periodReturn,
                    period = "daily",
                    col_rename = "ret")
p6 <- merge(p6, ret, by = c("ref_date", "ticker"))
# Data tabulation
p6$ret_product <- p6$ret * as.numeric(p6$weights)
# Creating a df of portfolios return
p6_ret  <- p6 %>%                      
            group_by(ref_date) %>%
            summarise_at(vars(ret_product),
                         list(p6_return = sum)) %>% as.data.frame()
#Calculating cumulative return per day
for(i in (1:nrow(p6_ret) ) ) {
p6_ret$p6_cum[i] <- Return.cumulative(p6_ret$p6_return[1:i])
}
#Calculating cumulative return total
p6_sharpe <- data.frame(matrix(NA, nrow = 1,ncol = 4))
colnames(p6_sharpe) <- c('p6_return', 'p6_sd', 'p6_rf' , 'p6_sharpe')
p6_sharpe$p6_return <- Return.cumulative(p6_ret$p6_return)
p6_sharpe$p6_sd <- sd(p6_ret$p6_return[2:nrow(p6_ret)])
p6_sharpe$p6_rf <- (1+0.03)^(nrow(p6_ret)/252) -1
p6_sharpe$p6_sharpe <- (p6_sharpe$p6_return - p6_sharpe$p6_rf)  / p6_sharpe$p6_sd

7.2 The portfolio

This is the portfolio of this group:

p6_wlist
     ticker weights  Currency
[1,] "MSFT" "0.6291" "USD"   
[2,] "TSLA" "0.1028" "USD"   
[3,] "ENPH" "0.2256" "USD"   
[4,] "AMD"  "0.0425" "USD"   

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

7.3 The performance

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

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

The current Sharpe of this portfolio is -6.779.

ggplot(p6_ret, aes(x= ref_date, y= p6_cum) ) +  geom_line(color = "darkgreen", size = 1.25) +
  labs(y = "Portfolio return", 
       x = "Time",
       title = "Group 6: Gabriel Brosens and Marina Pitanga") + theme_solarized()