Base class for getting all data related to indices from Yahoo Finance API.
Methods
Method new()
Create a new Index object
Usage
Index$new(index = NA)
Examples
nifty_50 <- Index$new('^NSEI')
Method get_history()
Retrieves historical data
Arguments
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
ordate
object inyyyy-mm-dd
format.end
Specific ending date.
String
ordate
object inyyyy-mm-dd
format.
Examples
## ------------------------------------------------
## Method `Index$new`
## ------------------------------------------------
nifty_50 <- Index$new('^NSEI')
## ------------------------------------------------
## Method `Index$set_index`
## ------------------------------------------------
indice <- Index$new('^NSEI')
indice$set_index('^NDX')
## ------------------------------------------------
## Method `Index$get_history`
## ------------------------------------------------
# \donttest{
nifty <- Index$new('^NSEI')
nifty$get_history(start = '2022-07-01', interval = '1d')
#> date volume high low open close adj_close
#> 1 2022-07-01 03:45:00 364100 15793.95 15511.05 15703.70 15752.05 15752.05
#> 2 2022-07-04 03:45:00 304300 15852.35 15661.80 15710.50 15835.35 15835.35
#> 3 2022-07-05 03:45:00 254200 16025.75 15785.45 15909.15 15810.85 15810.85
#> 4 2022-07-06 03:45:00 288400 16011.35 15800.90 15818.20 15989.80 15989.80
#> 5 2022-07-07 03:45:00 264600 16150.50 16045.95 16113.75 16132.90 16132.90
#> 6 2022-07-08 03:45:00 281100 16275.50 16157.90 16273.65 16220.60 16220.60
#> 7 2022-07-11 03:45:00 255900 16248.55 16115.50 16136.15 16216.00 16216.00
#> 8 2022-07-12 03:45:00 208600 16158.75 16031.15 16126.20 16058.30 16058.30
#> 9 2022-07-13 03:45:00 233300 16140.00 15950.15 16128.20 15966.65 15966.65
#> 10 2022-07-14 03:45:00 228600 16070.85 15858.20 16018.85 15938.65 15938.65
#> 11 2022-07-15 03:45:00 205800 16066.95 15927.30 16010.80 16049.20 16049.20
#> 12 2022-07-18 03:45:00 227700 16287.95 16142.20 16151.40 16278.50 16278.50
#> 13 2022-07-19 03:45:00 222600 16359.50 16187.05 16187.05 16340.55 16340.55
#> 14 2022-07-20 03:45:00 284400 16588.00 16490.95 16562.80 16520.85 16520.85
#> 15 2022-07-21 03:45:00 243600 16626.95 16483.90 16523.55 16605.25 16605.25
#> 16 2022-07-22 03:45:00 190900 16752.25 16610.90 16661.25 16719.45 16719.45
#> 17 2022-07-25 03:45:00 211400 16706.05 16564.25 16662.55 16631.00 16631.00
#> 18 2022-07-26 03:45:00 208200 16636.10 16463.30 16632.90 16483.85 16483.85
#> 19 2022-07-27 03:45:00 185200 16653.45 16438.75 16475.35 16641.80 16641.80
#> 20 2022-07-28 03:45:00 376300 16947.65 16746.25 16774.85 16929.60 16929.60
#> 21 2022-07-29 03:45:00 436100 17172.80 17018.15 17079.50 17158.25 17158.25
#> 22 2022-08-01 03:45:00 381500 17356.25 17154.80 17243.20 17340.05 17340.05
#> 23 2022-08-02 03:45:00 333600 17390.15 17215.85 17310.15 17345.45 17345.45
#> 24 2022-08-03 03:45:00 285400 17407.50 17225.85 17349.25 17388.15 17388.15
#> 25 2022-08-04 03:45:00 325000 17490.70 17161.25 17463.10 17382.00 17382.00
#> 26 2022-08-05 03:45:00 355300 17474.40 17348.75 17423.65 17397.50 17397.50
#> 27 2022-08-08 03:45:00 257000 17548.80 17359.75 17401.50 17525.10 17525.10
#> 28 2022-08-10 03:45:00 312700 17566.10 17442.80 17566.10 17534.75 17534.75
#> 29 2022-08-11 03:45:00 311200 17719.30 17631.95 17711.65 17659.00 17659.00
#> 30 2022-08-12 03:45:00 303900 17724.65 17597.85 17659.65 17698.15 17698.15
#> 31 2022-08-16 03:45:00 0 17839.10 17764.05 17797.20 17825.25 17825.25
#> 32 2022-08-17 03:45:00 262800 17965.95 17833.35 17868.15 17944.25 17944.25
#> 33 2022-08-18 03:45:00 263900 17968.45 17852.05 17898.65 17956.50 17956.50
#> 34 2022-08-19 03:45:00 295600 17992.20 17710.75 17966.55 17758.45 17758.45
#> 35 2022-08-22 03:45:00 287600 17690.05 17467.35 17682.90 17490.70 17490.70
#> 36 2022-08-23 03:45:00 285600 17625.55 17345.20 17357.35 17577.50 17577.50
#> 37 2022-08-24 03:45:00 262000 17623.65 17499.25 17525.45 17604.95 17604.95
#> 38 2022-08-25 03:45:00 230200 17726.50 17487.45 17679.00 17522.45 17522.45
#> 39 2022-08-26 03:45:00 266600 17685.85 17519.35 17619.30 17558.90 17558.90
#> 40 2022-08-29 03:45:00 244900 17380.15 17166.20 17188.65 17312.90 17312.90
#> 41 2022-08-30 03:45:00 324700 17777.65 17401.50 17414.95 17759.30 17759.30
#> 42 2022-09-01 03:45:00 308500 17695.60 17468.45 17485.70 17542.80 17542.80
#> 43 2022-09-02 03:45:00 256300 17643.85 17476.45 17598.40 17539.45 17539.45
#> 44 2022-09-05 03:45:00 230300 17683.15 17540.35 17546.45 17665.80 17665.80
#> 45 2022-09-06 03:45:00 251200 17764.65 17587.65 17695.70 17655.60 17655.60
#> 46 2022-09-07 03:45:00 354100 17650.75 17484.30 17519.40 17624.40 17624.40
#> 47 2022-09-08 03:45:00 279800 17807.65 17691.95 17748.15 17798.75 17798.75
#> 48 2022-09-09 03:45:00 270300 17925.95 17786.00 17923.35 17833.35 17833.35
#> 49 2022-09-12 03:45:00 228200 17980.55 17889.15 17890.85 17936.35 17936.35
#> 50 2022-09-13 03:45:00 259900 18088.30 18015.45 18044.45 18070.05 18070.05
#> 51 2022-09-14 03:45:00 365900 18091.55 17771.15 17771.15 18003.75 18003.75
#> 52 2022-09-15 03:45:00 289600 18096.15 17861.50 18046.35 17877.40 17877.40
#> 53 2022-09-16 03:45:00 468500 17820.05 17497.25 17796.80 17530.85 17530.85
#> 54 2022-09-19 03:45:00 258300 17667.20 17429.70 17540.65 17622.25 17622.25
#> 55 2022-09-20 06:23:22 0 17879.65 17744.40 17770.40 17854.30 17854.30
nifty$get_history(start = '2022-07-01', end = '2022-07-14', interval = '1d')
#> date volume high low open close adj_close
#> 1 2022-07-01 03:45:00 364100 15793.95 15511.05 15703.70 15752.05 15752.05
#> 2 2022-07-04 03:45:00 304300 15852.35 15661.80 15710.50 15835.35 15835.35
#> 3 2022-07-05 03:45:00 254200 16025.75 15785.45 15909.15 15810.85 15810.85
#> 4 2022-07-06 03:45:00 288400 16011.35 15800.90 15818.20 15989.80 15989.80
#> 5 2022-07-07 03:45:00 264600 16150.50 16045.95 16113.75 16132.90 16132.90
#> 6 2022-07-08 03:45:00 281100 16275.50 16157.90 16273.65 16220.60 16220.60
#> 7 2022-07-11 03:45:00 255900 16248.55 16115.50 16136.15 16216.00 16216.00
#> 8 2022-07-12 03:45:00 208600 16158.75 16031.15 16126.20 16058.30 16058.30
#> 9 2022-07-13 03:45:00 233300 16140.00 15950.15 16128.20 15966.65 15966.65
nifty$get_history(period = '1mo', interval = '1d')
#> date volume high low open close adj_close
#> 1 2022-08-22 03:45:00 287600 17690.05 17467.35 17682.90 17490.70 17490.70
#> 2 2022-08-23 03:45:00 285600 17625.55 17345.20 17357.35 17577.50 17577.50
#> 3 2022-08-24 03:45:00 262000 17623.65 17499.25 17525.45 17604.95 17604.95
#> 4 2022-08-25 03:45:00 230200 17726.50 17487.45 17679.00 17522.45 17522.45
#> 5 2022-08-26 03:45:00 266600 17685.85 17519.35 17619.30 17558.90 17558.90
#> 6 2022-08-29 03:45:00 244900 17380.15 17166.20 17188.65 17312.90 17312.90
#> 7 2022-08-30 03:45:00 324700 17777.65 17401.50 17414.95 17759.30 17759.30
#> 8 2022-09-01 03:45:00 308500 17695.60 17468.45 17485.70 17542.80 17542.80
#> 9 2022-09-02 03:45:00 256300 17643.85 17476.45 17598.40 17539.45 17539.45
#> 10 2022-09-05 03:45:00 230300 17683.15 17540.35 17546.45 17665.80 17665.80
#> 11 2022-09-06 03:45:00 251200 17764.65 17587.65 17695.70 17655.60 17655.60
#> 12 2022-09-07 03:45:00 354100 17650.75 17484.30 17519.40 17624.40 17624.40
#> 13 2022-09-08 03:45:00 279800 17807.65 17691.95 17748.15 17798.75 17798.75
#> 14 2022-09-09 03:45:00 270300 17925.95 17786.00 17923.35 17833.35 17833.35
#> 15 2022-09-12 03:45:00 228200 17980.55 17889.15 17890.85 17936.35 17936.35
#> 16 2022-09-13 03:45:00 259900 18088.30 18015.45 18044.45 18070.05 18070.05
#> 17 2022-09-14 03:45:00 365900 18091.55 17771.15 17771.15 18003.75 18003.75
#> 18 2022-09-15 03:45:00 289600 18096.15 17861.50 18046.35 17877.40 17877.40
#> 19 2022-09-16 03:45:00 468500 17820.05 17497.25 17796.80 17530.85 17530.85
#> 20 2022-09-19 03:45:00 258300 17667.20 17429.70 17540.65 17622.25 17622.25
#> 21 2022-09-20 06:23:22 0 17879.65 17744.40 17770.40 17854.30 17854.30
# }