Page 1

Page 2

Row

Nvidia (NVDA)

Row {.tabset .tabset-fade} ———————————————————————–

Broadcomm (AVGO)

Intel Corporation (INTC)

Qualcomm Corporation (QCOM)

Row

Adjusted Closing Price - 3 Years

Trading Volume - 6 Months

---
title: "Lab 1 - dashboarding"
author: "Sunny Duggal"
date: "`r Sys.Date()`"
output: 
  flexdashboard::flex_dashboard:
    orientation: rows
    vertical_layout: fill
    social: menu
    source_code: embed
---

# Intro text {.sidebar}

##Stock Analysis

I chose big chip vendors for analysis.Broadcomm seems to be in the increasing trend with the adjusted closing price for the last 3 years. Also,the increasing number of broadband, wireless services and Broadcomm's strong presence in the sector would make me choose Broadcomm.However, before placing my final order I would take a peek at other technical and fundamental aspects of these vendors for example weekly moving averages, RSI, approaching catalyst and company's pipeline. 

  
# Page 1

```{r, message=F, warning=F}

library(dygraphs)
library(flexdashboard)
library(quantmod)
library(plyr)
what_metrics <- yahooQF(c("Price/Sales", 
                          "P/E Ratio",
                          "Price/EPS Estimate Next Year",
                          "PEG Ratio",
                          "Dividend Yield", 
                          "Market Capitalization"))

tickers <- c("NVDA","AVGO","INTC","QCOM")
# Not all the metrics are returned by Yahoo.
metrics <- getQuote(paste(tickers, sep="", collapse=";") , what=what_metrics)

#Add tickers as the first column and remove the first column which had date stamps
metrics <- data.frame(Symbol=tickers, metrics[,2:length(metrics)]) 

#Change colnames
colnames(metrics) <- c("Symbol",  "P-E Ratio", "Price EPS Estimate Next Year", "Div Yield", "Market Cap")

#Persist this to the csv file
#write.csv(metrics, "FinancialMetrics.csv", row.names=FALSE)

DT::datatable(metrics)
```

# Page 2

```{r setup, include=FALSE, message=F, warning=F}
install.packages('flexdashboard',repos = "http://cran.us.r-project.org")
library(flexdashboard)
install.packages('pdfetch',repos = "http://cran.us.r-project.org")
library(pdfetch)
install.packages('dygraphs',repos = "http://cran.us.r-project.org")
library(dygraphs)
library(xts)
identifiers <- c("NVDA", "AVGO", "INTC","QCOM")
```

Row {.tabset .tabset-fade}
-----------------------------------------------------------------------

### Nvidia (NVDA)

```{r, message=F, warning=F}
threeMonthNVDA <- pdfetch_YAHOO("NVDA", fields = c("open", "high", "low", "close"), from = as.Date("2018-10-25"),to = as.Date("2019-01-25"),interval = "1d")
colnames(threeMonthNVDA)=c("Open","High","Low","Close")
m <- tail(threeMonthNVDA, n = 68)
dygraph(m) %>%
dyCandlestick()%>% 
dyRangeSelector()
```
Row {.tabset .tabset-fade}
-----------------------------------------------------------------------

### Broadcomm (AVGO)

```{r, message=F, warning=F}
threeMonthAVGO <- pdfetch_YAHOO("AVGO", fields = c("open", "high", "low", "close"), from = as.Date("2018-10-01"),interval = "1d")
colnames(threeMonthAVGO)=c("Open","High","Low","Close")
m <- tail(threeMonthAVGO, n = 68)
dygraph(m) %>%
dyCandlestick()%>% 
dyRangeSelector()
```


### Intel Corporation (INTC) 

```{r, message=F, warning=F}
threeMonthINTC <- pdfetch_YAHOO("INTC", fields = c("open", "high", "low", "close"), from = as.Date("2018-10-01"),interval = "1d")
colnames(threeMonthINTC)=c("Open","High","Low","Close")
m <- tail(threeMonthINTC, n = 68)
dygraph(m) %>% 
dyRangeSelector() %>%
dyCandlestick()
```


### Qualcomm Corporation (QCOM)
```{r, message=F, warning=F}
threeMonthQCOM <- pdfetch_YAHOO("QCOM", fields = c("open", "high", "low", "close"), from = as.Date("2018-10-01"),interval = "1d")
colnames(threeMonthQCOM)=c("Open","High","Low","Close")
m <- tail(threeMonthQCOM, n = 68)
dygraph(m) %>% 
dyRangeSelector() %>%
dyCandlestick()
```

Row {.tabset .tabset-fade}
-----------------------------------------------------------------------

### Adjusted Closing Price - 3 Years

```{r, message=F, warning=F}
financialData <- pdfetch_YAHOO(identifiers, fields = c("open","adjclose"), from = as.Date("2016-01-25"), to = as.Date("2019-01-25"),interval = "1d")

threeYAdjClose <- cbind(financialData$NVDA.adjclose,financialData$AVGO.adjclose, financialData$INTC.adjclose,financialData$QCOM.adjclose)
colnames(threeYAdjClose) <-c("NVDA","AVGO","INTC","QCOM")
#plot
dygraph(threeYAdjClose) %>%
dyOptions(strokeWidth = 2,colors = RColorBrewer::brewer.pal(5, "Set2"))%>%
dyHighlight(highlightCircleSize = 3, 
              highlightSeriesBackgroundAlpha = 0.2,
              hideOnMouseOut = TRUE)%>%
dyLegend(width = 400) %>%
  dyRangeSelector()
```


### Trading Volume - 6 Months

```{r, message=F, warning=F}
financialData6m <- pdfetch_YAHOO(identifiers, fields = c("open", "high", "low", "close","volume","adjclose"), from = as.Date("2018-07-25"), to = as.Date("2019-01-25"),interval = "1d")
sixMonthTradingVol <- cbind(financialData6m$NVDA.volume,financialData6m$AVGO.volume, financialData6m$INTC.volume,financialData6m$QCOM.volume)
colnames(sixMonthTradingVol) <-c("NVDA","AVGO","INTC","QCOM")
#plot
dygraph(sixMonthTradingVol) %>%
dyOptions(strokeWidth = 2,colors = RColorBrewer::brewer.pal(5, "Set2"))%>%
dyHighlight(highlightCircleSize = 3, 
              highlightSeriesBackgroundAlpha = 0.2,
              hideOnMouseOut = TRUE)%>%
dyLegend(width = 400)%>%
  dyRangeSelector()
```