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

Wrong values gotten in the Cash Flow Statement of AMD #4

Open
darh78 opened this issue Jul 4, 2021 · 3 comments
Open

Wrong values gotten in the Cash Flow Statement of AMD #4

darh78 opened this issue Jul 4, 2021 · 3 comments

Comments

@darh78
Copy link

darh78 commented Jul 4, 2021

Hello Ljupcho,

Just to report a weird situation when retrieving the Cash Flow Statement of the ticker AMD.
The Operating Cash Flow (annual) for 2017 is not the same shown in the CF Statement in the Y! Finance web page.

image

VERSUS

image

I do not believe is any issue with the package, but an issue of the API.
In any case, I thought it was worth to share it.

Thanks for the package!

Daniel.

@Ljupch0
Copy link
Owner

Ljupch0 commented Oct 2, 2021

Hi Daniel, yes it's a strange issue of the api. I checked the financials and the figure on the website is the correct one. Interesting that the problem is only for 2017, the other figures are the same on the website and api.

@Tor-Storli
Copy link

Hi Ljupch0,

Thanks for making this yfinance package available in r.
I just wanted to let you know (perhaps you are aware of it already) that I am getting extra rows in my "get_financials" call to the API.
I fixed my code and was able to remove the extra rows. I did some additional digging and here is what I found.
I noticed from your r code on Github (get_financials) that you are doing full joins using the dplyr join statements:

get_financials <- function (ticker, report_type="annual") {
ticker <- base::toupper(ticker)
BS <- get_bs(ticker, report_type)
CF <- get_cf(ticker, report_type)
Income <- get_income(ticker, report_type)

a <- dplyr::full_join(BS, CF)
b <- dplyr::full_join(a, Income)

In my case that causes the extra rows. The reason is that some of the accounts appear in more than one of the financial statements. the full join without the reference to "ticker" and "date" only causes the extra rows to appear in the resulting output data frame.

So I get six rows instead of 4.

financials <- get_financials("ABBV", report_type = "annual")

When I run the code snippet above, r informs me about the following:
Joining, by = c("ticker", "date")
Joining, by = c("ticker", "date", "minorityInterest", "netIncome")

I do understand that it is very difficult to cater to all situations, and you probably structured your code so that it is more flexible.

Here is the code I used to make it work for my purpose:

#Income Statement
df_IS <- get_income(ticker="ABBV", report_type="annual")

Balance Sheet

df_BS <- get_bs(ticker="ABBV", report_type="annual")
df_BS <- subset(df_BS, select = -c(minorityInterest, ticker)) # remove repeat columns by name

Cash Flow

df_CF <- get_cf(ticker="ABBV", report_type="annual")
df_CF <- subset(df_CF, select = -c(netIncome, ticker)) # remove repeat columns by name

Combine the three financial Statements into one data frame

annual_report <- df_IS %>%
inner_join(df_BS, by='date') %>%
inner_join(df_CF, by='date')

I attached a couple of screenshots below.

Again, thanks for your hard work, much appreciated.

dups_in_yfinance

get_financials

@Ljupch0
Copy link
Owner

Ljupch0 commented Oct 7, 2022

Good catch @Tor-Storli! Feel free to do a pull request to fix the joins as I will not have time to fix this anytime soon.

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

3 participants