Financial Meaure

Financial Meaure Comparsion

Daily Price Trend

Daily close price for TSLA

Daily close price for JPM

Daily close price for GM

Daily close price for JNJ

---
title: "ANLY512 - Lab1"
output: 
  flexdashboard::flex_dashboard:
    orientation: columns
    vertical_layout: fill
    source_code: embed
---

```{r setup, include=FALSE}
library(flexdashboard)
library(quantmod)
library(plyr)
library(ggplot2)

# Load data
tickers <- c("TSLA", "JPM", "JNJ", "GM")
getSymbols(tickers, 
           from = Sys.Date()-30, 
           to = Sys.Date(),
           periodicity = "daily",
           auto.assign=TRUE)

cleanup <- theme(panel.grid.major = element_blank(), #no grid lines
                panel.grid.minor = element_blank(), #no grid lines
                panel.background = element_blank(), #no background
                axis.line.x = element_line(color = 'black'), #black x axis line
                axis.line.y = element_line(color = 'black'), #black y axis line
                legend.key = element_rect(fill = 'white'), #no legend background
                text = element_text(size = 15)) #bigger text size
```

## Financial Meaure  {data-width=600}

### Financial Meaure Comparsion

```{r}
metrics <- getQuote(paste(tickers, sep="", collapse=";"), 
         what = yahooQF(c("Earnings/Share", "P/E Ratio", "Book Value")))

metrics <- data.frame(Symbol=tickers, metrics[,2:length(metrics)]) 
colnames(metrics) <- c("Symbol", "EPS", "P-E Ratio", "Book Value")

EPS = metrics[c("Symbol", "EPS")]
colnames(EPS) <- c("Symbol", "Value")
EPS$Measure = "EPS"

PE = metrics[c("Symbol", "P-E Ratio")]
colnames(PE) <- c("Symbol", "Value")
PE$Measure = "P-E Ratio"

BV = metrics[c("Symbol", "Book Value")]
colnames(BV) <- c("Symbol", "Value")
BV$Measure = "Book Value"

metrics = rbind(EPS, PE, BV)

ggplot(data=metrics, aes(x=Measure, y=Value, fill=Symbol)) +
       geom_bar(stat="identity",
                position = "dodge")+ 
       cleanup
```


## Daily Price Trend {data-width=300}

### Daily close price for TSLA {data-height=200}

```{r}
ggplot(TSLA, aes(x=Index, y=TSLA.Close)) +
       geom_line(colour = "#6699CC", size = 2) + 
       xlab("Date") + 
       ylab("Daily Close price") +
       cleanup
```

### Daily close price for JPM {data-height=200}

```{r}
ggplot(JPM, aes(x=Index, y=JPM.Close)) +
       geom_line(colour = "#996699", size = 2) + 
       xlab("Date") + 
       ylab("Daily Close price") +
       cleanup
```

### Daily close price for GM {data-height=200}

```{r}
ggplot(GM, aes(x=Index, y=GM.Close)) +
       geom_line(colour = "#FFFF00", size = 2) + 
       xlab("Date") + 
       ylab("Daily Close price") +
       cleanup
```

### Daily close price for JNJ {data-height=200}

```{r}
ggplot(JNJ, aes(x=Index, y=JNJ.Close)) +
       geom_line(colour = "#33FFFF", size = 2) + 
       xlab("Date") + 
       ylab("Daily Close price") +
       cleanup
```