joshuaulrich / quantmod

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

Yahoo Finance generates 'Couldn't resolve host name' error #311

Closed nzzl closed 4 years ago

nzzl commented 4 years ago

I'm using R-3.6.3 on an AWS instance of Ubunut 20.04 LTS, and I cannot access Yahoo data. I have tried other sources like FRED and I can access those. Also, I am running R-4.02 on a Windows laptop and I am able to access Yahoo data.

So the problems seems to be either (1) AWS settings or (2) R some issue with R-3.6.3.

How can I correct this problem?

I'd prefer not to upgrade my AWS instance, because that tends to create problems for scripts already running. Please advise.

Expected behavior

[Describe the behavior/output you expected]

getSymbols('MSFT',src='yahoo')

getSymbols('MSFT',src='yahoo') Error in download.file(paste(yahoo.URL, "s=", Symbols.name, "&a=", from.m, : cannot open URL 'http://ichart.finance.yahoo.com/table.csv?s=MSFT&a=0&b=01&c=2007&d=6&e=17&f=2020&g=d&q=q&y=0&z=MSFT&x=.csv' In addition: Warning message: In download.file(paste(yahoo.URL, "s=", Symbols.name, "&a=", from.m, : URL 'http://ichart.finance.yahoo.com/table.csv?s=MSFT&a=0&b=01&c=2007&d=6&e=17&f=2020&g=d&q=q&y=0&z=MSFT&x=.csv': status was 'Couldn't resolve host name'

Session Info

sessionInfo() R version 3.6.3 (2020-02-29) Platform: x86_64-pc-linux-gnu (64-bit) Running under: Ubuntu 20.04 LTS

Matrix products: default BLAS: /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.9.0 LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.9.0

locale: [1] LC_CTYPE=C.UTF-8 LC_NUMERIC=C LC_TIME=C.UTF-8 [4] LC_COLLATE=C.UTF-8 LC_MONETARY=C.UTF-8 LC_MESSAGES=C.UTF-8 [7] LC_PAPER=C.UTF-8 LC_NAME=C LC_ADDRESS=C [10] LC_TELEPHONE=C LC_MEASUREMENT=C.UTF-8 LC_IDENTIFICATION=C

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

other attached packages: [1] devtools_2.3.0 usethis_1.6.1 quantmod_0.4.17 TTR_0.23-6 [5] xts_0.12-0 zoo_1.8-8

loaded via a namespace (and not attached): [1] Rcpp_1.0.3 magrittr_1.5 pkgload_1.0.2 lattice_0.20-40 [5] R6_2.4.1 rlang_0.4.7 fansi_0.4.1 tools_3.6.3 [9] pkgbuild_1.0.6 grid_3.6.3 sessioninfo_1.1.1 cli_2.0.2 [13] withr_2.1.2 remotes_2.1.1 ellipsis_0.3.0 rprojroot_1.3-2 [17] assertthat_0.2.1 digest_0.6.25 crayon_1.3.4 processx_3.4.2 [21] callr_3.4.3 fs_1.3.1 ps_1.3.2 testthat_2.3.2 [25] curl_4.3 memoise_1.1.0 glue_1.4.1 compiler_3.6.3 [29] backports_1.1.5 desc_1.2.0 prettyunits_1.1.1

joshuaulrich commented 4 years ago

"Couldn't resolve host name" indicates this is a DNS error. I can't fix that.

I also see the URL is http:// not https://. getSymbols() started using https:// for Yahoo Finance in April 2017. That suggests you're using quantmod 0.4.7 (not 0.4.17) or earlier.

In short, you need to upgrade quantmod to a newer version.

nzzl commented 4 years ago

My version is quantmod_0.4.17

Is this not the most advanced version? If not, where do I find it, because that's the version shown on GitHub https://github.com/joshuaulrich/quantmod/releases/tag/v0.4-17 and CRAN https://cran.r-project.org/web/packages/quantmod/index.html, certainly you know.

If I am using latest version, of quantmod, how to force https.

sessionInfo() R version 4.0.0 (2020-04-24) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 10 x64 (build 19640)

Matrix products: default

locale: [1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252 [3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C

[5] LC_TIME=English_United States.1252

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

other attached packages: [1] quantmod_0.4.17 TTR_0.23-6 xts_0.12-0 zoo_1.8-8

loaded via a namespace (and not attached): [1] compiler_4.0.0 prettyunits_1.1.1 remotes_2.1.1 tools_4.0.0 testthat_2.3.2 [6] digest_0.6.25 pkgbuild_1.0.8 pkgload_1.1.0 memoise_1.1.0 lattice_0.20-41 [11] rlang_0.4.6 cli_2.0.2 rstudioapi_0.11 curl_4.3 xfun_0.15 [16] withr_2.2.0 httr_1.4.1 desc_1.2.0 fs_1.4.2 devtools_2.3.0 [21] rprojroot_1.3-2 grid_4.0.0 glue_1.4.1 R6_2.4.1 processx_3.4.2 [26] fansi_0.4.1 sessioninfo_1.1.1 callr_3.4.3 magrittr_1.5 backports_1.1.8 [31] ps_1.3.3 ellipsis_0.3.1 usethis_1.6.1 assertthat_0.2.1 tinytex_0.24 [36] crayon_1.3.4

On Fri, Jul 17, 2020 at 4:06 PM Joshua Ulrich notifications@github.com wrote:

"Couldn't resolve host name" indicates this is a DNS error. I can't fix that.

I also see the URL is http:// not https://. getSymbols() started using https:// for Yahoo Finance in April 2017. That suggests you're using quantmod 0.4.7 (not 0.4.17) or earlier.

In short, you need to upgrade quantmod to a newer version.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/joshuaulrich/quantmod/issues/311#issuecomment-660288722, or unsubscribe https://github.com/notifications/unsubscribe-auth/AD34MDJKFM4WXIRX77ZTSBDR4COL5ANCNFSM4O6XBIMQ .

joshuaulrich commented 4 years ago

You said you have the error on the AWS instance. So the version of R and quantmod that matter are what's installed on the Ubuntu 20.04 LTS you're running on AWS, not what you're running on your local Windows machine.

The error your reported was:

getSymbols('MSFT',src='yahoo')
Error in download.file(paste(yahoo.URL, "s=", Symbols.name, "&a=", from.m, :
cannot open URL 'http://ichart.finance.yahoo.com/table.csv?s=MSFT&a=0&b=01&c=2007&d=6&e=17&f=2020&g=d&q=q&y=0&z=MSFT&x=.csv'
In addition: Warning message:
In download.file(paste(yahoo.URL, "s=", Symbols.name, "&a=", from.m, :
URL 'http://ichart.finance.yahoo.com/table.csv?s=MSFT&a=0&b=01&c=2007&d=6&e=17&f=2020&g=d&q=q&y=0&z=MSFT&x=.csv': status was 'Couldn't resolve host name'

Note the URL in the error message. It's "http://ichart...". That URL hasn't been used since April, 2017. That is when it was changed to "https://ichart...". So your error message indicates you're running a very old version of quantmod on your AWS instance.

nzzl commented 4 years ago

Thanks for your quick response and apologies for the error. Here's the Ubuntu sessionInfo().

Also running: quantmod_0.4.17

sessionInfo() R version 3.6.3 (2020-02-29) Platform: x86_64-pc-linux-gnu (64-bit) Running under: Ubuntu 20.04 LTS

Matrix products: default BLAS: /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.9.0 LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.9.0

locale: [1] LC_CTYPE=C.UTF-8 LC_NUMERIC=C LC_TIME=C.UTF-8 [4] LC_COLLATE=C.UTF-8 LC_MONETARY=C.UTF-8 LC_MESSAGES=C.UTF-8 [7] LC_PAPER=C.UTF-8 LC_NAME=C LC_ADDRESS=C [10] LC_TELEPHONE=C LC_MEASUREMENT=C.UTF-8 LC_IDENTIFICATION=C

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

other attached packages: [1] quantmod_0.4.17 TTR_0.23-6 xts_0.12-0 zoo_1.8-8

loaded via a namespace (and not attached): [1] compiler_3.6.3 curl_4.3 grid_3.6.3 lattice_0.20-40

On Fri, Jul 17, 2020 at 7:45 PM Joshua Ulrich notifications@github.com wrote:

You said you have the error on the AWS instance. So the version of R and quantmod that matter are what's installed on the Ubuntu 20.04 LTS you're running on AWS, not what you're running on your local Windows machine.

The error your reported was:

getSymbols('MSFT',src='yahoo')Error in download.file(paste(yahoo.URL, "s=", Symbols.name, "&a=", from.m, :cannot open URL 'http://ichart.finance.yahoo.com/table.csv?s=MSFT&a=0&b=01&c=2007&d=6&e=17&f=2020&g=d&q=q&y=0&z=MSFT&x=.csv'In addition: Warning message:In download.file(paste(yahoo.URL, "s=", Symbols.name, "&a=", from.m, :URL 'http://ichart.finance.yahoo.com/table.csv?s=MSFT&a=0&b=01&c=2007&d=6&e=17&f=2020&g=d&q=q&y=0&z=MSFT&x=.csv': status was 'Couldn't resolve host name'

Note the URL in the error message. It's "http://ichart...". That URL hasn't been used since April, 2017. That is when it was changed to " https://ichart...". So your error message indicates you're running a very old version of quantmod on your AWS instance.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/joshuaulrich/quantmod/issues/311#issuecomment-660368549, or unsubscribe https://github.com/notifications/unsubscribe-auth/AD34MDIBDUKTGRP4DSZX443R4DIBRANCNFSM4O6XBIMQ .

nzzl commented 4 years ago

OK, I just tried again and it's working now, for reasons I don't understand. Thanks for your support.

Cheers, Greg

On Fri, Jul 17, 2020 at 8:01 PM Greg Wolfson gregory.wolfson@gmail.com wrote:

Thanks for your quick response and apologies for the error. Here's the Ubuntu sessionInfo().

Also running: quantmod_0.4.17

sessionInfo() R version 3.6.3 (2020-02-29) Platform: x86_64-pc-linux-gnu (64-bit) Running under: Ubuntu 20.04 LTS

Matrix products: default BLAS: /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.9.0 LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.9.0

locale: [1] LC_CTYPE=C.UTF-8 LC_NUMERIC=C LC_TIME=C.UTF-8 [4] LC_COLLATE=C.UTF-8 LC_MONETARY=C.UTF-8 LC_MESSAGES=C.UTF-8 [7] LC_PAPER=C.UTF-8 LC_NAME=C LC_ADDRESS=C [10] LC_TELEPHONE=C LC_MEASUREMENT=C.UTF-8 LC_IDENTIFICATION=C

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

other attached packages: [1] quantmod_0.4.17 TTR_0.23-6 xts_0.12-0 zoo_1.8-8

loaded via a namespace (and not attached): [1] compiler_3.6.3 curl_4.3 grid_3.6.3 lattice_0.20-40

On Fri, Jul 17, 2020 at 7:45 PM Joshua Ulrich notifications@github.com wrote:

You said you have the error on the AWS instance. So the version of R and quantmod that matter are what's installed on the Ubuntu 20.04 LTS you're running on AWS, not what you're running on your local Windows machine.

The error your reported was:

getSymbols('MSFT',src='yahoo')Error in download.file(paste(yahoo.URL, "s=", Symbols.name, "&a=", from.m, :cannot open URL 'http://ichart.finance.yahoo.com/table.csv?s=MSFT&a=0&b=01&c=2007&d=6&e=17&f=2020&g=d&q=q&y=0&z=MSFT&x=.csv'In addition: Warning message:In download.file(paste(yahoo.URL, "s=", Symbols.name, "&a=", from.m, :URL 'http://ichart.finance.yahoo.com/table.csv?s=MSFT&a=0&b=01&c=2007&d=6&e=17&f=2020&g=d&q=q&y=0&z=MSFT&x=.csv': status was 'Couldn't resolve host name'

Note the URL in the error message. It's "http://ichart...". That URL hasn't been used since April, 2017. That is when it was changed to " https://ichart...". So your error message indicates you're running a very old version of quantmod on your AWS instance.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/joshuaulrich/quantmod/issues/311#issuecomment-660368549, or unsubscribe https://github.com/notifications/unsubscribe-auth/AD34MDIBDUKTGRP4DSZX443R4DIBRANCNFSM4O6XBIMQ .

joshuaulrich commented 4 years ago

Did you turn it off and on again? :laughing:

I'm glad you got it working!

nzzl commented 4 years ago

Basically, yeah, seems R needed a restart. Thanks again for the awesome package & support. 👊

On Sat, Jul 18, 2020 at 6:59 AM Joshua Ulrich notifications@github.com wrote:

Did you turn it off and on again? 😆

I'm glad you got it working!

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/joshuaulrich/quantmod/issues/311#issuecomment-660459275, or unsubscribe https://github.com/notifications/unsubscribe-auth/AD34MDPM63KB2IQMIEWJNOLR4FW7NANCNFSM4O6XBIMQ .