Stock Analysis by telcom Company

Row

Column

Comcast Corporation (CMCSA)

Verizon Communications Inc (VZ)

AT&T Inc. (T)

More Trading Info

Column

Price

Volume

---
title: "ANLY 512 - Lab1"
author: "yingwen xue"
date: '`r Sys.Date()`'
output: 
  flexdashboard::flex_dashboard:
    orientation: rows
    social: menu
    source_code: embed
    vertical_layout: fill
---

Stock Analysis by telcom Company
===================================== 

```{r setup, include=FALSE}
chooseCRANmirror(graphics=FALSE, ind=1)
#install.packages("pdfetch")
#install.packages("dygraphs")
library(flexdashboard)
library(pdfetch)
library(dygraphs)
library(xts)
comIDs <- c("CMCSA", "VZ", "T")
```
Intro {.sidebar}
-------------------------------------
The objective of this Dashboard is to analyze who is the most good company to invest in the telcom industry for maximizing profits.

* Here, stocks of Comcast Corporation, Verizon Communications Inc and AT&T Inc.  are analysed through visualizations. 

* The stock prices of Comcast Corporation continue to rise, which look like a good sign for  buying stock.

* Compaired Adjusted Closing price over the past one year, Verizon Communications Inc had a much higher adjusted closing price consistently, followeed by Comcast Corporation, AT&T Inc.'s stock closing price started going down consistently from mid of  2018 to Jan 2019, and then started picking up.


* As we know, the trading volume is an important measure for stock liquidity. The greater the liquidity means the trading volume is greater.In the past one and half year, AT&T Inc. has the largest volume.Verizon Communications Inc and Comcast Corporation have the similar size of volumes. 

* Based on the analysis,, it is safe to say that Verizon shares are more likely to give better profits in future.


Row {data-width=400}
-----------------------------------------------------------------------
Column {.tabset data-height=550}
-----------------------------------------------------------------------

### Comcast Corporation (CMCSA)

```{r}
baseCMCSA <- pdfetch_YAHOO("CMCSA", fields = c("open", "high", "low", "close"), from = as.Date("2018-07-01"),interval = "1d")
colnames(baseCMCSA)=c("Open","High","Low","Close")

m <- tail(baseCMCSA, n = 365)

#plot
dygraph(m,
        ylab = "Stock Price ($)",
        group = "stockprices") %>%
dyCandlestick() %>%
dyLegend(width = 400) %>%
dyRangeSelector(dateWindow = c("2018-07-01", "2019-06-30"))
```


### Verizon Communications Inc (VZ)

```{r}
baseVZ <- pdfetch_YAHOO("VZ", fields = c("open", "high", "low", "close"), from = as.Date("2018-07-01"),interval = "1d")
colnames(baseVZ)=c("Open","High","Low","Close")

m <- tail(baseVZ, n = 365)

#plot
dygraph(m,
        ylab = "Stock Price ($)",
        group = "stockprices") %>%
dyCandlestick() %>%
dyLegend(width = 400) %>%
dyRangeSelector(dateWindow = c("2018-07-01", "2019-06-30"))
```


### AT&T Inc. (T)

```{r}
baseT <- pdfetch_YAHOO("T", fields = c("open", "high", "low", "close"), from = as.Date("2018-07-01"),interval = "1d")
colnames(baseT)=c("Open","High","Low","Close")

m <- tail(baseT, n = 365)

#plot
dygraph(m,
        ylab = "Stock Price ($)",
        group = "stockprices") %>%
dyCandlestick() %>%
dyLegend(width = 400) %>%
dyRangeSelector(dateWindow = c("2018-07-01", "2019-06-30"))
```

More Trading Info
=====================================

Column
-----------------------------------------------------------------------

### Price
```{r}
financialPrice <- pdfetch_YAHOO(comIDs, fields = c("open","adjclose"), from = as.Date("2018-07-01"), to = as.Date("2019-06-30"),interval = "1d")

OneYAdjClose <- cbind(financialPrice$CMCSA.adjclose,financialPrice$VZ.adjclose, financialPrice$T.adjclose,financialPrice$LBTYA.adjclose)
colnames(OneYAdjClose) <-c("CMCSA", "VZ", "T")

c <- tail(OneYAdjClose, n = 365)
#plot
dygraph(c,
        main = "Adjusted Closing Price (past 365 trading days)", 
        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(dateWindow = c("2018-07-01", "2019-06-30"))
```


### Volume
```{r}
financialVolume <- pdfetch_YAHOO(comIDs, fields = c("open", "high", "low", "close","volume","adjclose"), from = as.Date("2018-07-01"),interval = "1d")


OneYRTradingVol <- cbind(financialVolume$CMCSA.volume,financialVolume$VZ.volume, financialVolume$T.volume,financialVolume$LBTYA.volume)
colnames(OneYRTradingVol) <-c("CMCSA", "VZ", "T")
t <- tail(OneYRTradingVol, n = 365)
#plot
dygraph(t,
        main = "Trading Volume (past 365 trading 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(dateWindow = c("2018-07-01", "2019-06-30"))
```