Stock Analysis

Column

ResMed Inc. (RMD)

Edwards Lifesciences Corp. (EW)

Boston Scientific Corp. (BSX)

Pfizer Inc. (PFE)

Adjusted Closing Prices

Column

Adjusted Closing Prices for last 3 Years

Trading Volumes

Column

Trading Volumes for last 365 Days

---
title: "Lab_01_Dashboarding"
author: "Sindhura Arigela"
output: 
  flexdashboard::flex_dashboard:
    orientation: rows
    social: menu
    source_code: embed
    vertical_layout: fill  
  html_document:
    df_print: paged
---

# Intro text {.sidebar}

I have chosen 4 Healthcare stocks ResMed Inc.(RMD), Edwards Lifesciences Corp. (EW), Boston Scientific Corp. (BSX) and Pfizer Inc. (PFE) to analyze which is best for short term gains. I fetched the metrics such as Price/Sales, P/E Ratio, EPS Next Year, Dividend Yield, Market Capitalization, Adjusted Closing Price over the last 3 years and Trading Volume over the last 1 year. From the visualizations I created, it looks like both EW and PFE are good buys for short term gain.

Stock Analysis
=====================================

```{r setup, include=FALSE}
chooseCRANmirror(graphics=FALSE, ind=1)
library(flexdashboard)
library(pdfetch)
library(dygraphs)
library(xts)
identifiers = c("RMD", "EW", "BSX", "PFE")
```


Column {.tabset data-height=550}
-----------------------------------------------------------------------

### ResMed Inc. (RMD)

```{r}
RMD <- pdfetch_YAHOO("RMD", fields = c("open", "high", "low", "close"), from = as.Date("2019-03-12"),interval = "1d")
colnames(RMD)=c("Open","High","Low","Close")

x <- tail(RMD, n = 1500)

#plot
dygraph(x,
        ylab = "Stock Price ($)",
        group = "stockprices") %>%
dyCandlestick() %>%
dyLegend(width = 400) %>%
dyRangeSelector()
```

### Edwards Lifesciences Corp. (EW)

```{r}
EW <- pdfetch_YAHOO("EW", fields = c("open", "high", "low", "close"), from = as.Date("2019-03-12"),interval = "1d")
colnames(EW)=c("Open","High","Low","Close")

x <- tail(EW, n = 1500)

#plot
dygraph(x,
        ylab = "Stock Price ($)",
        group = "stockprices") %>%
dyCandlestick() %>%
dyLegend(width = 400) %>%
dyRangeSelector()
```

### Boston Scientific Corp. (BSX)

```{r}
BSX <- pdfetch_YAHOO("BSX", fields = c("open", "high", "low", "close"), from = as.Date("2019-03-12"),interval = "1d")
colnames(BSX)=c("Open","High","Low","Close")

x <- tail(BSX, n = 1500)

#plot
dygraph(x,
        ylab = "Stock Price ($)",
        group = "stockprices") %>%
dyCandlestick() %>%
dyLegend(width = 400) %>%
dyRangeSelector()
```

### Pfizer Inc. (PFE)

```{r}
PFE <- pdfetch_YAHOO("PFE", fields = c("open", "high", "low", "close"), from = as.Date("2019-03-12"),interval = "1d")
colnames(PFE)=c("Open","High","Low","Close")

x <- tail(PFE, n = 1500)

#plot
dygraph(x,
        ylab = "Stock Price ($)",
        group = "stockprices") %>%
dyCandlestick() %>%
dyLegend(width = 400) %>%
dyRangeSelector()
```

Adjusted Closing Prices
=====================================

Column {.tabset data-height=550}
-----------------------------------------------------------------------

### Adjusted Closing Prices for last 3 Years

```{r}
financialData <- pdfetch_YAHOO(identifiers, fields = c("open","adjclose"), from = as.Date("2017-03-12"), to = as.Date("2020-03-12"), interval = "1d")

adj_close <- cbind(financialData$RMD.adjclose,financialData$EW.adjclose, financialData$BSX.adjclose, financialData$PFE.adjclose)
colnames(adj_close) <-c("RMD","EW","BSX", "PFE")

x <- tail(adj_close, n = 1500)

#plot
dygraph(x,
        main = "Adjusted Closing Price (Last 3 Years)", 
        ylab = "Closing Price ($)",
        group = "trading") %>%
dyOptions(strokeWidth = 2,colors = RColorBrewer::brewer.pal(5, "Set2"))%>%
dyHighlight(highlightCircleSize = 3, 
              highlightSeriesBackgroundAlpha = 0.2,
              hideOnMouseOut = TRUE)%>%
dyLegend(width = 400) %>%
dyRangeSelector()
```

Trading Volumes
=====================================

Column {.tabset data-height=550}
-----------------------------------------------------------------------

### Trading Volumes for last 365 Days

```{r}
tradvol_data = pdfetch_YAHOO(identifiers, fields = c("open", "high", "low", "close","volume","adjclose"), from = as.Date("2019-03-12"), to = as.Date("2020-03-12"),interval = "1d")
trad_vol <- cbind(tradvol_data$RMD.volume,tradvol_data$EW.volume, tradvol_data$BSX.volume,tradvol_data$PFE.volume)
colnames(trad_vol) <-c("RMD","EW","BSX","PFE")
#plot
dygraph(trad_vol,
        main = "Trading Volume (Last 365 Days)", 
        ylab = "Volume",
        group = "trading") %>%
dyOptions(strokeWidth = 2,colors = RColorBrewer::brewer.pal(5, "Set2"))%>%
dyHighlight(highlightCircleSize = 3, 
              highlightSeriesBackgroundAlpha = 0.2,
              hideOnMouseOut = TRUE)%>%
dyLegend(width = 400)%>%
  dyRangeSelector()
```