Column

R Markdown


The downloaded binary packages are in
    /var/folders/xj/tl6pm98x5qb3b_94_pxtg29h0000gn/T//RtmpNOo3oj/downloaded_packages

The downloaded binary packages are in
    /var/folders/xj/tl6pm98x5qb3b_94_pxtg29h0000gn/T//RtmpNOo3oj/downloaded_packages

The downloaded binary packages are in
    /var/folders/xj/tl6pm98x5qb3b_94_pxtg29h0000gn/T//RtmpNOo3oj/downloaded_packages

The downloaded binary packages are in
    /var/folders/xj/tl6pm98x5qb3b_94_pxtg29h0000gn/T//RtmpNOo3oj/downloaded_packages

Column

Stock Closing Prices

[1] "AAPL"
---
title: "Dashboard"
author: "Ning Yan & Yuyang Li"
date: "10/30/2017"
output: 
  flexdashboard::flex_dashboard:
    orientation: columns
    vertical_layout: fill
    social: menu
    source_code: embed
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE)
```

Sidebar {.sidebar}
-----------------------------------------------------------------------

### Financial Data Lab
Summarization:

From generated plots , we find that : APPL's stock price steadily rised in the past 2 years and shows heathy growing trend. The recent marketing of Iphone 8 and Iphone X has made Apple's stock price fluctuate, so we might look closely on Apple's price in the next few weeks. If Apple's price still shows highly variance, we will sell it. However, if Apple's price returns stable and continuely shows a healthy grow trend, we can hold the 5 shares.

Column {.tabset data-width=500}
-----------------------------------------------------------------------
  
## R Markdown


```{r message=FALSE, warning=FALSE,echo=FALSE }
options(repos=structure(c(CRAN="http://cran.us.r-project.org")))
install.packages('flexdashboard')
install.packages("tidyr")
install.packages("dygraphs")
install.packages("lubridate")
library(flexdashboard)
library(quantmod)
library(ggplot2)
library(tidyr)
library(plyr)
library(dygraphs)
library(lubridate)
```



```{r message=FALSE, warning=FALSE, echo=FALSE}
daily_stock_returns <- function(ticker, start_year){
  
symbol <- getSymbols(ticker, src = 'yahoo', auto.assign = FALSE, warnings = FALSE)
  
data <- periodReturn(symbol, period='monthly', subset=paste(start_year, "::", sep = ""), type ='log')

colnames(data) <- as.character(ticker)

assign(ticker, data, .GlobalEnv)

}

```


```{r message=FALSE, warning=FALSE, echo=FALSE}

date <- ymd("2016-01-01")

daily_stock_returns('AAPL', date)

merged_returns <- merge.xts(AAPL)
merged_returns_percent <- merged_returns * 100

dygraph(merged_returns_percent, main = "Monthly Return") %>%
  dyAxis("y", label = "Return(%)") %>%
  dyOptions(colors = RColorBrewer::brewer.pal(5, "Set1")) %>%
  dyHighlight(highlightSeriesBackgroundAlpha = 0.2,
              highlightSeriesOpts = list(strokeWidth = 2)) %>%
  dyRangeSelector(height = 65)
```


```{r message=FALSE, warning=FALSE, echo=FALSE}

date<-ymd("2016-01-01")
invisible(getSymbols("AAPL", src = "yahoo", from=date))
Apple<-AAPL[,-5]
colnames(Apple)<-c("Open","High","Low","Close","Adjusted")
dygraph(Apple, main = "Apple(AAPL)") %>%
  dyAxis("y", label="Price(USD)") %>%
  dyOptions(axisLineWidth = 1.5,  colors = RColorBrewer::brewer.pal(5, "Set1")) %>%
  dyCandlestick()
  
```


Column {.tabset data-width=550}
-----------------------------------------------------------------------
### Stock Closing Prices
```{r,echo=FALSE, message = FALSE}
ticker <- c("AAPL")
getSymbols(ticker, from="2016-01-01", to="2017-07-01")
ClosingPrices <- do.call(merge, lapply(ticker, function(x) Cl(get(x))))

dateperiod<-c("2016-01-01", "2017-07-01")
dygraph(ClosingPrices, main="Closing Price in Dollars", group="Stock") %>%
    dyAxis("y", label="Closing Price(USD)") %>%
  dyOptions(axisLineWidth = 2.0,  colors = RColorBrewer::brewer.pal(5, "Set1")) %>%
  dyHighlight(highlightSeriesBackgroundAlpha = 1.0,
              highlightSeriesOpts = list(strokeWidth = 3)) %>%
  dyRangeSelector(height = 65)
```