-
-
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: catch errors and continue processing #135
Comments
Although my initial thought was to put the try/catch in each It might be simple to just loop over the symbols in whatever order they're passed in, and call each method on the symbol. Though I'm not sure the reason they're pulled in groups by source, and therefore a bit reluctant to change that. |
Was going to open a new entry, but saw this one which is (maybe) the enhancement I was thinking about. |
@helgasoft Yes, this issue is to implement what you describe. I started working on it, then ran into the issue I described in my first comment. |
FYI - this is working well, skipping delisted/misspelled symbols:
Warning message: |
@helgasoft you may use this to work around this in the mean time: lapply(ticker_list, function(x){ |
A long-term annoyance with getSymbols() is that an error downloading or reading data for any symbol causes no data to be loaded. Wrap the for loop body inside a try() call, and convert any errors into warnings. Also keep track of symbols that failed to load, so we only return ticker symbols that actually have data. See #135.
Use the same logic as getSymbols.yahoo(). See #135.
This is similar logic as getSymbols.yahoo(), for most of the remaining getSymbols() 'methods'. This does not include Alpha Vantage or Tiingo, because the logic in those functions are fairly different from the other 'methods'. See #135.
Replace the lapply(Symbols, ...) with a for loop, so we can reuse the same error-catching logic as the other getSymbols() 'methods'. Also add tests to ensure all getSymbols() 'methods' catch errors correctly. Only those that do not require a DB are tested. Fixes #135.
One consequence of this change is that |
A long-term annoyance with getSymbols() is that an error downloading or reading data for any symbol causes no data to be loaded. Wrap the for loop body inside a try() call, and convert any errors into warnings. Also keep track of symbols that failed to load, so we only return ticker symbols that actually have data. See #135.
Use the same logic as getSymbols.yahoo(). See #135.
This is similar logic as getSymbols.yahoo(), for most of the remaining getSymbols() 'methods'. This does not include Alpha Vantage or Tiingo, because the logic in those functions are fairly different from the other 'methods'. See #135.
It makes sense to throw an error when getSymbols() is called with only one single ticker. The new try-catch logic only warns. Check whether the main getSymbols() function is called with only a single ticker symbol and pass that logical value through to the "methods". We shouldn't check in each individual "method" because the main function may be called with tickers for multiple sources, but only one ticker for any single source. See #135.
Wrap
download.file()
in atry()
ortryCatch()
in order to catch errors and provide more useful messages to the user.For example, Google Finance does not provide historical data for the S&P 500 index, even though it's displayed on their website. Note there's no "Export/Download to spreadsheet" link under the historical chart like there are for symbols where
getSymbols.google()
works (e.g. General Electric).It would also be nice if a
download.file()
error did not completely stopgetSymbols()
whengetSymbols()
is called with multiple symbols.The text was updated successfully, but these errors were encountered: