Closed espher1987 closed 1 year ago
Related to #258.
@espher1987, add 1 day to your retrieval will give you the data you want:
amzn <- getSymbols(Symbols = "AMZN",
from = "2010-12-31",
to = "2014-01-01",
auto.assign = FALSE)
I have noticed a similar issue. I typically do not specify a "to" date, assuming the most recent close date will be returned. This does not seem to be the case.
e.g.
> p <- getSymbols(Symbols = "^GSPC", auto.assign = FALSE)
> tail(p)
GSPC.Open GSPC.High GSPC.Low GSPC.Close GSPC.Volume GSPC.Adjusted
2022-10-20 3689.05 3736.00 3656.44 3665.78 4496620000 3665.78
2022-10-21 3657.10 3757.89 3647.42 3752.75 5078020000 3752.75
2022-10-24 3762.01 3810.74 3741.65 3797.34 4747930000 3797.34
2022-10-25 3799.44 3862.85 3799.44 3859.11 4843120000 3859.11
2022-10-26 3825.97 3886.15 3824.07 3830.60 4817310000 3830.60
2022-10-27 3834.69 3859.95 3803.79 3807.30 4687320000 3807.30
>
> p <- getSymbols(Symbols = "^GSPC", auto.assign = FALSE, to = Sys.Date())
> tail(p)
GSPC.Open GSPC.High GSPC.Low GSPC.Close GSPC.Volume GSPC.Adjusted
2022-10-20 3689.05 3736.00 3656.44 3665.78 4496620000 3665.78
2022-10-21 3657.10 3757.89 3647.42 3752.75 5078020000 3752.75
2022-10-24 3762.01 3810.74 3741.65 3797.34 4747930000 3797.34
2022-10-25 3799.44 3862.85 3799.44 3859.11 4843120000 3859.11
2022-10-26 3825.97 3886.15 3824.07 3830.60 4817310000 3830.60
2022-10-27 3834.69 3859.95 3803.79 3807.30 4687320000 3807.30
>
> p <- getSymbols(Symbols = "^GSPC", auto.assign = FALSE, to = Sys.Date() + 1)
> tail(p)
GSPC.Open GSPC.High GSPC.Low GSPC.Close GSPC.Volume GSPC.Adjusted
2022-10-21 3657.10 3757.89 3647.42 3752.75 5078020000 3752.75
2022-10-24 3762.01 3810.74 3741.65 3797.34 4747930000 3797.34
2022-10-25 3799.44 3862.85 3799.44 3859.11 4843120000 3859.11
2022-10-26 3825.97 3886.15 3824.07 3830.60 4817310000 3830.60
2022-10-27 3834.69 3859.95 3803.79 3807.30 4687320000 3807.30
2022-10-28 3808.26 3905.42 3808.26 3901.06 4459410000 3901.06
>
> Sys.Date()
[1] "2022-10-28"
I see a few related open issues. Is there a fix, beyond always adding to = Sys.Date() + 1
for safety?
What's your sessionInfo()?
Description
I'm trying to replicate an example from Ang, C. S. (2015). Analyzing financial data and implementing financial models using R. Springer, Retrieving yahoo finance data directly using getsymbols page 11, where i need to use
from =
andto=
arguments. Usingfrom = 2010-12-31"
andend = "2013-12-31"
Expected behavior
i expect data starting on "2010-12-31" and ending at "2013-12-31", using the same code used by Ang (2015).
Minimal, reproducible example
Created on 2022-01-29 by the reprex package (v1.0.0)
Session Info
Created on 2022-01-29 by the reprex package (v1.0.0)