Load library install.packages("quantmod") install.packages("highcharter") install.packages("PerformanceAnalytics")
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
## Registered S3 method overwritten by 'quantmod':
## method from
## as.zoo.data.frame zoo
## Version 0.4-0 included new data defaults. See ?getSymbols.
library(highcharter)
library(PerformanceAnalytics)
##
## Attaching package: 'PerformanceAnalytics'
## The following object is masked from 'package:graphics':
##
## legend
Getting Stock market price from Yahoo finance
#Ini IHSG, kode tickernya ^JKSE
price_ihsg<-getSymbols("^JKSE",auto.assign=FALSE,from="2019-12-01",to="2020-12-26")
## '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: ^JKSE contains missing values. Some functions will not work if objects
## contain missing values in the middle of the series. Consider using na.omit(),
## na.approx(), na.fill(), etc to remove or replace them.
price_bbri<-getSymbols("BBRI.JK",auto.assign=FALSE,from="2019-12-01",to="2020-12-26")
price_bbca<-getSymbols("BBCA.JK",auto.assign=FALSE,from="2019-12-01",to="2020-12-26")
price_antm<-getSymbols("ANTM.JK",auto.assign=FALSE,from="2019-12-01",to="2020-12-26")
price_tlkm<-getSymbols("TLKM.JK",auto.assign=FALSE,from="2019-12-01",to="2020-12-26")
Look2 candlestick chart
highchart(type="stock") %>% hc_add_series(price_ihsg)%>%
hc_title(text="<b>IHSG Price Candle Stick Chart 2019Des-2020Des</b>")
highchart(type="stock") %>% hc_add_series(price_bbri)%>%
hc_title(text="<b>BBRI Price Candle Stick Chart 2019Des-2020Des</b>")
highchart(type="stock") %>% hc_add_series(price_bbca)%>%
hc_title(text="<b>BBCA Price Candle Stick Chart 2019Des-2020Des</b>")
highchart(type="stock") %>% hc_add_series(price_antm)%>%
hc_title(text="<b>ANTM Price Candle Stick Chart 2019Des-2020Des</b>")
highchart(type="stock") %>% hc_add_series(price_tlkm)%>%
hc_title(text="<b>TLKM Price Candle Stick Chart 2019Des-2020Des</b>")
Return atau pertumbuhan saham
return<-dailyReturn(Cl(price_ihsg))
## Warning in to_period(xx, period = on.opts[[period]], ...): missing values
## removed from data
return<-dailyReturn(Cl(price_bbri))
return<-dailyReturn(Cl(price_bbca))
return<-dailyReturn(Cl(price_antm))
return<-dailyReturn(Cl(price_tlkm))
Plot semua harga saham
highchart(type="stock") %>%
hc_add_series(Cl(price_ihsg),name="IHSG") %>%
hc_add_series(Cl(price_bbri),name="BBRI") %>%
hc_add_series(Cl(price_bbca),name="BBCA") %>%
hc_add_series(Cl(price_antm),name="ANTM") %>%
hc_add_series(Cl(price_tlkm),name="tlkm") %>%
hc_title(text="<b>IHSG vs BBRI vs BBCA vs ANTM vs TLKM Closing Price</b>")