APPLE Stock Price
Yearly trend shows increase in stock price.
---
title: "dashboard Lab1"
output:
flexdashboard::flex_dashboard:
orientation: columns
vertical_layout: fill
source_code: embed
---
APPLE Stock Price
```{r setup, include=FALSE}
```
Column {data-width=650}
-----------------------------------------------------------------------
### Chart A
Yearly trend shows increase in stock price.
```{r,echo = FALSE, message=FALSE}
library(flexdashboard)
library(lubridate) # easily work with dates and times
library(fpp2) # working with time series data
library(zoo) # working with time series data
library(data.table)
library(tidyverse)
AAPL<- read.csv("AAPL.csv", header=TRUE)
AAPL$Date1<- as.Date(AAPL$Date,format="%m/%d/%Y")
APPLE <- AAPL %>%
select(Date1, Close) %>%
mutate(sma5 = rollmean(Close, k = 5, fill = NA,align = "right" ),
sma9= rollmean(Close, k = 9, fill = NA,align = "right"),
sma21 = rollmean(Close, k = 21, fill = NA,align = "right"))
APPLE1<- APPLE %>%
gather(metric, value, sma5:sma21) %>%
ggplot(mapping=aes(Date1, value, color = metric)) +
geom_line()+
geom_point(mapping=aes(y=Close),color="Black")
APPLE1 + labs(x="Date", y="Price",title="APPLE Stock Price",
subtitle="Indicators=simple moving averages", caption="(based on yahoo finance data)")
```
Column {data-width=650}
-----------------------------------------------------------------------
### Chart B
Small simple moving average croses a large simple moving average signals strong buying sentiment.In following chart on 10th July 2018, 5 day moving average has croosed 21 day moving signaling strong indiction to buy the stock for short term profit
```{r}
library(flexdashboard)
library(lubridate) # easily work with dates and times
library(fpp2) # working with time series data
library(zoo) # working with time series data
library(data.table)
library(tidyverse)
AAPL<- read.csv("AAPL.csv", header=TRUE)
AAPL$Date1<- as.Date(AAPL$Date,format="%m/%d/%Y")
APPLE <- AAPL %>%
select(Date1, Close) %>%
mutate(sma5 = rollmean(Close, k = 5, fill = NA,align = "right" ),
sma9= rollmean(Close, k = 9, fill = NA,align = "right"),
sma21 = rollmean(Close, k = 21, fill = NA,align = "right"))
APPLE30<- tail(APPLE,30)
APPLE2<- APPLE30 %>%
gather(metric, value, sma5:sma21) %>%
ggplot(mapping=aes(Date1, value, color = metric)) +
geom_line()+
geom_point(mapping=aes(y=Close),color="Black") +
geom_vline(aes(xintercept =as.numeric(APPLE30$Date1[26])),linetype=8, na.rm=FALSE,color="Purple")
APPLE2 + labs(x="Date", y="Price",title="APPLE Stock Price Analysis last 30 days",
subtitle="sma5 crosses sma21 signals buying", caption="(based on yahoo finance data)")
```