library(flexdashboard)
library(quantmod)
## Loading required package: xts
## Loading required package: zoo
##
## Attaching package: 'zoo'
## The following objects are masked from 'package:base':
##
## as.Date, as.Date.numeric
## Loading required package: TTR
## Version 0.4-0 included new data defaults. See ?getSymbols.
library(dygraphs)
library(lubridate)
##
## Attaching package: 'lubridate'
## The following object is masked from 'package:base':
##
## date
library(RColorBrewer)
library(plotly)
## Loading required package: ggplot2
##
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
##
## last_plot
## The following object is masked from 'package:stats':
##
## filter
## The following object is masked from 'package:graphics':
##
## layout
tickers<-c("INFY","TCS","BLMT")
getSymbols(tickers)
## 'getSymbols' currently uses auto.assign=TRUE by default, but will
## use auto.assign=FALSE in 0.5-0. You will still be able to use
## 'loadSymbols' to automatically load data. getOption("getSymbols.env")
## and getOption("getSymbols.auto.assign") will still be checked for
## alternate defaults.
##
## This message is shown once per session and may be disabled by setting
## options("getSymbols.warning4.0"=FALSE). See ?getSymbols for details.
##
## WARNING: There have been significant changes to Yahoo Finance data.
## Please see the Warning section of '?getSymbols.yahoo' for details.
##
## This message is shown once per session and may be disabled by setting
## options("getSymbols.yahoo.warning"=FALSE).
## [1] "INFY" "TCS" "BLMT"
closePrice<-do.call(merge, lapply(tickers, function(x) Cl(get(x))))
dateWindow<-c("2015-01-01", "2018-01-01")
dygraph(closePrice, main="Value", group="Stock") %>%
dyRebase(value=100) %>%
dyAxis("y", label="Close Price(USD)") %>%
dyOptions(axisLineWidth = 1.5, colors = RColorBrewer::brewer.pal(3, "Set1")) %>%
dyRangeSelector(dateWindow = dateWindow)
closePrice<-do.call(merge, lapply(tickers, function(x) Cl(get(x))))
dateWindow<-c("2015-01-01", "2018-01-01")
dygraph(closePrice, main="Value", group="Stock") %>%
dyRebase(percent = TRUE) %>%
dyAxis("y", label="Close Price(USD)") %>%
dyOptions(axisLineWidth = 1.5, colors = RColorBrewer::brewer.pal(3, "Set1")) %>%
dyRangeSelector(dateWindow = dateWindow)
closePrice<-do.call(merge, lapply(tickers, function(x) Cl(get(x))))
dateWindow<-c("2015-01-01", "2018-01-01")
dygraph(closePrice, main="Value", group="Stock") %>%
dyRebase(percent = TRUE) %>%
dyAxis("y", label="Close Price(USD)") %>%
dyOptions(axisLineWidth = 1.5, colors = RColorBrewer::brewer.pal(3, "Set1")) %>%
dyRangeSelector(dateWindow = dateWindow)
These ratio helps us to understand how the stocks are doing. The return on single dollar investment. It helps us understand the resistance of the stock.
plot(INFY$INFY.Close)
plot(TCS$TCS.Close)
plot(BLMT$BLMT.Close)
## If you see the Close for three companies you can see that BLMT has done much better in the long term as compared to Infy and TCS.
INFYD <- data.frame(Date=index(INFY),coredata(INFY))
INFYD %>%
plot_ly(x = ~Date, type="candlestick",
open = ~INFY.Open, close = ~INFY.Close,
high = ~INFY.High, low = ~INFY.Low) %>%
layout(title = "INFY High Low Close Graph")
TCSD <- data.frame(Date=index(TCS),coredata(TCS))
TCSD %>%
plot_ly(x = ~Date, type="candlestick",
open = ~TCS.Open, close = ~TCS.Close,
high = ~TCS.High, low = ~TCS.Low) %>%
layout(title = "TCS High Low Close Graph")
BLMTD <- data.frame(Date=index(BLMT),coredata(BLMT))
BLMTD %>%
plot_ly(x = ~Date, type="candlestick",
open = ~BLMT.Open, close = ~BLMT.Close,
high = ~BLMT.High, low = ~BLMT.Low) %>%
layout(title = "BLMT High Low Close Graph")