Financial Multiples Analysis

Column

Revenue Multiple

Earnings Multiple

Column

Enterprise Multiple

Stock Momentum Analysis

Column

Monthly Return Comparison

Column

Apple

Microsoft

Google

---
title: "Dashboarding Lab"
author: "Ruofan Yu & Tian Tian"
date: "10/30/2017"
output: 
 flexdashboard::flex_dashboard:
    orientation: columns
    vertical_layout: fill
    source_code: embed
---

```{r setup, include=FALSE}
library(flexdashboard)
library(quantmod)
library(PerformanceAnalytics)
library(dygraphs)
library(lubridate)
library(ggplot2)
library(dplyr)
```

Financial Multiples Analysis
===================================== 

Intro {.sidebar}
-------------------------------------
We are comparing AAPL's financials with two peer companies Amazon and Google to find out if the company is fairly valued at current price. The conlusion is AAPL is actaully undervalued at current price level when comapared to MSFT and GOOG.

Column {data-width=400}
-----------------------------------------------------------------------
### Revenue Multiple
```{r}
Rawdata <- yahooQF(c(
  "EBITDA","Price/Sales", 
                          "P/E Ratio",
                          "Price/EPS Estimate Next Year",
                          "Market Capitalization"))

tickers <- c("AAPL","MSFT","GOOG")

Fin_table <- getQuote(paste(tickers, sep="", collapse=";"), what=Rawdata)

Fin_table <- data.frame(Symbol=tickers,Fin_table[,2:length(Fin_table)]) 
colnames(Fin_table) <- c("Symbol","EBITDA","Revenue_Multiple", "Earnings_Multiple", "Earnings_Multiple (Forward)", "Market_Cap")
Fin_table[,2]<-c(69.72,28.80,0.08517)
Fin_table[,6]<-c(750.90,532.18,12.96)
Fin_table$Enterprise_Multiple<-Fin_table[,6]/Fin_table[,2]

g1<-ggplot2::ggplot(data=Fin_table,aes(x=Symbol,y=Revenue_Multiple,fill=Symbol))
g1 + geom_bar(stat='identity',color="white") + 
scale_fill_manual(values=c("red","black","green")) + 
labs(x="Stock", y="Multiples") + 
theme_bw()
```

### Earnings Multiple 
```{r}
g2<-ggplot2::ggplot(data=Fin_table,aes(x=Symbol,y=Earnings_Multiple,fill=Symbol))
g2 + geom_bar(stat='identity',color="white") + 
scale_fill_manual(values=c("red","black","green")) + 
labs(x="Stock", y="Multiples") + 
theme_bw()
```

Column {data-width=400}
-----------------------------------------------------------------------
### Enterprise Multiple
```{r}
g3<-ggplot2::ggplot(data=Fin_table,aes(x=Symbol,y=Enterprise_Multiple,fill=Symbol))
g3 + geom_bar(stat='identity',color="white") +
scale_fill_manual(values=c("red","black","green")) + 
labs(x="Stock", y="Multiples") + 
theme_bw()
```


Stock Momentum Analysis
===================================== 

# Intro {.sidebar}
-------------------------------------
We are comparing Apple's stock performance against peer companies. All three companies have been in a positive upward trend in the past 2 years. But Apple's stock hasn't gone up as much as the rest two. The conclusion is there is still some upside room for AAPL.


Column {.tabset data-width=500}
-----------------------------------------------------------------------

### Monthly Return Comparison

```{r message = FALSE}
daily_returns <- function(ticker, start_year){
symbol <- getSymbols(ticker, src = 'google', auto.assign = FALSE, warnings = FALSE)
data <- periodReturn(symbol, period='monthly', subset=paste(start_year, "::", sep = ""), type ='log')
colnames(data) <- as.character(ticker)
assign(ticker, data, .GlobalEnv)
}
year <- ymd("2015-10-28")
duration <- ymd("2017-10-27")

daily_returns('AAPL', year)
daily_returns('MSFT', year)
daily_returns('GOOG', year)

all_returns <- merge.xts(AAPL, MSFT, GOOG)
all_returns_percent <- all_returns * 100

dygraph(all_returns_percent, main = "Monthly Return Percentage") %>%
  dyAxis("y", label = "return") %>%
  dyOptions(colors = RColorBrewer::brewer.pal(3, "Set2")) %>%
  dyHighlight(highlightSeriesBackgroundAlpha = 0.2,
              highlightSeriesOpts = list(strokeWidth = 2)) %>%
  dyRangeSelector(height = 75)
```

Column {.tabset data-width=500}
-----------------------------------------------------------------------

### Apple

```{r}
invisible(getSymbols ("AAPL", src = "google",from="2015-10-28"))
dygraph(AAPL[, -5], main = "Apple") %>%
  dyCandlestick() %>%
  dyAxis("y", label="Price") %>%
  dyOptions(colors= RColorBrewer::brewer.pal(3, "Set2")) %>%
  dyHighlight(highlightCircleSize = 4,
              highlightSeriesOpts = list(strokeWidth = 3),
              highlightSeriesBackgroundAlpha = 1) %>%
  dyRangeSelector(height = 75)
```


### Microsoft

```{r}
invisible(getSymbols ("MSFT", src = "google",from="2015-10-28"))
dygraph(MSFT[, -5], main = "Microsoft") %>%
  dyCandlestick() %>%
  dyAxis("y", label="Price") %>%
  dyOptions(colors= RColorBrewer::brewer.pal(3, "Set2")) %>%
  dyHighlight(highlightCircleSize = 4,
              highlightSeriesOpts = list(strokeWidth = 3),
              highlightSeriesBackgroundAlpha = 1) %>%
  dyRangeSelector(height = 75)
```


### Google

```{r}
invisible(getSymbols ("GOOG", src = "google",from="2015-10-28"))
dygraph(GOOG[, -5], main = "Google") %>%
  dyCandlestick() %>%
  dyAxis("y", label="Price") %>%
  dyOptions(colors= RColorBrewer::brewer.pal(3, "Set2")) %>%
  dyHighlight(highlightCircleSize = 4,
              highlightSeriesOpts = list(strokeWidth = 3),
              highlightSeriesBackgroundAlpha = 1) %>%
  dyRangeSelector(height = 75)
```