joshuaulrich / quantmod

Quantitative Financial Modelling Framework
http://www.quantmod.com/
GNU General Public License v3.0
813 stars 224 forks source link

Issue with getQuote #390

Closed rabarros01 closed 1 year ago

rabarros01 commented 1 year ago

Description

Hi,

when running the function "getQuote", I am getting the following error message:

Error in open.connection(con, "rb") : HTTP error 404.

Expected behavior

This error has happened for quite some time. It used to run smoothly.

Minimal, reproducible example

Here is an example:

tickers = c("WM","TOM.OL")
data.stocks.last = getQuote(tickers, what=yahooQF("Last Trade (Price Only)"))

Session Info

And the error message pops up

Error in open.connection(con, "rb") : HTTP error 404.

Thanks!

joshuaulrich commented 1 year ago

What's your sessionInfo() output?

rabarros01 commented 1 year ago

Thanks for reaching out Joshua. Pasting the info below.

sessionInfo() R version 4.2.1 (2022-06-23 ucrt) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 10 x64 (build 19045)

Matrix products: default

locale: [1] LC_COLLATE=Swedish_Sweden.utf8 LC_CTYPE=Swedish_Sweden.utf8 LC_MONETARY=Swedish_Sweden.utf8 [4] LC_NUMERIC=C LC_TIME=Swedish_Sweden.utf8

attached base packages: [1] stats graphics grDevices utils datasets methods base

other attached packages: [1] quantmod_0.4.23 TTR_0.24.3 xts_0.12.2 zoo_1.8-11

loaded via a namespace (and not attached): [1] compiler_4.2.1 curl_4.3.3 grid_4.2.1 lattice_0.20-45

joshuaulrich commented 1 year ago

This is working for me.

quantmod::getQuote("WM;TOM.OL")
##                 Trade Time   Last    Change   % Change   Open   High    Low Volume
## WM     2023-07-11 11:58:54 169.88 -1.250000 -0.7304388 170.92 171.51 167.91 891472
## TOM.OL 2023-07-11 09:25:21 165.45  4.599991  2.8598015 163.00 164.50 161.45 480874
rabarros01 commented 1 year ago

Hi,

any clear solution to this error "Error in open.connection(con, "rb") : HTTP error 404."?

It seems like a similar error "Error in open.connection(con, "rb") : HTTP error 401." appeared in the past, and could be fixed with a patch by ethanbsmith, https://github.com/joshuaulrich/quantmod/issues/382

Thanks!

Kind regards, rabarros01

ethanbsmith commented 1 year ago

it looks like yahoo has removed the v6 endpoint which was a fallback because the v7 endpoint doesn't work in gdpr countries. We can probably improve the error message on this, but not fixable

https://query1.finance.yahoo.com/v6/finance/quote?TM {"finance":{"result":null,"error":{"code":"Not Found","description":"HTTP 404 Not Found"}}}

joshuaulrich commented 1 year ago

Good catch Ethan! I forgot about that issue for GDPR countries.