---
title: "Netflix Stock Recommendation Dashboard"
author: "Mansi Joshi, Prerna Bajaj, Rishabh Kumar"
output:
flexdashboard::flex_dashboard:
orientation: columns
vertical_layout: fill
social: menu
source_code: embed
---
```{r setup, include=FALSE}
library(flexdashboard)
library(quantmod)
library(dygraphs)
library(TTR)
```
Inputs {.sidebar}
-------------------------------------
1. Netflix Time Series Graph
2. ROI of the Netflix stock Vs NASDAQ index is compared
3. Bollinger Band is plotted two standard deviations away from a simple moving average. The Bollinger band is shown with the candlestick graph. The term "up", "mavg", down" represents Bollinger Band.
4. MACD - It helps to quickly spot short term momentum. A nine-day EMA of the MACD, called the "signal line", is then plotted on top of the MACD, functioning as a trigger for buy and sell signals.
```{r Technical_Analysis}
invisible(getSymbols("NFLX", from = "2015-01-01", auto.assign=TRUE))
NFLX <- as.data.frame(NFLX)
# Simple Moving Averages (SMA)
# 20-day SMA
sma20 <- SMA(NFLX$NFLX.Close, n=20)
# 50-day SMA
sma50 <- SMA(NFLX$NFLX.Close, n=50)
# 200-day SMA
sma200 <- SMA(NFLX$NFLX.Close, n=200)
# Exponential Moving Average (EMA)
# 14-day EMA
ema14 <- EMA(NFLX$NFLX.Close, n=14)
# Bollinger Bands
bb20 <- BBands(NFLX$NFLX.Close, sd=2.0, n=14, maType=EMA)
# Overall data frame
NFLXplusBB <- data.frame(NFLX,bb20)
# Relative Strength Indicator
rsi14 <- RSI(NFLXplusBB$NFLX.Close, n=14)
#MACD
macd <- MACD(NFLXplusBB$NFLX.Close, nFast = 12, nSlow = 26,
nSig = 9, maType = SMA)
# allData
allData <- data.frame(NFLX,sma20,sma50,sma200,ema14,bb20,rsi14,macd)
```
Column {.tabset}
-------------------------------------
###Netflix Stock Price - Time Series Graph
```{r Relative_Rebase1}
invisible(getSymbols("NFLX", from = "2015-01-01", auto.assign=TRUE))
difference <- NFLX[, "NFLX.Open"] - NFLX[, "NFLX.Close"]
decreasing <- which(difference < 0)
increasing <- which(difference > 0)
dyData <- NFLX[, "NFLX.Close"]
ribbonData <- rep(0, nrow(dyData))
ribbonData[decreasing] <- 0.5
ribbonData[increasing] <- 1
dygraph(dyData, main = "Stock Price Movement since 2015") %>%
dyRibbon(data = ribbonData, top = 0.1, bottom = 0.02)
```
-------------------------------------
### Relative Rebase - Comparison of Stock Price with Nasdaq
```{r Relative_Rebase}
tickers <- c("NFLX", "NDAQ")
invisible(getSymbols(tickers))
closePrices <- do.call(merge, lapply(tickers, function(x) Cl(get(x))))
dateWindow <- c("2015-01-01", "2017-10-31")
dygraph(closePrices, main = "Stock performance Vs Nasdaq Composite performance", group = "stock") %>%
dyRebase(value = 100) %>%
dyRangeSelector(dateWindow = dateWindow, height = 100) %>%
dyAxis("y", label = "Price Index since 2015")
```
-------------------------------------
### Technical Analysis 1: Candlestick with Bollinger Bands {data-width=650}
```{r Stock_TimeSeries_Plot}
m <- cbind(allData[,1:4], allData[,11], allData[,12], allData[,13])
colnames(m)[5] <- "dn"
colnames(m)[6] <- "mavg"
colnames(m)[7] <- "up"
dygraph(m, main = "Stock Price - Candlestick Chart with Bollinger Bands" ) %>%
dyCandlestick() %>%
dyRangeSelector(height = 50)
```
-------------------------------------
### Technical Analysis 2: MACD
```{r Tech_Analysis_Plots}
#invisible(getSymbols("NFLX", from = "2015-01-01", auto.assign=TRUE))
#macd <- MACD(NFLX[,"NFLX.Close"], 12, 26, 9, maType ="EMA")
m <- cbind(allData[,1:4], allData[,16], allData[,17])
colnames(m)[5] <- "MACD"
colnames(m)[6] <- "MACD Signal Line"
dygraph(m, main = 'Moving Average Convergence Divergence') %>%
dyAxis("y", valueRange = c(-14, 14), label = "Rate of Convergence/ Divergence")%>%
dyRangeSelector(height = 50)
```