business-science / riingo

An R interface to the Tiingo stock price API
https://business-science.github.io/riingo/
Other
51 stars 9 forks source link

Safety #10

Closed DavisVaughan closed 5 years ago

DavisVaughan commented 5 years ago

Closes #6 by using purrr::safely() to catch any tickers that fail. If all fail, an error is thrown. Otherwise, the user is warned about the tickers that fail but the rest of the data is returned.

Example from that issue:

library(riingo)

tickers <- c("AAPL","IBM","F","BADTICKER")

riingo_prices(tickers)
#> Warning: Download failure with BADTICKER, removing. See full message below:
#> The ticker name, BADTICKER, is invalid or data is currently not available. Check ticker validity with is_supported_ticker().
#> Tiingo msg) Error: Ticker 'BADTICKER' not found
#> # A tibble: 753 x 14
#>    ticker date                close  high   low  open volume adjClose
#>    <chr>  <dttm>              <dbl> <dbl> <dbl> <dbl>  <int>    <dbl>
#>  1 AAPL   2018-05-10 00:00:00  190.  190.  188.  188. 2.80e7     187.
#>  2 AAPL   2018-05-11 00:00:00  189.  190.  187.  189. 2.62e7     186.
#>  3 AAPL   2018-05-14 00:00:00  188.  190.  188.  189. 2.08e7     186.
#>  4 AAPL   2018-05-15 00:00:00  186.  187.  185.  187. 2.37e7     184.
#>  5 AAPL   2018-05-16 00:00:00  188.  188.  186   186. 1.92e7     186.
#>  6 AAPL   2018-05-17 00:00:00  187.  189.  186.  188  1.73e7     185.
#>  7 AAPL   2018-05-18 00:00:00  186.  188.  186.  187. 1.83e7     184.
#>  8 AAPL   2018-05-21 00:00:00  188.  189.  187.  188  1.84e7     186.
#>  9 AAPL   2018-05-22 00:00:00  187.  189.  187.  188. 1.52e7     185.
#> 10 AAPL   2018-05-23 00:00:00  188.  188.  186.  186. 2.01e7     186.
#> # … with 743 more rows, and 6 more variables: adjHigh <dbl>, adjLow <dbl>,
#> #   adjOpen <dbl>, adjVolume <int>, divCash <dbl>, splitFactor <dbl>

Created on 2019-05-10 by the reprex package (v0.2.1.9000)