Skip to content
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

BatchGetSymbols: Error in download #27

Closed
mattapel opened this issue Apr 29, 2022 · 16 comments
Closed

BatchGetSymbols: Error in download #27

mattapel opened this issue Apr 29, 2022 · 16 comments

Comments

@mattapel
Copy link

The function with snippet below was working very reliably, but now not working anymore at all.

I tried with several symbols to no success. Also tried your new package "fyR" - same result, that is none.

Any idea?

Snippet:
start_lng <- '2019-01-01'
list_yahoo_out <- BatchGetSymbols(c('BZ=F','NG=F', 'EURUSD=X', 'TTF=F'), first.date=start_lng, last.date=Sys.Date())

@OVVO-Financial
Copy link

Also downloading errors with following output from the vignette example:

> future::plan(future::multisession, workers = floor(parallel::detectCores()-1))
> tickers <- c('FB','MMM')
> first.date <- Sys.Date()-30
> last.date <- Sys.Date()
> l.out <- BatchGetSymbols(tickers = tickers,
+ first.date = first.date,
+ last.date = last.date, do.cache=FALSE)

Running BatchGetSymbols for:
   tickers =FB, MMM
   Downloading data for benchmark ticker
^GSPC | yahoo (1|1) - Error in download..
FB | yahoo (1|2) - Error in download..
MMM | yahoo (2|2) - Error in download..Error in `vec_slice()`:
! `x` must be a vector, not NULL.
Run `rlang::last_error()` to see where the error occurred.
Warning messages:
1: Unknown or uninitialised column: `ticker`. 
2: Unknown or uninitialised column: `threshold.decision`. 
3: Unknown or uninitialised column: `ticker`. 
4: Unknown or uninitialised column: `price.adjusted`. 
> print(l.out$df.control)
Error in print(l.out$df.control) : object 'l.out' not found
> print(l.out$df.tickers)
Error in print(l.out$df.tickers) : object 'l.out' not found
> rlang::last_error()
<error/vctrs_error_scalar_type>
Error in `vec_slice()`:
! `x` must be a vector, not NULL.
---
Backtrace:
 1. BatchGetSymbols::BatchGetSymbols(...)
 2. BatchGetSymbols::calc.ret(...)
 3. dplyr::lag(P)
 5. vctrs::vec_slice(inputs$x, seq_len(xlen - n))
Run `rlang::last_trace()` to see the full context.
> rlang::last_trace()
<error/vctrs_error_scalar_type>
Error in `vec_slice()`:
! `x` must be a vector, not NULL.
---
Backtrace:
    x
 1. +-BatchGetSymbols::BatchGetSymbols(...)
 2. | \-BatchGetSymbols::calc.ret(...)
 3. |   \-dplyr::lag(P)
 4. |     +-vctrs::vec_c(...)
 5. |     \-vctrs::vec_slice(inputs$x, seq_len(xlen - n))
 6. \-vctrs:::stop_scalar_type(`<fn>`(NULL), "x", `<env>`)
 7.   \-vctrs:::stop_vctrs(...)
 8.     \-rlang::abort(message, class = c(class, "vctrs_error"), ..., call = vctrs_error_call(call))

@msperlin
Copy link
Owner

The issue is due to a call to quantmod::getSymbols(), likely a change in yahoo finance api.
I'll investigate as soon as I can.

@msperlin
Copy link
Owner

See issue in quantmod

joshuaulrich/quantmod#358

@OVVO-Financial
Copy link

Installing quantmod via the following branch works, thanks!

devtools::install_github("joshuaulrich/quantmod", ref = "358-getsymbols-new.session")

@mattapel
Copy link
Author

Thanks a lot !!

@msperlin
Copy link
Owner

msperlin commented May 1, 2022

See my reply here

joshuaulrich/quantmod#358 (comment)

@Yuanyuan77-wang
Copy link

Yuanyuan77-wang commented May 5, 2022

library(yfR)
my_ticker <- 'FB'
first_date <- Sys.Date() - 30
last_date <- Sys.Date()
df_yf <- yf_get(tickers = my_ticker, first_date = first_date, last_date = last_date)

── Running yfR for 1 stocks | 2022-04-04 --> 2022-05-04 (30 days) ──

ℹ Downloading data for benchmark ticker ^GSPC
ℹ (1/1) Fetching data for FB
! - not cached
✖ - error in download..
ℹ Binding price data
Error in vec_slice():
! x must be a vector, not NULL.
Run rlang::last_error() to see where the error occurred.
Warning messages:
1: Unknown or uninitialised column: ticker.
2: Unknown or uninitialised column: threshold_decision.
3: Unknown or uninitialised column: ticker.
4: Unknown or uninitialised column: price_adjusted.
Hi,I tried to intsall “quantmod” ,but I still can't use it correctly ,Could you please guide me ,I don't know where the problem is.The same happens when I use “BatchGetSymbols“.Thanks.

@msperlin
Copy link
Owner

msperlin commented May 5, 2022

The code is working fine here. Make sure you update all your packages including quantmod:

library(yfR)
my_ticker <- 'FB'
first_date <- Sys.Date() - 30
last_date <- Sys.Date()
df_yf <- yf_get(tickers = my_ticker, first_date = first_date, last_date = last_date)

── Running yfR for 1 stocks | 2022-04-05 --> 2022-05-05 (30 days) ──

ℹ Downloading data for benchmark ticker ^GSPC
ℹ (1/1) Fetching data for FB
! - not cached
✔ - cache saved successfully
✔ - got 21 valid rows (2022-04-05 --> 2022-05-04)
✔ - got 100% of valid prices -- Youre doing good!
ℹ Binding price data

@msperlin
Copy link
Owner

msperlin commented May 5, 2022

Btw, please use the correct repo next time. This one is for BatchGetSymbols (and not yfR).

@Yuanyuan77-wang
Copy link

Btw, please use the correct repo next time. This one is for BatchGetSymbols (and not yfR).

Many thanks all! I will check it carefully.

@Yuanyuan77-wang
Copy link

Yuanyuan77-wang commented May 7, 2022

Sorry to bother you again,I've tried updating the quantmod package, but I'm still failing, which seems to be because I don't have access to yahoo. I checked the script of the package, the package accessed:(http://query2.finance.yahoo.com/), the problem is that I can't access:(http://query2.finance.yahoo.com/),I checked the engineer's answer: From November 1, 2021, users will not be able to use Yahoo's products and services from mainland China. This does not affect Yahoo's products and services elsewhere in the world. We thank you for your continued support.

In addition, I have an unkind request, I don't know if you could help me download the data set, the code that can be executed to get the data is:
library(BatchGetSymbols)
symbols <- c("AAPL", "T")
prices <- BatchGetSymbols(symbols, first.date = as.Date("1990-01-01"))

Anyway, I am very grateful to you for answering my confusion, if you can help me, Please send the data to my email: wangcongyuan@gamil.com or vitally@hdu.edu.cn,Thanks!

@Alberoyang
Copy link

Alberoyang commented May 7, 2022

Sorry to bother you that I meet an issue like Yuanyuan77-wang.
I cannot open (http://query2.finance.yahoo.com), but I can open the url (https://query2.finance.yahoo.com/v7/finance/options/AAPL).
In addition, Is there any other way to get data using (https://query2.finance.yahoo.com/v7/finance/options/AAPL).
Anyway, thank you very much.

@msperlin
Copy link
Owner

msperlin commented May 7, 2022

@Yuanyuan77-wang

Thanks for letting me know about china's restriction. This was news to me.
One solution you could try is to use a VPN to get a different IP.

As for the data, please send me an email (marceloperlin@gmail.com) and I'll reply with the data.

@msperlin
Copy link
Owner

msperlin commented May 7, 2022

@Alberoyang

All data is imported using quantmod::getSymbols(). You should check with its author which api endpoint is being queried.

@Alberoyang
Copy link

@Alberoyang

All data is imported using quantmod::getSymbols(). You should check with its author which api endpoint is being queried.

OK, thanks

@Yuanyuan77-wang
Copy link

Yuanyuan77-wang commented May 7, 2022

@msperlin Thanks for your time! I have emailed you.Anticipated you reply.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants