Ljupch0 / yfinance

Tidy Financial Statement Data in R. Via the Yahoo Finance API.
31 stars 7 forks source link

Suppressing output #10

Closed dennisfisher closed 1 year ago

dennisfisher commented 1 year ago

I love yfinance -- however, there is one minor nuisance. When it runs, this type of output appears: Downloading Prices SQ [======================>---------------] 62% ETA: 5s Downloading Prices TTD [=======================>-------------] 65% ETA: 4s Downloading Prices TTEK [========================>-----------] 69% ETA: 4s Downloading Prices UNH [==========================>----------] 73% ETA: 3s Is it possible to suppress that output?

Ljupch0 commented 1 year ago

Hi Dennis, thanks for the kind words.

Not out of the box, but you can directly load the package functions and remove pb <- progress_bar(datatype = "Balance Sheets", ticker) and pb$tick from the definitions, and this will remove the progress bars.

dennisfisher commented 1 year ago

Ljupchi

Thanks for getting back to me. I tried the following:

require("yfinance") ticker <- c("AAPL") function (ticker) {

pb <- progress_bar(datatype = "Prices", ticker = ticker)

get_price_proto <- function(ticker, ...) {
    #pb$tick(tokens = list(what = ticker))
    jsonlite::flatten(jsonlite::fromJSON(glue::glue("https://query2.finance.yahoo.com/v10/finance/quoteSummary/{ticker}?modules=price"))[[1]][[1]][[1]]) %>% 
        select(ends_with(".raw")) %>% `names<-`(sub(".raw", 
        "", names(.))) %>% mutate(ticker = ticker, date = Sys.Date()) %>% 
        select(ticker, date, everything())
}
safe_download(vector = ticker, proto_function = get_price_proto)

}

I got an error message: Error in safe_download(vector = ticker, proto_function = get_price_proto) : could not find function "safe_download"

I presume that this is because safe_download is not exported. I then commented out that line of code -- this returns nothing.
And TEMP is:

TEMP function(ticker, ...) {

pb$tick(tokens = list(what = ticker))

jsonlite::flatten(jsonlite::fromJSON(glue::glue("https://query2.finance.yahoo.com/v10/finance/quoteSummary/{ticker}?modules=price"))[[1]][[1]][[1]]) %>% select(ends_with(".raw")) %>% names<-(sub(".raw", "", names(.))) %>% mutate(ticker = ticker, date = Smake thys.Date()) %>% select(ticker, date, everything()) } <environment: 0x7fa9550c7700>

I suspect that I am missing something quite simple -- can you advise how to make this work?

Dennis

Dennis Fisher MD P < (The "P Less Than" Company) Phone / Fax: 1-866-PLessThan (1-866-753-7784) www.PLessThan.com

On May 12, 2023, at 7:56 AM, Ljupcho Naumov @.***> wrote:

Hi Dennis, thanks for the kind words.

Not out of the box, but you can directly load the package functions and remove pb <- progress_bar(datatype = "Balance Sheets", ticker) and pb$tick from the definitions, and this will remove the progress bars.

— Reply to this email directly, view it on GitHub https://github.com/Ljupch0/yfinance/issues/10#issuecomment-1545874663, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABZKYUN3M7PFQFOUPQ5WFZLXFZFRVANCNFSM6AAAAAAX6SBM7Q. You are receiving this because you authored the thread.

Ljupch0 commented 1 year ago

Hi Dennis,

yes you are close. You need to load the utility functions used by all other functions in https://github.com/Ljupch0/yfinance/blob/master/R/utils.R

dennisfisher commented 1 year ago

Ljupcho

yfinanc stopped working today —repeated error messages of:

1: In open.connection(con, "rb") : cannot open URL 'https://query2.finance.yahoo.com/v10/finance/quoteSummary/AAPL?modules=price': HTTP status was '401 Unauthorized'

Are you aware of this?

Dennis

Dennis Fisher MD P < (The "P Less Than" Company) Phone / Fax: 1-866-PLessThan (1-866-753-7784) www.PLessThan.com http://www.plessthan.com/

On May 16, 2023, at 11:10 AM, Ljupcho Naumov @.***> wrote:

Hi Dennis,

yes you are close. You need to load the utility functions used by all other functions in https://github.com/Ljupch0/yfinance/blob/master/R/utils.R

— Reply to this email directly, view it on GitHub https://github.com/Ljupch0/yfinance/issues/10#issuecomment-1550139202, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABZKYUOJBLPLP7ELQ6ANG3LXGO7JTANCNFSM6AAAAAAX6SBM7Q. You are receiving this because you authored the thread.

Ljupch0 commented 1 year ago

Yes the yahoo finance api is down, maybe this endpoint has been shut down. Nothing I can do.

dennisfisher commented 1 year ago

unfortunate!

Dennis Fisher MD P < (The "P Less Than" Company) Phone / Fax: 1-866-PLessThan (1-866-753-7784) www.PLessThan.com http://www.plessthan.com/

On Jul 17, 2023, at 5:55 AM, Ljupcho Naumov @.***> wrote:

Yes the yahoo finance api is down, maybe this endpoint has been shut down. Nothing I can do.

— Reply to this email directly, view it on GitHub https://github.com/Ljupch0/yfinance/issues/10#issuecomment-1638087031, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABZKYUK4JPARRLYTURFCQCTXQUY3VANCNFSM6AAAAAAX6SBM7Q. You are receiving this because you authored the thread.