highcharter (version 0.7.0)

hc_add_series_ohlc: Shortcut for create candlestick charts

Description

This function helps to create candlestick from xts objects obtaining by getSymbols function from the quantmod.

Usage

hc_add_series_ohlc(hc, x, type = "candlestick", ...)

Arguments

hc

A highchart htmlwidget object.

x

A ohlc object from the quantmod package.

type

The type of chart. Can be candlestick or ohlc.

...

Additional shared arguments for the data series (http://api.highcharts.com/highcharts#series).

Examples

Run this code
# NOT RUN {
  

# }
# NOT RUN {
library("xts")

data(sample_matrix)

matrix_xts <- as.xts(sample_matrix, dateFormat = "Date")

head(matrix_xts)

class(matrix_xts)

highchart() %>% 
  hc_add_series_ohlc(matrix_xts)
   
library("quantmod")

x <- getSymbols("AAPL", auto.assign = FALSE)
y <- getSymbols("SPY", auto.assign = FALSE)

highchart() %>% 
  hc_add_series_ohlc(x) %>% 
  hc_add_series_ohlc(y)
  
# }
# NOT RUN {
  
# }

Run the code above in your browser using DataLab