Index-class | R Documentation |
Base class for getting all data related to indices from Yahoo Finance API.
An R6 class object
index
Index for which data is retrieved
new()
Create a new Index object
Index$new(index = NA)
index
Index
A new 'Index' object
nifty_50 <- Index$new('^NSEI')
set_index()
Set a new index.
Index$set_index(index)
index
New index
indice <- Index$new('^NSEI') indice$set_index('^NDX')
get_history()
Retrieves historical data
Index$get_history(period = "ytd", interval = "1d", start = NULL, end = NULL)
period
Length of time. Defaults to 'ytd'
. Valid values are:
'1d'
'5d'
'1mo'
'3mo'
'6mo'
'1y'
'2y'
'5y'
'10y'
'ytd'
'max'
interval
Time between data points. Defaults to '1d'
. Valid values are:
'1m'
'2m'
'5m'
'15m'
'30m'
'60m'
'90m'
'1h'
'1d'
'5d'
'1wk'
'1mo'
'3mo'
start
Specific starting date. String
or date
object in yyyy-mm-dd
format.
end
Specific ending date. String
or date
object in yyyy-mm-dd
format.
A data.frame
.
\donttest{ nifty <- Index$new('^NSEI') nifty$get_history(start = '2022-07-01', interval = '1d') nifty$get_history(start = '2022-07-01', end = '2022-07-14', interval = '1d') nifty$get_history(period = '1mo', interval = '1d') }
clone()
The objects of this class are cloneable with this method.
Index$clone(deep = FALSE)
deep
Whether to make a deep clone.
## ------------------------------------------------
## Method `Index$new`
## ------------------------------------------------
nifty_50 <- Index$new('^NSEI')
## ------------------------------------------------
## Method `Index$set_index`
## ------------------------------------------------
indice <- Index$new('^NSEI')
indice$set_index('^NDX')
## ------------------------------------------------
## Method `Index$get_history`
## ------------------------------------------------
nifty <- Index$new('^NSEI')
nifty$get_history(start = '2022-07-01', interval = '1d')
nifty$get_history(start = '2022-07-01', end = '2022-07-14', interval = '1d')
nifty$get_history(period = '1mo', interval = '1d')
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.