JerBouma / FinanceToolkit

Transparent and Efficient Financial Analysis
https://www.jeroenbouma.com/projects/financetoolkit
MIT License
2.99k stars 360 forks source link

[IMPROVE] NaN values in PVGO #129

Closed giraffeingreen closed 7 months ago

giraffeingreen commented 8 months ago

For the following code snippet:


from financetoolkit import Toolkit

toolkit = Toolkit(["NVDA", "AAPL","BRK.B"], api_key=API_KEY, start_date="2000-01-01")

pvgo = toolkit.models.get_present_value_of_growth_opportunities()
I get the following result: AAPL BRK.B NVDA
2000 0.4451 207.172 1.3462
2001 0.3214 98.699 5.283
2002 0.2313 114.778 1.0905
2003 0.3125 20.3332 1.677
2004 nan 5.1102 1.6264
2005 nan -25.3974 1.8248
2006 nan 3.8913 nan
2007 nan -39.0508 nan
2008 nan 81.6841 nan
2009 nan 48.8492 4.3185
2010 nan 31.844 3.6831
2011 nan -113.76 -2.3902
2012 nan 32.7019 1.6914
2013 10.6612 91.6904 3.0434
2014 10.24 75.3026 3.5505
2015 -197.63 -482.481 -16.096
2016 7.5209 57.8841 24.4573
2017 30.7936 110.427 46.3468
2018 93.9601 248.859 44.3535
2019 64.6675 90.3009 56.1368
2020 113.997 109.681 125.633
2021 159.81 89.0447 290.602
2022 155.176 209.412 154.967
2023 170.215 102.937 491.612
2024 nan nan 815.209

Does the FMP API miss something?

JerBouma commented 8 months ago

Solved! Total Debt was 0 for Apple which is why you see the NaNs. Please update to v1.8.5.

image
giraffeingreen commented 8 months ago

NVDA still exhibit a NaN value for 2008? Is this the anticipated behavior?

JerBouma commented 8 months ago

Ah I see, probably because interest expense is NaN in that case. I'll adjust this later.

giraffeingreen commented 8 months ago

Is that because we use WACC instead of the cost of equity, I can implement a flag to swap between using WACC or cost of equity.

JerBouma commented 8 months ago

Feel free to do so! Makes sense to have both.

giraffeingreen commented 7 months ago

I also talked to one of my finance teachers, and we figured it'd be better to go with the estimatedNetIncomeAvg from https://site.financialmodelingprep.com/developer/docs/analyst-estimates-api instead of using earnings from current period.

JerBouma commented 7 months ago

That's indeed also a good option, note that this is obtainable directly from the Finance Toolkit as well: https://www.jeroenbouma.com/projects/financetoolkit/docs#get_analyst_estimates (but I think you are aware of that đŸ˜‰ )