joshuaulrich / TTR

Technical analysis and other functions to construct technical trading rules with R
GNU General Public License v2.0
330 stars 103 forks source link

TTR::stockSymbols() not working in R console but works in RStudio #97

Closed SamoPP closed 4 years ago

SamoPP commented 4 years ago

Description

Running TTR::stockSymbols() in R console on Unbuntu 18.04 fails after upgrading from R 3.6 to R 4.0 while it stil works if I run TTR::stockSymbols() in RStudio (in R 4.0). It also fails in StatET R console (in R 4.0).

I guess this is not TTR related, however, I hope someone reading this might have an idea what might be wrong here.

Expected behavior

TTR::stockSymbols() runs without error.

Minimal, reproducible example

library(TTR)
symbols <- stockSymbols()

# In RStudio
> library(TTR)
> symbols <- stockSymbols()
Fetching AMEX symbols...
Fetching NASDAQ symbols...
Fetching NYSE symbols...
> 

# In R console in Terminal
> library(TTR)
> symbols <- stockSymbols()
Fetching AMEX symbols...
Error in file(file, "rt") : 
  cannot open the connection to 'https://old.nasdaq.com/screening/companies-by-name.aspx?letter=0&exchange=AMEX&render=download'
In addition: Warning message:
In file(file, "rt") :
  URL 'https://old.nasdaq.com/screening/companies-by-name.aspx?letter=0&exchange=AMEX&render=download': status was 'Failure when receiving data from the peer'
> traceback()
4: file(file, "rt")
3: read.table(file = file, header = header, sep = sep, quote = quote, 
       dec = dec, fill = fill, comment.char = comment.char, ...)
2: read.csv(url, header = TRUE, as.is = TRUE, na = "n/a") at WebData.R#127
1: stockSymbols()
> 

Session Info

# RStudio
> sessionInfo()
R version 4.0.2 (2020-06-22)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 18.04.4 LTS

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/openblas/libblas.so.3
LAPACK: /usr/lib/x86_64-linux-gnu/libopenblasp-r0.2.20.so

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

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

other attached packages:
[1] TTR_0.23-6

loaded via a namespace (and not attached):
[1] zoo_1.8-8       compiler_4.0.2  tools_4.0.2     xts_0.12-0      curl_4.3        grid_4.0.2     
[7] lattice_0.20-41

# R console in Terminal
> sessionInfo()
R version 4.0.2 (2020-06-22)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 18.04.4 LTS

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/openblas/libblas.so.3
LAPACK: /usr/lib/x86_64-linux-gnu/libopenblasp-r0.2.20.so

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

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

other attached packages:
[1] TTR_0.23-6

loaded via a namespace (and not attached):
[1] zoo_1.8-8       compiler_4.0.2  xts_0.12-0      curl_4.3       
[5] grid_4.0.2      lattice_0.20-41
SamoPP commented 4 years ago

This is indeed read.csv problem and not TTR problem. So I am closing this issue.

joshuaulrich commented 4 years ago

While I agree that this isn't necessarily a TTR issue, we can fix it.

joshuaulrich commented 4 years ago

Related to #66.

nknauer commented 4 years ago

Any update on this? Getting the same error but in RStudio:

symbols <- TTR::stockSymbols() Fetching AMEX symbols... Error in file(file, "rt") : cannot open the connection In addition: Warning message: In file(file, "rt") : InternetOpenUrl failed: 'The operation timed out'