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

fatal error when one of the symbols returns only one row #23

Closed
rvalieris opened this issue Dec 1, 2022 · 6 comments
Closed

fatal error when one of the symbols returns only one row #23

rvalieris opened this issue Dec 1, 2022 · 6 comments

Comments

@rvalieris
Copy link

hello, I recently changed my code to use this package instead of BatchGetSymbols but the behavior changed, on BatchGetSymbols if one of the symbols don't return enough data it will be NA on the result table, on yf_get I get this fatal error below, and none of the other symbols data is returned, is there any way to use yf_get and still get the results of the other symbols ?
I tried setting thresh_bad_data=0 and do_complete_data=TRUE but that still results in a fatal error.

Error in `.f()`:
! Returned dataframe for DNAI11.SA between 2022-09-30 and 2022-12-02 has only ONE row.  Perhaps you should check
  your inputs dates?

and this is the function call:

	dd = yf_get(tickers=paste0(x$ticker,".SA"),first_date=d0, last_date=d+1, 
do_cache=T, bench_ticker="^BVSP", thresh_bad_data=0, do_complete_data=TRUE, freq_data='daily')

thanks.

@msperlin
Copy link
Collaborator

msperlin commented Dec 1, 2022

Hi Renan,

The idea is for the user to have more care regarding which tickers are being inputed. Since there isn't much you can do with a one row dataframe, perhaps you should remove DNAI11 from the requested ticker vector?

@rvalieris
Copy link
Author

yes, I agree this ticker is problematic, I don't know why but yahoo finance sometimes it returns more data and sometimes no data for this ticker.

however my script was already dealing with the missing data, and for some use cases just having the latest price is already useful so if possible I would like it return whatever data it got even if its just a single row. otherwise I can split the call in two parts, but I will need to change my script to keep track of which tickers are problematic.

@msperlin
Copy link
Collaborator

msperlin commented Dec 2, 2022

I can see your reasoning, and I agree with it. I'll make it a warning (and not an error). This will make sure the rest of the data is returned.

I'll leave this issue open and make the changes next week.

@rvalieris
Copy link
Author

thanks, to be clear, I think the default behavior as it works now is good and useful but, as I understand, if I set the option thresh_bad_data=0 I expected to get whatever data was returned even if its all missing at least thats how I understood BatchGetSymbols works.

msperlin added a commit that referenced this issue Dec 6, 2022
Merge branch 'main' of github.com:ropensci/yfR

# Conflicts:
#	NEWS.md
@msperlin
Copy link
Collaborator

msperlin commented Dec 6, 2022

Ok, fixed. Try it out:

remotes::install_github("ropensci/yfR")

@rvalieris
Copy link
Author

works great. thanks !

Fetching data for DNAI11.SA
! 	- not cached
✔ 	- got 1 valid rows (2022-12-06 --> 2022-12-06)
✔ 	- got 2% of valid prices -- Feliz que nem lambari de sanga!

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

2 participants