Closed inoddy closed 9 months ago
The mismatch in rows is due to NULL
values not being handled by the package. Will fix this at the earliest.
Great package, thanks. I also ran across this bug. Looking forward to when it gets fixed! Thank you!
Please install the latest development version from GitHub:
# install.packages("pak")
pak::pak("rsquaredacademy/yahoofinancer")
library(yahoofinancer)
nz50 = Index$new('^NZ50')
nz = nz50$get_history(start = '2003-01-03', interval = '1d')
head(nz)
#> date volume high low open close adj_close
#> 1 2003-01-02 21:00:00 0 1954.96 1954.96 1954.96 1954.96 1954.96
#> 2 2003-01-05 21:00:00 0 1981.10 1981.10 1981.10 1981.10 1981.1
#> 3 2003-01-06 21:00:00 0 1992.42 1992.42 1992.42 1992.42 1992.42
#> 4 2003-01-07 21:00:00 0 1987.99 1987.99 1987.99 1987.99 1987.99
#> 5 2003-01-08 21:00:00 0 1984.45 1984.45 1984.45 1984.45 1984.45
#> 6 2003-01-09 21:00:00 0 1998.91 1998.91 1998.91 1998.91 1998.91
Created on 2023-12-19 with reprex v2.0.2
Apologies, I fixed the issue for the indices but not the ticker.
library(yahoofinancer)
nz50 = Ticker$new('^NZ50')
nz = nz50$get_history(start = '2003-01-03', interval = '1d')
head(nz)
#> date volume high low open close adj_close
#> 1 2003-01-02 21:00:00 0 1954.96 1954.96 1954.96 1954.96 1954.96
#> 2 2003-01-05 21:00:00 0 1981.10 1981.10 1981.10 1981.10 1981.1
#> 3 2003-01-06 21:00:00 0 1992.42 1992.42 1992.42 1992.42 1992.42
#> 4 2003-01-07 21:00:00 0 1987.99 1987.99 1987.99 1987.99 1987.99
#> 5 2003-01-08 21:00:00 0 1984.45 1984.45 1984.45 1984.45 1984.45
#> 6 2003-01-09 21:00:00 0 1998.91 1998.91 1998.91 1998.91 1998.91
Created on 2023-12-20 with reprex v2.0.2
@tkfull
library(yahoofinancer)
x <- Ticker$new('hubb')
y <- x$get_history(start = '1995-01-01', interval = '1d')
head(y)
#> date volume high low open close adj_close
#> 1 1995-01-03 14:30:00 42630 25.179 24.822 25.12381 25.179 10.92304
#> 2 1995-01-04 14:30:00 72660 25.536 25.179 25.18095 25.536 11.07792
#> 3 1995-01-05 14:30:00 37380 25.953 25.536 25.54286 25.893 11.23278
#> 4 1995-01-06 14:30:00 95970 25.893 25.595 25.83809 25.595 11.10351
#> 5 1995-01-09 14:30:00 0 25.595 25.595 25.59500 25.595 11.10351
#> 6 1995-01-10 14:30:00 44400 25.813 25.500 25.69000 25.500 11.0623
Created on 2023-12-20 with reprex v2.0.2
nz50 = Index$new('^NZ50') nz = nz50$get_history(start = '2003-01-03', interval = '1d')
produces
Error in
$<-.data.frame
(*tmp*
, adj_close, value = c(1954.9599609375, : replacement has 5070 rows, data has 5191nz50 = Ticker$new('^NZ50') nz = nz50$get_history(start = '2003-01-03', interval = '1d')
produces
Error in data.frame(date = as_datetime(unlist(data$timestamp)), volume = unlist(indicators$volume), : arguments imply differing number of rows: 5191, 5070