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

[IMPROVE] get_income_statement returns inaccurate results #94

Closed
laurynasas opened this issue Jan 3, 2024 · 6 comments
Closed

[IMPROVE] get_income_statement returns inaccurate results #94

laurynasas opened this issue Jan 3, 2024 · 6 comments

Comments

@laurynasas
Copy link

laurynasas commented Jan 3, 2024

Hi! I have been validating get_free_cash_flow_yield ratio and can see that for some tickers it is not accurate.

Example:

If i try to get ratio for HYMTF in the following way:

companies = Toolkit(
	tickers=tickers, 
	api_key=FMP_KEY, 
	start_date="2019-12-21",
	quarterly=False,
	# historical_source='YahooFinance',
)
print(companies.ratios.get_free_cash_flow_yield())

the result is:

date       2019      2020      2021     2022
HYMTF -294.1981 -298.0033 -330.6268 411.7727

but it cannot be larger than 1, right?

looking at the income statements, the Weighted Average Shares seems to be incorrect:

date                                                  2019          2020          2021           2022
Revenue                                      95171779800.0 93597840900.0 94088500800.0 114022028000.0
Cost of Goods Sold                           79282268100.0 76964337900.0 76544104800.0  91367586400.0
Gross Profit                                 15889511700.0 16633503000.0 17544396000.0  22654441600.0
Gross Profit Ratio                                  0.0002        0.0002        0.0001         0.0002
Research and Development Expenses             1160743500.0  1204084800.0  1227994400.0   1410199200.0
General and Administrative Expenses           1350061200.0  1304637300.0  1212272800.0   1663864800.0
Selling and Marketing Expenses                7141083300.0  8966731500.0  6915793600.0   8532795200.0
Selling, General and Administrative Expenses  8491144500.0 10271368800.0  8128066400.0  10196660000.0
Other Expenses                                2992669200.0  3002845500.0  2845176000.0   3191767200.0
Operating Expenses                           12644557200.0 14478299100.0 12201236800.0  14798626400.0
Cost and Expenses                            91926825300.0 91442637000.0 88745341600.0 106166212800.0
Interest Income                                461336400.0   361212300.0   278890400.0    511373600.0
Interest Expense                               285281100.0   326139300.0   243633600.0    428868800.0
Depreciation and Amortization                 4357631700.0  3975313500.0  4926842400.0   5547491200.0
EBITDA                                        7602586200.0  6130517400.0 10270001600.0  13403306400.0
EBITDA Ratio                                        0.0001        0.0001        0.0001         0.0001
Operating Income                              3244954500.0  2155203900.0  5343159200.0   7855815200.0
Operating Income Ratio                                 0.0           0.0           0.0         0.0001
Total Other Income                             502434900.0  -271273500.0  1024490400.0    902539200.0
Income Before Tax                             3747389400.0  1883930400.0  6367649600.0   8758354400.0
Income Before Tax Ratio                                0.0           0.0        0.0001         0.0001
Income Tax Expense                             880308000.0   151832700.0  1813188000.0   2371463200.0
Net Income                                    2682044100.0  1732097700.0  3953884800.0   5891491200.0
Net Income Ratio                                       0.0           0.0           0.0            0.0
EPS                                                 5.0895         3.316        7.5916        11.4084
EPS Diluted                                         5.0895         3.316        7.5916        11.4084
Weighted Average Shares                         474278.355   470110.8915   416658.9176    319576.4128
Weighted Average Shares Diluted                 474278.355   470110.8915   416658.9176    319576.4128

while directly querying FMP endpoint https://financialmodelingprep.com/api/v3/income-statement/HYMTF gives more reasonable results at least for share count:

  {
    "date": "2022-12-31",
    "symbol": "HYMTF",
    "reportedCurrency": "KRW",
    "cik": "0000000000",
    "fillingDate": "2022-12-31",
    "acceptedDate": "2022-12-31 00:00:00",
    "calendarYear": "2022",
    "period": "FY",
    "revenue": 142527535000000,
    "costOfRevenue": 114209483000000,
    "grossProfit": 28318052000000,
    "grossProfitRatio": 0.1986847805,
    "researchAndDevelopmentExpenses": 1762749000000,
    "generalAndAdministrativeExpenses": 2079831000000,
    "sellingAndMarketingExpenses": 10665994000000,
    "sellingGeneralAndAdministrativeExpenses": 12745825000000,
    "otherExpenses": 3989709000000,
    "operatingExpenses": 18498283000000,
    "costAndExpenses": 132707766000000,
    "interestIncome": 639217000000,
    "interestExpense": 536086000000,
    "depreciationAndAmortization": 6934364000000,
    "ebitda": 16754133000000,
    "ebitdaratio": 0.1175501492,
    "operatingIncome": 9819769000000,
    "operatingIncomeRatio": 0.0688973467,
    "totalOtherIncomeExpensesNet": 1128174000000,
    "incomeBeforeTax": 10947943000000,
    "incomeBeforeTaxRatio": 0.0768128278,
    "incomeTaxExpense": 2964329000000,
    "netIncome": 7364364000000,
    "netIncomeRatio": 0.0516697633,
    "eps": 14260.5,
    "epsdiluted": 14260.5,
    "weightedAverageShsOut": 399470516,
    "weightedAverageShsOutDil": 399470516,
    "link": null,
    "finalLink": null
  },

do you have any ideas what's the issue here?

Thanks!

@JerBouma
Copy link
Owner

JerBouma commented Jan 3, 2024

Ah!! The issue here is that I automatically convert financial statements based on their currency. E.g. in this case I'd convert the statement to USD given that the historical data is also in USD (so any calculation that would use both actually works). This is also very relevant when you wish to compare companies.

However, as the Income Statement contains the shares as well, which is not defined in a currency, this falsely alters these numbers. For now, disable this please by setting convert_currency=False within the Toolkit initialization.

companies = Toolkit(
	tickers=tickers, 
	api_key=FMP_KEY, 
	start_date="2019-12-21",
	quarterly=False,
        convert_currency=False,
	# historical_source='YahooFinance',
)
print(companies.ratios.get_free_cash_flow_yield())

Thanks for bringing this up, I'll fix this issue this week.

@laurynasas
Copy link
Author

Thank you, I tried this, the income statement now matches the FMP endpoint output:

date                                                      2019              2020              2021              2022
Revenue                                      105746422000000.0 103997601000000.0 117610626000000.0 142527535000000.0
Cost of Goods Sold                            88091409000000.0  85515931000000.0  95680131000000.0 114209483000000.0
Gross Profit                                  17655013000000.0  18481670000000.0  21930495000000.0  28318052000000.0
Gross Profit Ratio                                       0.167            0.1777            0.1865            0.1987
Research and Development Expenses              1289715000000.0   1337872000000.0   1534993000000.0   1762749000000.0
General and Administrative Expenses            1500068000000.0   1449597000000.0   1515341000000.0   2079831000000.0
Selling and Marketing Expenses                 7934537000000.0   9963035000000.0   8644742000000.0  10665994000000.0
Selling, General and Administrative Expenses   9434605000000.0  11412632000000.0  10160083000000.0  12745825000000.0
Other Expenses                                 3325188000000.0   3336495000000.0   3556470000000.0   3989709000000.0
Operating Expenses                            14049508000000.0  16086999000000.0  15251546000000.0  18498283000000.0
Cost and Expenses                            102140917000000.0 101602930000000.0 110931677000000.0 132707766000000.0
Interest Income                                 512596000000.0    401347000000.0    348613000000.0    639217000000.0
Interest Expense                                316979000000.0    362377000000.0    304542000000.0    536086000000.0
Depreciation and Amortization                  4841813000000.0   4417015000000.0   6158553000000.0   6934364000000.0
EBITDA                                         8447318000000.0   6811686000000.0  12837502000000.0  16754133000000.0
EBITDA Ratio                                            0.0799            0.0655            0.1092            0.1176
Operating Income                               3605505000000.0   2394671000000.0   6678949000000.0   9819769000000.0
Operating Income Ratio                                  0.0341             0.023            0.0568            0.0689
Total Other Income                              558261000000.0   -301415000000.0   1280613000000.0   1128174000000.0
Income Before Tax                              4163766000000.0   2093256000000.0   7959562000000.0  10947943000000.0
Income Before Tax Ratio                                 0.0394            0.0201            0.0677            0.0768
Income Tax Expense                              978120000000.0    168703000000.0   2266485000000.0   2964329000000.0
Net Income                                     2980049000000.0   1924553000000.0   4942356000000.0   7364364000000.0
Net Income Ratio                                        0.0282            0.0185             0.042            0.0517
EPS                                                     5655.0           3684.44            9489.5           14260.5
EPS Diluted                                             5655.0           3684.44            9489.5           14260.5
Weighted Average Shares                            526975950.0       522345435.0       520823647.0       399470516.0
Weighted Average Shares Diluted                    526975950.0       522345435.0       520823647.0       399470516.0

however companies.ratios.get_free_cash_flow_yield() is still inaccurate:

date       2019      2020      2021     2022
HYMTF -294.1981 -298.0033 -330.6268 411.7727

@laurynasas laurynasas reopened this Jan 3, 2024
@JerBouma
Copy link
Owner

JerBouma commented Jan 3, 2024

Thank you, I tried this, the income statement now matches the FMP endpoint output:

date                                                      2019              2020              2021              2022
Revenue                                      105746422000000.0 103997601000000.0 117610626000000.0 142527535000000.0
Cost of Goods Sold                            88091409000000.0  85515931000000.0  95680131000000.0 114209483000000.0
Gross Profit                                  17655013000000.0  18481670000000.0  21930495000000.0  28318052000000.0
Gross Profit Ratio                                       0.167            0.1777            0.1865            0.1987
Research and Development Expenses              1289715000000.0   1337872000000.0   1534993000000.0   1762749000000.0
General and Administrative Expenses            1500068000000.0   1449597000000.0   1515341000000.0   2079831000000.0
Selling and Marketing Expenses                 7934537000000.0   9963035000000.0   8644742000000.0  10665994000000.0
Selling, General and Administrative Expenses   9434605000000.0  11412632000000.0  10160083000000.0  12745825000000.0
Other Expenses                                 3325188000000.0   3336495000000.0   3556470000000.0   3989709000000.0
Operating Expenses                            14049508000000.0  16086999000000.0  15251546000000.0  18498283000000.0
Cost and Expenses                            102140917000000.0 101602930000000.0 110931677000000.0 132707766000000.0
Interest Income                                 512596000000.0    401347000000.0    348613000000.0    639217000000.0
Interest Expense                                316979000000.0    362377000000.0    304542000000.0    536086000000.0
Depreciation and Amortization                  4841813000000.0   4417015000000.0   6158553000000.0   6934364000000.0
EBITDA                                         8447318000000.0   6811686000000.0  12837502000000.0  16754133000000.0
EBITDA Ratio                                            0.0799            0.0655            0.1092            0.1176
Operating Income                               3605505000000.0   2394671000000.0   6678949000000.0   9819769000000.0
Operating Income Ratio                                  0.0341             0.023            0.0568            0.0689
Total Other Income                              558261000000.0   -301415000000.0   1280613000000.0   1128174000000.0
Income Before Tax                              4163766000000.0   2093256000000.0   7959562000000.0  10947943000000.0
Income Before Tax Ratio                                 0.0394            0.0201            0.0677            0.0768
Income Tax Expense                              978120000000.0    168703000000.0   2266485000000.0   2964329000000.0
Net Income                                     2980049000000.0   1924553000000.0   4942356000000.0   7364364000000.0
Net Income Ratio                                        0.0282            0.0185             0.042            0.0517
EPS                                                     5655.0           3684.44            9489.5           14260.5
EPS Diluted                                             5655.0           3684.44            9489.5           14260.5
Weighted Average Shares                            526975950.0       522345435.0       520823647.0       399470516.0
Weighted Average Shares Diluted                    526975950.0       522345435.0       520823647.0       399470516.0

however companies.ratios.get_free_cash_flow_yield() is still inaccurate:

date       2019      2020      2021     2022
HYMTF -294.1981 -298.0033 -330.6268 411.7727

Hi! This is correct given that the stock price is in USD (which is used to calculate the market cap) and the financial statement is KWD. Please wait for the fix.

@laurynasas
Copy link
Author

Ah I see, thank you very much! :)

@JerBouma
Copy link
Owner

JerBouma commented Jan 4, 2024

Alright, I have adjusted the income statement so that the weighted shares are not adjusted by the currency. What is good to note in this case is that it is better to find the ticker in which both financial statements and historical data line up. For example, "Hyundai Motor Company" reports their financial statements in KRW however the ticker you have chosen is the ticker as shown on the American exchange. This means that the historical market data is depicted in USD.

I automatically correct for this by finding the exchange rates and adjust the financial statement (so that the financial statement is the same as the historical data's currency) however this does lead to some discrepancies. Therefore, the more accurate result would be taking the ticker from the Korean exhange ("005380.KS", see https://sg.finance.yahoo.com/quote/005380.KS) which has both the financial statements as the historical data listed in KRW.

I did notice that the weighted shares is different for both (which is why the numbers don't align as well as you would expect) in which I've reached out to FinancialModelingPrep to explain the difference. I'll let you know once they reply. In any case, do these numbers align better with your expections? Note that the market cap is based on the Weighted Average Shares.

image

JerBouma added a commit that referenced this issue Jan 4, 2024
@JerBouma
Copy link
Owner

JerBouma commented Jan 5, 2024

This issue has been resolved in v1.7.4, see: https://github.com/JerBouma/FinanceToolkit/releases/tag/v1.7.4

@JerBouma JerBouma closed this as completed Jan 5, 2024
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