-
-
Notifications
You must be signed in to change notification settings - Fork 225
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
getSymbols.yahoo() always throws "Error in new.session()" #358
Comments
The issue is located in the function Looking over the code. I don't see much point in the Removing the |
seeing same issue here |
one also needs to get rid of the if statement inside the .getHandle function which stops the process if the number of cookies is zero if (NROW(curl::handle_cookies(h)) ==0 p.s. thank you for the quick fix! Really appreciate it |
@pverspeelt and @alihru thanks for taking a look! I have a patch and am running CRAN and reverse-dependency checks now. |
Thanks for helping out @joshuaulrich . Im the author of BatchGetSymbols, which uses quantmod::getSymbols(), and got lots of emails this morning about the issue! |
Seeing the same issue here. |
@joshuaulrich just confirming that I have tested the fix on the |
what's the solution? These comments are not working! |
@asaeb1480 please try installing from the |
What's the exact code for installation of 358-getsymbols-new.session plz? |
|
Thank you @joshuaulrich I can't install it due to this error: Error: package ‘xts’ 0.12.1 was found, but > 0.12.1 is required by ‘quantmod’ The latest version of xts package is 0.12.1. I am running ubuntu 20.04 and R version of 4.1.2 |
@m1270 ah, that's because I have a change in development to move the S4 xts/zoo class to xts... I need to revert that. Thanks for the catch! |
Thanks joshua. getSymbols working now. |
That installs but doesn't appear to fix for me. |
I have the same issue as @mik3hall here! I tried to find it in the given directory on the computer, but the file still seems to be deleted once install is complete |
Thanks, Joshuaulrich. It's working for me. |
@TommyTorstP it is in the user library path that it indicated in the install but I must not default search that. Looking at how I can include that now. I assume it will eventually cran install to a normal system path. |
Hello, I'm very sorry but I'm an idiot when it comes to this stuff. I'm currently enrolled in a master's class but I've only been coding since January 2022. I have a project due tonight at midnight and it uses quantmod. How can I fix this error? I'm in Rstudio Thanks in advance. I know this has to be work. |
@pawatkins |
after a bit of experimenting, it is working for me too. Thanks @joshuaulrich! |
Thank you @joshuaulrich |
Hello, @joshuaulrich, thank you for helping with this issue, but I was trying to run the code you provided, but it is still not working for me and it gives me this error: ERROR: package installation failed (sorry I am new to this) Do you know what could be a problem? |
@TommyTorstP Still not working for me. Installed to...
This message is shown once per session and may be disabled by setting Error in new.session() : Could not establish session after 5 attempts.
|
Hi @zlfang00. That's very odd and it's not clear why |
@yw6010, that means you have an R session that already has quantmod loaded, so you can't change anything in the directory the package is installed in. You need to close all your R sessions on that computer, install quantmod, and then you can load and use quantmod. |
rstudio can load and keep links to packages active for intellisense parsing and such, even after a Session -> Restart R. best to shut down everything and do installs from a clean vanilla r session. |
it works now!!! very appreciate. time to resume my project haha |
Thank you for the quick fix @joshuaulrich Example: EMN | yahoo (161|506) | Found cache file - Got 100% of valid prices | Feels good! I have tried restarting R but now I cannot even receive one successful return. Each ticker states "Error in download" once again. Any ideas? Thank you |
Hi, Thank you very much for the fix and comments here. getSymols.yahoo() now works for me, but I have a different problem. When I run getSymbols.yahoo() successfully in a loop for more than about 300-400 tickers, I started to get "HTTP error 401" for all following downloads. There are some failed downloads of invalid tickers in between though. Does anyone know what the issue is? Maybe I have the same problem with @rhamo. Here is an example of the subsequent download: Thank you! |
> install.packages("quantmod")
> library(quantmod)
> remotes::install_github("joshuaulrich/xts", force = TRUE)
* installing *source* package 'xts' ...
ERROR: cannot remove earlier installation, is it in use?
* removing 'C:/Users/Tama/Documents/R/win-library/3.6/xts'
* restoring previous 'C:/Users/Tama/Documents/R/win-library/3.6/xts'
Error in file.copy(lp, dirname(pkgdir), recursive = TRUE, copy.date = TRUE) :
(converted from warning) problem copying C:\Users\Tama\Documents\R\win-library\3.6\00LOCK-xts\xts\libs\x64\xts.dll to C:\Users\Tama\Documents\R\win-library\3.6\xts\libs\x64\xts.dll: Permission denied
* removing 'C:/Users/Tama/Documents/R/win-library/3.6/xts'
* restoring previous 'C:/Users/Tama/Documents/R/win-library/3.6/xts'
Error in file.copy(lp, dirname(pkgdir), recursive = TRUE, copy.date = TRUE) :
(converted from warning) problem copying C:\Users\Tama\Documents\R\win-library\3.6\00LOCK-xts\xts\libs\x64\xts.dll to C:\Users\Tama\Documents\R\win-library\3.6\xts\libs\x64\xts.dll: Permission denied
Execution halted
Error: Failed to install 'xts' from GitHub:
(converted from warning) installation of package ‘C:/Users/Tama/AppData/Local/Temp/RtmpAnQpkC/file449050346c2/xts_0.12.1.2.tar.gz’ had non-zero exit status
> remotes::install_github("joshuaulrich/[email protected]")
installing *source* package 'quantmod' ...
** using staged installation
** R
** demo
** byte-compile and prepare package for lazy loading
Error: package 'xts' required by 'quantmod' could not be found
Execution halted
ERROR: lazy loading failed for package 'quantmod'
- removing 'C:/Users/Tama/AppData/Local/Temp/RtmpqubKOV/Rinst31ac26a1569f/quantmod'
-----------------------------------
ERROR: package installation failed
Error: Failed to install 'quantmod' from GitHub:
System command 'Rcmd.exe' failed, exit status: 1, stdout + stderr (last 10 lines):
E> ** using staged installation
E> ** R
E> ** demo
E> ** byte-compile and prepare package for lazy loading
E> Error: package 'xts' required by 'quantmod' could not be found
E> Execution halted
E> ERROR: lazy loading failed for package 'quantmod'
E> * removing 'C:/Users/Tama/AppData/Local/Temp/RtmpqubKOV/Rinst31ac26a1569f/quantmod'
E> -----------------------------------
E> ERROR: package installation failed I don't know what else to do. Help |
get this as well when apply patch: |
I've been having the same issue! |
Hi, @joshuaulrich, One thing I noticed is zoo is already installed in the public R library, while xts and TTR are not. My guess is this version quantmod only searches for its dependencies in the public library path?
|
ok remote is working |
Patched quantmod on CRAN nowThe source package for quantmod 0.4.20 has been released to CRAN! It may take another day or two for CRAN to build the Windows and macOS binaries, so users on those systems can install from source or wait for the binaries to be built. SponsorsI'd like to take this opportunity to thank those who started sponsoring me on GitHub today! Check out my sponsors profile if you didn't know about GitHub sponsors and you love my work on quantmod, xts, TTR, IBrokers, microbenchmark, etc. Tiers start at $1, and higher tiers give you access to an exclusive Slack community of my sponsors, private messages with me, and more. Yahoo Finance alternativeI also want to mention an alternative to Yahoo Finance data. I've found the end of day data from tiingo to be higher quality and the endpoint is more stable than Yahoo Finance. You need to sign up to get a free API key, and that gives individuals free access with 500 requests/hour and 20,000 requests/day, up to 5GB of data/month. Disclaimer: While I don't receive any referral compensation for pointing individuals to the Free Plan or Power Plan, I may receive compensation (I honestly don't remember how much) from them for new Commercial Plan customers who learned of tiingo through me. But you have to mention me when you join, I don't have an affiliate link or anything like that. |
@rhamo, @edwinhung, and @rpfreitasxyz A HTTP 401 response means the request is "unauthorized". That can happen for various reasons, but my guess is that you're hitting rate limits imposed by the Yahoo Finance servers. Let's move this conversation to #360. @zpio you shouldn't need to install xts from GitHub. You only need the version on CRAN. Can you try to install quantmod via @zlfang00 The new version of quantmod uses zoo, xts, and TTR just like prior versions. Nothing has changed in that regard, so I'm stumped about what's causing your issue.
@BathosEconTrade That looks like version 0.4.18 is being loaded instead of 0.4.19 or 0.4.20. Check |
Many thanks all! Great help. Must have version 4.2. |
Have tried with new quantmod 0.4.20 update but still no success. Every ticker states "Not Cached - Error in download" error as above. Any ideas on how to solve this issue? |
Thank you@joshuaulrich. The issue is resolved |
It seems that yahoo finance is now restricting access to the data. Once you download too much data, you get the "HTTP 401" error. This is controled by Yahoo and there is nothing myself or @joshuaulrich can do about it. As with any webscrapping script, you can try to overcome the restriction with:
Overall, if the limits are too restrictive, it might be best to find other source of price data. |
Is there any indication of what the Yahoo Rate limit is? I can also confirm that the VPN fix is working, thanks for putting some serious effort into this. :) |
@NilssonHedge Im looking into it right now.. It doenst seem too restrictive. After a 401 error, I can download again in a few minutes. |
are you sure it is the yahoo restriction? I tried Python package yfinance to grab the same size of date, no issues. |
The |
Changing ip has worked wonders. Once again BatchGetSymbols now retrieves data without errors. Thanks so much for all your help @msperlin and @joshuaulrich |
Hi, Really appreciate your dedication. I'm a new user to R (v 3.5.3) through Bert for Excel. I finally had everything working to call R functionality and getSymbols (with a single ticker) through an Excel VBA macro and then it abruptly stopped as noted in prior comments. It appears that the problem with getSymbols has been resolved and that I can now download quantmod v 4.20 zip file for Windows (10), which I did from the quantmod.zip link on the CRAN page dtd 2022-04-29, copying the unzipped quantmod directory to the BERT2/lib folder. The command "library (quantmod)" ouputs an error: "package or namespace load failed for 'quantmod' in rbind(info, getNamespaceInfo(env,"S3methods")). packageVersion("quantmod") outputs '0.4.20'. I must be doing something wrong! What is the proper way to install the new version of quantmod? Thanks for your help, |
Description
When applying the function
getSymbols()
, it errors and does not return a result.Minimal, reproducible example
The text was updated successfully, but these errors were encountered: