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

tq_get when yahoo finance returns non unique rows #212

Open
risktoollib opened this issue Mar 13, 2022 · 0 comments
Open

tq_get when yahoo finance returns non unique rows #212

risktoollib opened this issue Mar 13, 2022 · 0 comments

Comments

@risktoollib
Copy link

risktoollib commented Mar 13, 2022

Most recent day often returns non-unique values which returns a warning. Problem is with the yahoo extract in the first place via quantmod then passed on to tq_get().

Suggest to amend tq_get just before the return(ret) last line to include:

if (identical(get, "stock.prices")) {
    ret <- ret %>%
    dplyr::group_by(symbol, date) %>%
    dplyr::summarise(open = dplyr::last(open),
                     high = dplyr::last(high),
                     low = dplyr::last(low),
                     close = dplyr::last(close),
                     volume = dplyr::last(volume),
                     adjusted = dplyr::last(adjusted)) %>%
        dplyr::ungroup()
    }

At times yahoo finance returns duplicate last day and at other times everything is the same with the exception of volume. Hence the approach above instead of dplyr::distinct().

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

1 participant