Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getQuote throws 404 error in GDPR countries #392

Closed
chartviewer opened this issue Jul 20, 2023 · 2 comments · Fixed by #395
Closed

getQuote throws 404 error in GDPR countries #392

chartviewer opened this issue Jul 20, 2023 · 2 comments · Fixed by #395

Comments

@chartviewer
Copy link

Description

The command getQuote("AAPL") throws the error "Error in open.connection(con, "rb") : HTTP error 404". Any chance to fix that?
Thanks a lot!
Thorsten

Expected behavior

I would expect to get a dataframe containing the most recent quote from yahoo as the default src

Minimal, reproducible example

library(quantmod)
getQuote("AAPL")

Session Info

R version 4.3.0 (2023-04-21 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19045)

Matrix products: default


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

time zone: Europe/Berlin
tzcode source: internal

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

other attached packages:
[1] quantmod_0.4.24 TTR_0.24.3      xts_0.13.1      zoo_1.8-12     

loaded via a namespace (and not attached):
 [1] crayon_1.5.2      cli_3.6.1         knitr_1.43        xfun_0.39         rlang_1.1.1      
 [6] processx_3.8.1    jsonlite_1.8.4    prettyunits_1.1.1 rprojroot_2.0.3   htmltools_0.5.5  
[11] pkgbuild_1.4.0    ps_1.7.5          rmarkdown_2.22    grid_4.3.0        evaluate_0.21    
[16] fastmap_1.1.1     yaml_2.3.7        compiler_4.3.0    rstudioapi_0.14   lattice_0.21-8   
[21] digest_0.6.31     R6_2.5.1          curl_5.0.0        callr_3.7.3       tools_4.3.0      
[26] withr_2.5.0       remotes_2.4.2     desc_1.4.2  
@ethanbsmith
Copy link
Contributor

you are most likely running into an issue that yahoo now requires GDPR consent, which cannot be scripted. i have pushed a patch that will give a better error message. if you would like to test it:

remotes::install_github("ethanbsmith/quantmod@fix_404_handle_getquote_gdpr_errors")

@joshuaulrich
Copy link
Owner

@chartviewer we don't currently have a fix for this, because it's not clear how to programmatically consent to GDPR. More information is in the comments of #382.

@joshuaulrich joshuaulrich changed the title getQuote throws and error 404 getQuote throws 404 error in GDPR countries Jul 20, 2023
@joshuaulrich joshuaulrich added this to the Release 0.4.25 milestone Jul 27, 2023
joshuaulrich added a commit that referenced this issue Jul 27, 2023
Yahoo Finance requires GDPR consent in some countries. We can't
automatically consent for the user, so the data request fails with an
ambiguous 404 error.

Yahoo also started to require a User-Agent in the header.

Fixes #392. Fixes #393.

Co-authored-by: Ethan Smith <24379655+ethanbsmith@users.noreply.github.com>
netbsd-srcmastr pushed a commit to NetBSD/pkgsrc that referenced this issue Jan 4, 2025
### Changes in 0.4.25 (2023-08-21)

1. Fix `getQuote.yahoo()` for API changes. Thanks to Ethan B. Smith for the
    report and patch! Also add error message for users in GDPR countries, since
    we cannot automatically consent to GDPR and the request fails without
    consent.
    [#392](joshuaulrich/quantmod#392)
    [#393](joshuaulrich/quantmod#393)
    [#395](joshuaulrich/quantmod#395)

1. Fix `getQuote.yahoo()` when the user only requested metrics that do not have
    have a value for 'regularMarketTime'. Set the value to NA in these cases
    so the output remains the same regardless of whether the endpoint returns
    a 'regularMarketTime' or not. Thanks to @mehdiMBH for the report!
    [#255](joshuaulrich/quantmod#255)

1. Add fields to `getQuote.yahoo()` that are returned when no fields are
    explicitly requested. Thanks to @Courvoisier13 for the report!
    [#335](joshuaulrich/quantmod#335)

1. Add intraday endpoint to `getSymbols.yahoo()`. Thanks to @kapsner for the
    report and patch! Also allow suppressing the warning if more than 7 days
    of data are requested (@eddelbuettel).
    [#351](joshuaulrich/quantmod#351)
    [#381](joshuaulrich/quantmod#381)
    [#399](joshuaulrich/quantmod#399)

1. Add warning if `getSymbols()` is called with tickers that are reserved words
    because accessing them requires back-quotes (e.g. ``NA``).
    [#401](joshuaulrich/quantmod#401)

1. Fix `allReturns()` when 'subset' is specified. Thanks to @Panagis1980 for
    the report!
    [#402](joshuaulrich/quantmod#402)

### Changes in 0.4.24 (2023-07-17)

1. Fix `getSymbols.oanda()` URL. Thanks to @macray76 for the report.
    [#387](joshuaulrich/quantmod#387)

### Changes in 0.4.23 (2023-06-14)

1. Fix `getQuote.yahoo()` error. Thanks to Ethan B. Smith for the report and
    patch!
    [#382](joshuaulrich/quantmod#382)
    [#383](joshuaulrich/quantmod#383)

1. Add `name` argument to `add_TA()`. Thanks to @SamoPP for the suggestion!
    [#377](joshuaulrich/quantmod#377)
    [#205](joshuaulrich/quantmod#205)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants