Stock Prices

Column

Alibaba (BABA)

Facebook (FB)

Netflix (NFLX)

Tesla (TSLA)

Adjusted Closing Prices

Column

Adjusted Closing Prices for Alibaba, Facebook, Netflix and Tesla

Trading Volumes

Column

Trading Volumes for Alibaba, Facebook, Netflix and Tesla

Summary

Column

Decision Summary

I picked 4 companies - Alibaba (BABA), Facebook (FB), Netflix (NFLX) and Tesla (TSLA), and performed analysis on their stock data. The data was sourced from Yahoo Finance and the time period of the data is from January 2017 to October 2019.

On the first tab, Stock Prices provided a graphical presentation of the daily data of the open and closing stock prices, along with the daily low and high for each of the 4 companies.

On the second tab, Adjusted Closing Prices performed visualizations of the comparison of the closing stock prices of all 4 companies.

On the third tab, Trading Volumes presented the trading volumes of all the 4 companies.

Based on the information in the previous tabs, all four stocks have experienced some certain level of rising in 2018. In 2019, Alibaba, Netflix and Tesla’s stock prices have shown some volatile from the year end performance of 2018. On the other hand, even though Facebook was subject to severe fluctuations in the early 2019, the price of the stock has reached quite closely to the highest level in 2018. As for the adjusted closing price, all four stocks has reached their hightest records since 2017 during the summer of 2018, especially in July. Tesla’s trading volumes are relatively lower as compared to other 3 companies, and Facebook’s stock price shriked dramaticly as its trading volume experienced a significat rise and drop in a short period of time.

Based on the analysis above, Alibaba looks to be a better choice of investment among the four stocks, and Facebook would be the second choice.

---
title: "ANLY 512 LAB 1"
author: "Xingchao Zhou"
output: 
  flexdashboard::flex_dashboard:
    orientation: rows
    social: menu
    source_code: embed
    vertical_layout: fill  
  html_document:
    df_print: paged
---

Stock Prices
=====================================

```{r setup, include=FALSE}
chooseCRANmirror(graphics=FALSE, ind=1)
library(flexdashboard)
library(pdfetch)
library(dygraphs)
library(xts)
identifiers <- c("BABA", "FB", "NFLX", "TSLA")
```


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

### Alibaba (BABA)

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

x <- tail(Alibaba, n = 1500)

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

### Facebook (FB)

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

x <- tail(Facebook, n = 1500)

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

### Netflix (NFLX)

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

x <- tail(Netflix, n = 1500)

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

### Tesla (TSLA)

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

x <- tail(Tesla, 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 Alibaba, Facebook, Netflix and Tesla

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

Adj_close <- cbind(financialData$BABA.adjclose,financialData$FB.adjclose, financialData$NFLX.adjclose, financialData$TSLA.adjclose)
colnames(Adj_close) <-c("BABA","FB","NFLX", "TSLA")

x <- tail(Adj_close, n = 1500)

#plot
dygraph(x,
        main = "Adjusted Closing Price", 
        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 Alibaba, Facebook, Netflix and Tesla

```{r}
financialData <- pdfetch_YAHOO(identifiers, fields = c("open", "high", "low", "close","volume","adjclose"), from = as.Date("2017-01-01"),interval = "1d")

Trade_vol <- cbind(financialData$BABA.volume,financialData$FB.volume, financialData$NFLX.volume, financialData$TSLA.volume)
colnames(Trade_vol) <-c("BABA","FB","NFLX", "TSLA")

x <- tail(Trade_vol, n = 1500)

#plot
dygraph(x,
        main = "Trading Volume", 
        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()
```

Summary 
=====================================

Column {data-width=600}
-------------------------------------

### Decision Summary

I picked 4 companies - Alibaba (BABA), Facebook (FB), Netflix (NFLX) and Tesla (TSLA), and performed analysis on their stock data. The data was sourced from Yahoo Finance and the time period of the data is from January 2017 to October 2019.

On the first tab, Stock Prices provided a graphical presentation of the daily data of the open and closing stock prices, along with the daily low and high for each of the 4 companies. 

On the second tab, Adjusted Closing Prices performed visualizations of the comparison of the closing stock prices of all 4 companies. 

On the third tab, Trading Volumes presented the trading volumes of all the 4 companies. 

Based on the information in the previous tabs, all four stocks have experienced some certain level of rising in 2018. In 2019, Alibaba, Netflix and Tesla's stock prices have shown some volatile from the year end performance of 2018. On the other hand, even though Facebook was subject to severe fluctuations in the early 2019, the price of the stock has reached quite closely to the highest level in 2018. As for the adjusted closing price, all four stocks has reached their hightest records since 2017 during the summer of 2018, especially in July. Tesla's trading volumes are relatively lower as compared to other 3 companies, and Facebook's stock price shriked dramaticly as its trading volume experienced a significat rise and drop in a short period of time.

Based on the analysis above, Alibaba looks to be a better choice of investment among the four stocks, and Facebook would be the second choice.