The FinanceToolkit is an open-source toolkit in which all relevant financial ratios (100+), indicators and performance measurements are written down in the most simplistic way allowing for complete transparency of the calculation method. This allows you to not have to rely on metrics from other providers and, given a financial statement, allow for efficient manual calculations. This leads to one uniform method of calculation being applied that is available and understood by everyone.
To install the FinanceToolkit it simply requires the following:
pip install financetoolkit -U
From within Python use:
from financetoolkit import Toolkit
To be able to get started, you need to obtain an API Key from FinancialModelingPrep. This is used to gain access to 30+ years of financial statement both annually and quarterly. Note that the Free plan is limited to 250 requests each day, 5 years of data and only features companies listed on US exchanges.
Through the link you are able to subscribe for the free plan and also premium plans at a 15% discount. This is an affiliate link and thus supports the project at the same time. I have chosen FinancialModelingPrep as a source as I find it to be the most transparent, reliable and at an affordable price. When you notice that data is inaccurate or have any other issue related to the data, note that I simply provide the means to access this data and I am not responsible for the accuracy of the data itself. For this, use their contact form or provide the data yourself.
The current Notebook is revolved around the Ratios class. If you are interested in the other modules, you can find the related Notebooks below. Please view the documentation here to find all the available functionality.
import pandas as pd
from financetoolkit import Toolkit
API_KEY = "FINANCIAL_MODELING_PREP_API_KEY"
Initializing only is required once. This is the case for any function so once you have obtained a balance sheet statement, it will be stored accordingly which means that requests to FinancialModelingPrep, the source used in these examples, are kept to a minimum. Note that in this example annual data is used but by adding quarterly=True
to the Toolkit initialization, quarterly data can also be collected. Note that this requires a Premium subscription from FMP.
# Initialize the Toolkit with company tickers
companies = Toolkit(
["AAPL", "AMZN", "META", "WMT"], api_key=API_KEY, start_date="2005-01-01"
)
After initialization of Toolkit
, you can get access to the Ratios module which includes over 50 different ratios. This can be done by calling the ratios
property. Please view the documentation here to find all the available ratios.
Within this ratios module, the distinction is made between collect_
and get_
. The former obtains a collection of ratios (e.g. all solvency ratios) whereas the latter obtains a specific ratio. You will note that it will collect data first, this is done only once so that the ratios can be calculated efficiently. For example, let's start with getting all ratios.
companies.ratios.collect_all_ratios()
Obtaining financial statements: 100%|██████████| 3/3 [00:04<00:00, 1.35s/it] Obtaining historical data: 100%|██████████| 5/5 [00:00<00:00, 9.30it/s]
2005 | 2006 | 2007 | 2008 | 2009 | 2010 | 2011 | 2012 | 2013 | 2014 | 2015 | 2016 | 2017 | 2018 | 2019 | 2020 | 2021 | 2022 | 2023 | ||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
AAPL | Days of Inventory Outstanding (DIO) | NaN | 5.7875 | 7.0918 | 7.314 | 7.5193 | 6.9509 | 5.175 | 3.2554 | 4.3739 | 6.2997 | 5.8102 | 6.2247 | 9.0404 | 9.8195 | 9.0944 | 8.7903 | 9.1181 | 9.4097 | 9.6109 |
Days of Sales Outstanding (DSO) | NaN | 39.2779 | 52.258 | 36.2483 | 28.8857 | 37.1715 | 36.4852 | 35.4592 | 42.0003 | 47.7828 | 44.9482 | 50.4763 | 51.7261 | 58.1785 | 66.4971 | 55.3447 | 44.3762 | 52.0377 | 58.0504 | |
Operating Cycle (CC) | NaN | 45.0654 | 59.3498 | 43.5623 | 36.4051 | 44.1224 | 41.6601 | 38.7146 | 46.3742 | 54.0824 | 50.7584 | 56.7011 | 60.7665 | 67.998 | 75.5915 | 64.135 | 53.4943 | 61.4474 | 67.6613 | |
Days of Accounts Payable Outstanding (DPO) | NaN | 68.7718 | 96.2465 | 89.7359 | 86.7454 | 81.306 | 75.4773 | 74.389 | 74.54 | 85.4527 | 85.572 | 101.1074 | 111.718 | 116.9484 | 115.2021 | 95.2889 | 83.1683 | 97.0504 | 108.0033 | |
Cash Conversion Cycle (CCC) | NaN | -23.7064 | -36.8967 | -46.1736 | -50.3404 | -37.1836 | -33.8172 | -35.6744 | -28.1658 | -31.3703 | -34.8136 | -44.4063 | -50.9515 | -48.9504 | -39.6106 | -31.1539 | -29.674 | -35.603 | -40.3419 | |
... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
WMT | EV-to-EBIT | 9.5833 | 9.0818 | 8.9111 | 9.4147 | 8.4392 | 8.1809 | 8.1931 | 9.1931 | 9.8347 | 10.941 | 8.0224 | 10.0524 | 14.318 | 17.9074 | 29.033 | 20.7407 | 19.8916 | 21.6887 | 25.0026 |
EV-to-EBITDA | 7.5981 | 7.2093 | 6.6802 | 7.2297 | 6.4941 | 6.1906 | 6.4623 | 6.8813 | 7.3773 | 8.1003 | 5.9216 | 7.1292 | 9.684 | 9.7107 | 11.8294 | 13.7822 | 13.2585 | 13.1213 | 16.2302 | |
EV-to-Operating-Cash-Flow | 10.8567 | 9.5046 | 8.5991 | 10.0567 | 8.2868 | 7.3363 | 9.0699 | 9.8412 | 10.465 | 12.4487 | 7.5295 | 8.7352 | 10.0875 | 10.6116 | 13.9103 | 18.3919 | 12.5076 | 18.318 | 16.7812 | |
Tangible Asset Value | 38593000000.0 | 40983000000.0 | 47814000000.0 | 48537000000.0 | 50025000000.0 | 57110000000.0 | 54892000000.0 | 55514000000.0 | 61760000000.0 | 63320000000.0 | 67835000000.0 | 66916000000.0 | 63498000000.0 | 62580000000.0 | 48453000000.0 | 50479000000.0 | 58548000000.0 | 62877000000.0 | 55817000000.0 | |
Net Current Asset Value | -4397000000.0 | -5002000000.0 | -5166000000.0 | -10869000000.0 | -6441000000.0 | -7230000000.0 | -6591000000.0 | -7325000000.0 | -11878000000.0 | -8160000000.0 | -1994000000.0 | -4380000000.0 | -9239000000.0 | -18857000000.0 | -15580000000.0 | -15984000000.0 | -2578000000.0 | -6309000000.0 | -16543000000.0 |
268 rows × 19 columns
Given that you might not be interested in all of them, it is possible to also call each and every single one seperately.
companies.ratios.get_effective_tax_rate()
date | 2005 | 2006 | 2007 | 2008 | 2009 | 2010 | 2011 | 2012 | 2013 | 2014 | 2015 | 2016 | 2017 | 2018 | 2019 | 2020 | 2021 | 2022 | 2023 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
AAPL | 0.2645 | 0.2942 | 0.3019 | 0.2989 | 0.2856 | 0.2442 | 0.2422 | 0.2516 | 0.2615 | 0.2613 | 0.2637 | 0.2556 | 0.2456 | 0.1834 | 0.1594 | 0.1443 | 0.133 | 0.162 | 0.1472 |
AMZN | 0.222 | 0.496 | 0.2788 | 0.2741 | 0.2179 | 0.2351 | 0.3116 | 1.1003 | 0.3701 | -2.2568 | 0.6145 | 0.3754 | 0.2023 | 0.1062 | 0.17 | 0.1183 | 0.1256 | -0.5417 | NaN |
META | NaN | NaN | NaN | NaN | NaN | 0.3988 | 0.41 | 0.8927 | 0.4553 | 0.4012 | 0.4046 | 0.1838 | 0.2263 | 0.1281 | 0.255 | 0.1216 | 0.1674 | 0.195 | NaN |
WMT | 0.347 | 0.3343 | 0.3356 | 0.342 | 0.3419 | 0.3235 | 0.322 | 0.3256 | 0.3101 | 0.3287 | 0.322 | 0.3031 | 0.3027 | 0.3042 | 0.3736 | 0.2443 | 0.3335 | 0.2544 | 0.3364 |
Some of these ratios also include optional fields depending on whether there is room for different methods of calculation. E.g. whether you'd like to have the diluted average shares included in the calculation.
companies.ratios.collect_solvency_ratios(diluted=False, growth=True)
date | 2005 | 2006 | 2007 | 2008 | 2009 | 2010 | 2011 | 2012 | 2013 | 2014 | 2015 | 2016 | 2017 | 2018 | 2019 | 2020 | 2021 | 2022 | 2023 | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
AAPL | Debt-to-Assets Ratio | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | inf | 0.8584 | 0.458 | 0.219 | 0.1394 | 0.0156 | 0.0198 | 0.0874 | 0.0236 | -0.0419 | -0.0743 |
Debt-to-Equity Ratio | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | inf | 1.3044 | 0.707 | 0.2564 | 0.2717 | 0.2381 | 0.1175 | 0.4412 | 0.1488 | 0.1987 | -0.2456 | |
Debt Service Coverage Ratio | NaN | -0.1995 | 0.2506 | -0.0607 | -0.108 | 1.2336 | 0.3617 | 0.1864 | -0.1933 | -0.2843 | 0.0678 | -0.1038 | -0.2316 | -0.003 | -0.0033 | 0.0402 | 0.3804 | -0.1066 | 0.0141 | |
Equity Multiplier | NaN | 2.4795 | 0.0533 | 0.0517 | 0.0474 | -0.1076 | -0.0976 | -0.0251 | 0.0556 | 0.178 | 0.2119 | 0.093 | 0.0748 | 0.1562 | 0.1598 | 0.193 | 0.2362 | 0.1772 | 0.0106 | |
Free Cash Flow Yield | NaN | -0.4425 | 0.2023 | 3.2654 | -0.5744 | 0.18 | 0.432 | 0.0285 | 0.0051 | -0.1531 | 0.5241 | -0.2996 | -0.3138 | 0.4062 | -0.4784 | -0.2735 | -0.0216 | 0.6782 | -0.3816 | |
Net-Debt to EBITDA Ratio | NaN | 0.2505 | -0.171 | -0.1107 | -0.6423 | -0.0785 | -0.5247 | -0.3341 | -1.2571 | 6.5191 | 0.4804 | 0.7333 | 0.4649 | -0.1884 | -0.285 | 0.243 | -0.224 | -0.0108 | -0.127 | |
Cash Flow Coverage Ratio | NaN | -0.4425 | 0.2023 | 3.2654 | -0.5744 | 0.18 | 0.432 | 0.0285 | 0.0051 | -0.1531 | 0.5241 | -0.2996 | -0.3138 | 0.4062 | -0.4784 | -0.2735 | -0.0216 | 0.6782 | -0.3816 | |
CAPEX Coverage Ratio | NaN | -0.6534 | 0.6418 | 0.4426 | 0.0465 | 0.0468 | -0.4256 | 0.0741 | 0.0932 | 0.0291 | 0.1625 | -0.3132 | 0.023 | 0.1702 | 0.1368 | 0.6694 | -0.1497 | 0.2154 | -0.1158 | |
Dividend CAPEX Coverage Ratio | NaN | -0.6534 | 0.6418 | 0.4426 | 0.0465 | 0.0468 | -0.4256 | -0.1507 | -0.3611 | 0.0437 | 0.2363 | -0.2735 | -0.0287 | 0.1517 | -0.0161 | 0.3378 | 0.0795 | 0.1742 | -0.1102 | |
AMZN | Debt-to-Assets Ratio | NaN | -0.2943 | -0.2865 | -0.7283 | -0.8597 | 3.3165 | 0.6422 | 1.1 | 0.0969 | 0.776 | -0.0541 | -0.1583 | 0.5833 | -0.153 | 0.1472 | -0.0638 | 0.0537 | 0.0939 | -15.0499 |
Debt-to-Equity Ratio | NaN | -0.5245 | -0.6181 | -0.8441 | -0.8818 | 3.5121 | 0.9529 | 1.563 | 0.1371 | 1.1872 | -0.0886 | -0.2555 | 0.7349 | -0.3325 | 0.1147 | -0.1128 | -0.0682 | 0.1396 | -5.4343 | |
Debt Service Coverage Ratio | NaN | -0.3143 | 0.1484 | 0.0057 | -0.1359 | -0.1155 | -0.573 | -0.3851 | -0.0899 | -0.8056 | 9.4603 | 0.4492 | -0.2576 | 1.5614 | -0.0881 | 0.0942 | -0.0348 | -0.5495 | -54.9886 | |
Equity Multiplier | NaN | 52.1429 | -0.4402 | -0.426 | -0.2704 | -0.0359 | 0.1205 | 0.2029 | 0.1179 | 0.1399 | 0.076 | -0.0836 | 0.0028 | -0.0971 | -0.1097 | -0.043 | -0.089 | -0.0297 | -2.3694 | |
Free Cash Flow Yield | NaN | 0.0919 | 0.0404 | 1.0388 | -0.2048 | -0.3752 | -0.147 | -0.8652 | 2.0556 | 0.2364 | 0.6765 | 0.1754 | -0.5821 | 1.0536 | 0.013 | -0.3305 | -1.5513 | 1.314 | 212.7839 | |
Net-Debt to EBITDA Ratio | NaN | -0.5509 | -4.2153 | 0.5367 | 0.0858 | -0.2821 | 0.2472 | -0.144 | -0.4221 | -0.5167 | -0.5426 | 0.5459 | -4.3337 | -0.7408 | 1.5779 | 0.1779 | 0.5377 | 0.1776 | -3.6725 | |
Cash Flow Coverage Ratio | NaN | 0.0919 | 0.0404 | 1.0388 | -0.2048 | -0.3752 | -0.147 | -0.8652 | 2.0556 | 0.2364 | 0.6765 | 0.1754 | -0.5821 | 1.0536 | 0.013 | -0.3305 | -1.5513 | 1.314 | 212.7839 | |
CAPEX Coverage Ratio | NaN | -0.0955 | 0.9299 | -0.1875 | 0.7324 | -0.5956 | -0.3963 | -0.4876 | 0.4394 | -0.1204 | 0.8576 | -0.0604 | -0.3683 | 0.484 | -0.0017 | -0.2795 | -0.5389 | -0.0319 | 4.7913 | |
Dividend CAPEX Coverage Ratio | NaN | -0.0955 | 0.9299 | -0.1875 | 0.7324 | -0.5956 | -0.3963 | -0.4876 | 0.4394 | -0.1204 | 0.8576 | -0.0604 | -0.3683 | 0.484 | -0.0017 | -0.2795 | -0.5389 | -0.0319 | 4.7913 | |
META | Debt-to-Assets Ratio | NaN | -0.0955 | 0.9299 | -0.1875 | 0.7324 | -1.0179 | -0.3243 | 0.4593 | -0.8295 | -0.782 | -0.6034 | -1.0 | NaN | inf | 14.1765 | -0.1357 | 0.2496 | 0.7129 | -30.7088 |
Debt-to-Equity Ratio | NaN | -0.0955 | 0.9299 | -0.1875 | 0.7324 | -1.0248 | -0.3684 | 0.4501 | -0.8463 | -0.789 | -0.6 | -1.0 | NaN | inf | 16.322 | -0.1879 | 0.3386 | 0.9037 | -21.1149 | |
Debt Service Coverage Ratio | NaN | -0.0955 | 0.9299 | -0.1875 | 0.7324 | -1.3005 | -0.2637 | -0.7382 | 3.9846 | 0.3758 | -0.0779 | 0.3366 | 0.2431 | -0.3392 | -0.5512 | 0.3686 | 0.0144 | -0.5158 | -4.9723 | |
Equity Multiplier | NaN | -0.0955 | 0.9299 | -0.1875 | 0.7324 | -1.3005 | -0.5024 | -0.0251 | -0.0583 | -0.0707 | -0.0096 | -0.0086 | 0.0122 | 0.0252 | 0.0857 | 0.0243 | 0.0068 | 0.0923 | -4.0312 | |
Free Cash Flow Yield | NaN | -0.0955 | 0.9299 | -0.1875 | 0.7324 | -inf | NaN | -1.0 | 3.75 | -0.1627 | 0.1714 | 0.6878 | -0.0318 | 0.197 | -0.1047 | -0.1671 | 0.3612 | 0.4398 | -73.599 | |
Net-Debt to EBITDA Ratio | NaN | -0.0955 | 0.9299 | -0.1875 | 0.7324 | -0.8731 | -0.6416 | -0.9412 | 30.6229 | -0.123 | -0.1036 | 0.0274 | -0.423 | -0.0635 | -0.0958 | -0.4054 | -0.715 | -7.3427 | -14.4417 | |
Cash Flow Coverage Ratio | NaN | -0.0955 | 0.9299 | -0.1875 | 0.7324 | -inf | NaN | -1.0 | 3.75 | -0.1627 | 0.1714 | 0.6878 | -0.0318 | 0.197 | -0.1047 | -0.1671 | 0.3612 | 0.4398 | -73.599 | |
CAPEX Coverage Ratio | NaN | -0.0955 | 0.9299 | -0.1875 | 0.7324 | -0.7302 | 0.073 | -0.4893 | 1.3749 | -0.0386 | 0.1436 | 0.0524 | 0.0028 | -0.4151 | 0.143 | 0.0661 | 0.2119 | -0.4831 | 1.6492 | |
Dividend CAPEX Coverage Ratio | NaN | -0.0955 | 0.9299 | -0.1875 | 0.7324 | -0.7302 | 0.073 | -0.4893 | 1.3749 | -0.0386 | 0.1436 | 0.0524 | 0.0028 | -0.4151 | 0.143 | 0.0661 | 0.2119 | -0.4831 | 1.6492 | |
WMT | Debt-to-Assets Ratio | NaN | 0.0738 | -0.0812 | 0.0585 | -0.0545 | -0.0627 | 0.14 | 0.0007 | -0.0351 | 0.0379 | -0.1059 | 0.0137 | -0.0786 | -0.016 | 0.1641 | 0.1576 | -0.1822 | -0.0655 | 0.0337 |
Debt-to-Equity Ratio | NaN | 0.1467 | -0.132 | 0.0911 | -0.0647 | -0.097 | 0.2457 | 0.0298 | -0.0535 | 0.0475 | -0.1667 | 0.0036 | -0.0494 | 0.011 | 0.2206 | 0.2189 | -0.1864 | -0.1367 | 0.1246 | |
Debt Service Coverage Ratio | NaN | -0.0477 | 0.0435 | -0.0497 | 0.0938 | 0.0474 | 0.013 | -0.0238 | -0.092 | 0.001 | 0.0733 | -0.1031 | -0.0882 | -0.2346 | 0.0887 | -0.067 | -0.0794 | 0.2198 | -0.256 | |
Equity Multiplier | NaN | 5.3222 | 0.001 | -0.0111 | 0.0092 | -0.0241 | 0.027 | 0.0603 | 0.004 | -0.0047 | -0.0306 | -0.0388 | 0.0104 | 0.0298 | 0.0385 | 0.0508 | 0.0227 | -0.0415 | 0.0016 | |
Free Cash Flow Yield | NaN | 0.4557 | 0.4043 | 0.0248 | 1.281 | 0.1921 | -0.2767 | -0.1137 | 0.026 | -0.2635 | 1.2294 | -0.1574 | -0.072 | -0.0632 | -0.2514 | -0.3039 | 0.752 | -0.5631 | 0.0035 | |
Net-Debt to EBITDA Ratio | NaN | 0.1541 | -0.1253 | 0.1328 | -0.1434 | -0.0921 | 0.1915 | 0.0559 | -0.0551 | 0.0815 | -0.1777 | 0.0844 | -0.034 | 0.0786 | 0.2015 | 0.212 | -0.2843 | -0.0571 | 0.319 | |
Cash Flow Coverage Ratio | NaN | 0.4557 | 0.4043 | 0.0248 | 1.281 | 0.1921 | -0.2767 | -0.1137 | 0.026 | -0.2635 | 1.2294 | -0.1574 | -0.072 | -0.0632 | -0.2514 | -0.3039 | 0.752 | -0.5631 | 0.0035 | |
CAPEX Coverage Ratio | NaN | 0.0377 | 0.063 | 0.0587 | 0.4772 | 0.0702 | -0.1358 | -0.0357 | 0.1052 | -0.1062 | 0.3231 | 0.0171 | 0.2442 | -0.0505 | -0.0483 | -0.1207 | 0.4897 | -0.475 | -0.0643 | |
Dividend CAPEX Coverage Ratio | NaN | 0.0371 | 0.0572 | 0.0065 | 0.3817 | 0.0541 | -0.138 | -0.0527 | 0.0724 | -0.1382 | 0.2881 | -0.0094 | 0.2152 | -0.0646 | -0.0368 | -0.1067 | 0.4609 | -0.4299 | 0.009 |
For all ratios, it is also possible to show the growth instead. E.g. if you are interested in the growth of the Price-to-Book ratio you can use the following:
companies.ratios.get_price_to_book_ratio(growth=True)
Date | 2005 | 2006 | 2007 | 2008 | 2009 | 2010 | 2011 | 2012 | 2013 | 2014 | 2015 | 2016 | 2017 | 2018 | 2019 | 2020 | 2021 | 2022 | 2023 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
AAPL | NaN | -0.097 | 0.6254 | -0.6986 | 0.8785 | -0.0908 | -0.2071 | -0.133 | 0.0195 | 0.4618 | -0.1422 | -0.0061 | 0.3562 | 0.1268 | 1.0803 | 1.38 | 0.3416 | -0.1129 | 0.1767 |
AMZN | NaN | -0.5251 | -0.1544 | -0.7476 | 0.3673 | 0.0567 | -0.1402 | 0.3489 | 0.3719 | -0.2983 | 0.804 | -0.2187 | 0.1057 | -0.1712 | -0.1298 | 0.1848 | -0.3017 | -0.528 | 7.359 |
META | NaN | -0.5251 | -0.1544 | -0.7476 | 0.3673 | -1.0 | NaN | inf | 0.8128 | -0.3524 | 0.1727 | -0.1581 | 0.2341 | -0.3512 | 0.2834 | 0.0527 | 0.2523 | -0.6641 | 17.9395 |
WMT | NaN | -0.0868 | -0.0986 | 0.1173 | -0.0646 | -0.0654 | 0.1125 | 0.0642 | 0.0769 | 0.085 | -0.321 | 0.1632 | 0.4678 | -0.0669 | 0.368 | 0.166 | -0.0703 | -0.0423 | 0.1943 |
By default, the lag is set to 1 (one period) but it is possible to change this and add multiple lags as well.
companies.ratios.get_current_ratio(growth=True, lag=[1, 2, 3])
date | 2005 | 2006 | 2007 | 2008 | 2009 | 2010 | 2011 | 2012 | 2013 | 2014 | 2015 | 2016 | 2017 | 2018 | 2019 | 2020 | 2021 | 2022 | 2023 | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
AAPL | Lag 1 | NaN | -0.2416 | 0.0531 | 0.0426 | -0.236 | 0.0694 | -0.2003 | -0.07 | 0.1222 | -0.3566 | 0.0265 | 0.22 | -0.0566 | -0.1193 | 0.3704 | -0.1146 | -0.212 | -0.1817 | 0.1236 |
Lag 2 | NaN | NaN | -0.2013 | 0.0979 | -0.2034 | -0.183 | -0.1448 | -0.2563 | 0.0436 | -0.2779 | -0.3395 | 0.2523 | 0.1509 | -0.1692 | 0.2069 | 0.2133 | -0.3023 | -0.3551 | -0.0805 | |
Lag 3 | NaN | NaN | NaN | -0.1673 | -0.1612 | -0.1482 | -0.3466 | -0.2047 | -0.1654 | -0.3285 | -0.2588 | -0.1942 | 0.1814 | 0.0136 | 0.1386 | 0.0686 | -0.0439 | -0.429 | -0.2754 | |
AMZN | Lag 1 | NaN | -0.1227 | 0.0437 | -0.067 | 0.0255 | -0.0038 | -0.1141 | -0.0455 | -0.0438 | 0.0408 | -0.0353 | -0.0289 | -0.0047 | 0.0559 | -0.001 | -0.0427 | 0.0814 | -0.1683 | 0.0 |
Lag 2 | NaN | NaN | -0.0843 | -0.0262 | -0.0432 | 0.0217 | -0.1174 | -0.1544 | -0.0873 | -0.0049 | 0.0041 | -0.0632 | -0.0334 | 0.051 | 0.0549 | -0.0436 | 0.0353 | -0.1005 | -0.1683 | |
Lag 3 | NaN | NaN | NaN | -0.1456 | -0.0013 | -0.0468 | -0.0949 | -0.1576 | -0.1915 | -0.0501 | -0.0399 | -0.025 | -0.0675 | 0.0206 | 0.05 | 0.0099 | 0.0343 | -0.1389 | -0.1005 | |
META | Lag 1 | NaN | NaN | NaN | NaN | NaN | NaN | -0.113 | 1.0913 | 0.1094 | -0.1921 | 0.1717 | 0.0638 | 0.0794 | -0.443 | -0.3885 | 0.1481 | -0.3755 | -0.3015 | 0.0 |
Lag 2 | NaN | NaN | NaN | NaN | NaN | NaN | NaN | 0.855 | 1.3201 | -0.1037 | -0.0534 | 0.2464 | 0.1483 | -0.3988 | -0.6594 | -0.2979 | -0.283 | -0.5638 | -0.3015 | |
Lag 3 | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | 1.0579 | 0.8745 | 0.0502 | 0.007 | 0.3454 | -0.3604 | -0.6323 | -0.6089 | -0.5615 | -0.4992 | -0.5638 | |
WMT | Lag 1 | NaN | 0.0001 | 0.0029 | -0.0957 | 0.0856 | -0.0157 | 0.02 | -0.0055 | -0.0542 | 0.0572 | 0.0987 | -0.0384 | -0.0754 | -0.1185 | 0.0514 | -0.0055 | 0.2236 | -0.0456 | -0.115 |
Lag 2 | NaN | NaN | 0.003 | -0.093 | -0.0183 | 0.0686 | 0.0041 | 0.0144 | -0.0594 | -0.0001 | 0.1616 | 0.0565 | -0.1109 | -0.1849 | -0.0731 | 0.0456 | 0.2169 | 0.1677 | -0.1554 | |
Lag 3 | NaN | NaN | NaN | -0.0929 | -0.0154 | -0.0337 | 0.09 | -0.0015 | -0.0405 | -0.0056 | 0.0986 | 0.117 | -0.0231 | -0.2162 | -0.143 | -0.0782 | 0.2794 | 0.1613 | 0.0334 |
It is also possible to get trailing results. E.g. the TTM Earnings per Share ratio can be acquired by setting trailing to 4 (quarters). Note that this does not lead to meaningful results when using yearly data and therefore this image now shows the 4 year trailing result. Set quarterly=True
in the Toolkit initialization to use quarterly data.
companies.ratios.get_earnings_per_share(trailing=4).T.dropna().plot(
figsize=(15, 3),
title="4 Year Trailing Earnings per Share for Apple, Amazon, META and Walmart",
grid=True,
linestyle="-",
linewidth=2,
xlabel="Date",
ylabel="Earnings per Share",
)
companies.ratios.get_earnings_per_share(trailing=4, growth=True).T.dropna().plot(
figsize=(15, 3),
title="4 Year Trailing Earnings per Share Growth for Apple, Amazon, META and Walmart",
grid=True,
linestyle="-",
linewidth=2,
xlabel="Date",
ylabel="Earnings per Share Growth",
)
<Axes: title={'center': '4 Year Trailing Earnings per Share Growth for Apple, Amazon, META and Walmart'}, xlabel='Date', ylabel='Earnings per Share Growth'>
It is possible to define custom ratios if the current ratio calculations are not sufficient. Define how each custom ratio needs to be calculated. This can be any of the following structures:
'Quick Assets': 'Cash and Short Term Investments + Accounts Receivable'
'Cash Op Expenses':'Cost of Goods Sold + Selling, General and Administrative Expenses - Depreciation and Amortization'
,'WC / Net Income as %': '(Working Capital / Net Income) * 100'
,'Large Revenues': 'Revenue > 1000000000'
,'Daily Cash Op Expenses': 'Cash Op Expenses / 365'
,'Defensive Interval':'Quick Assets / Daily Cash Op Expenses'
Not that it is important you follow the NAME - FORMULA format and that you adhere to the financial statement naming. See some of the available fields you can use below, shrunken down for readability.
companies.ratios.collect_custom_ratios(options=True)[10:15]
The following names are available to be used in the Custom Ratios calculations.
['CAPEX per Share', 'Capital Expenditure', 'Capital Lease Obligations', 'Cash Beginning of Period', 'Cash Conversion Cycle (CCC)']
Then create your custom ratios and add them to custom ratios function.
custom_ratios = {
"WC / Net Income as %": "(Working Capital / Net Income) * 100",
"Large Revenues": "Revenue > 1000000000",
"Quick Assets": "Cash and Short Term Investments + Accounts Receivable",
"Cash Op Expenses": "Cost of Goods Sold + Selling, General and Administrative Expenses "
"- Depreciation and Amortization",
"Daily Cash Op Expenses": "Cash Op Expenses / 365",
"Defensive Interval": "Quick Assets / Daily Cash Op Expenses",
}
companies.ratios.collect_custom_ratios(custom_ratios_dict=custom_ratios)
2005 | 2006 | 2007 | 2008 | 2009 | 2010 | 2011 | 2012 | 2013 | 2014 | 2015 | 2016 | 2017 | 2018 | 2019 | 2020 | 2021 | 2022 | 2023 | ||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
AAPL | WC / Net Income as % | 510.5618 | 404.1227 | 362.0423 | 426.1067 | 297.7384 | 149.5468 | 65.6508 | 45.7935 | 79.9957 | 12.8651 | 16.4213 | 60.9867 | 57.5603 | 24.3117 | 103.339 | 66.7485 | 9.8807 | -18.6137 | -1.796 |
Large Revenues | 1.0 | 1.0 | 1.0 | 1.0 | 1.0 | 1.0 | 1.0 | 1.0 | 1.0 | 1.0 | 1.0 | 1.0 | 1.0 | 1.0 | 1.0 | 1.0 | 1.0 | 1.0 | 1.0 | |
Quick Assets | 9573000000.0 | 12955000000.0 | 19415000000.0 | 26912000000.0 | 26825000000.0 | 35544000000.0 | 37669000000.0 | 47821000000.0 | 61187000000.0 | 52296000000.0 | 71944000000.0 | 96454000000.0 | 109854000000.0 | 115296000000.0 | 146361000000.0 | 128388000000.0 | 114145000000.0 | 109236000000.0 | 122540000000.0 | |
Cash Op Expenses | 11568000000.0 | 15925000000.0 | 18498000000.0 | 24622000000.0 | 26843000000.0 | 44031000000.0 | 70216000000.0 | 94609000000.0 | 110679000000.0 | 116305000000.0 | 143161000000.0 | 135065000000.0 | 146152000000.0 | 169558000000.0 | 167480000000.0 | 178419000000.0 | 223670000000.0 | 237536000000.0 | 227550000000.0 | |
Daily Cash Op Expenses | 31693150.6849 | 43630136.9863 | 50679452.0548 | 67457534.2466 | 73542465.7534 | 120632876.7123 | 192372602.7397 | 259202739.726 | 303230136.9863 | 318643835.6164 | 392221917.8082 | 370041095.8904 | 400416438.3562 | 464542465.7534 | 458849315.0685 | 488819178.0822 | 612794520.5479 | 650783561.6438 | 623424657.5342 | |
Defensive Interval | 302.0526 | 296.9278 | 383.0941 | 398.9473 | 364.7552 | 294.646 | 195.8127 | 184.4926 | 201.784 | 164.1205 | 183.4268 | 260.6575 | 274.3494 | 248.1926 | 318.974 | 262.6493 | 186.2696 | 167.853 | 196.5594 | |
AMZN | WC / Net Income as % | 300.3003 | 442.6316 | 304.6218 | 218.7597 | 269.7339 | 292.9688 | 411.0935 | -5882.0513 | 600.365 | -1343.5685 | 432.047 | 82.8764 | 76.2941 | 66.6137 | 73.5416 | 29.7595 | 57.8887 | 316.0176 | NaN |
Large Revenues | 1.0 | 1.0 | 1.0 | 1.0 | 1.0 | 1.0 | 1.0 | 1.0 | 1.0 | 1.0 | 1.0 | 1.0 | 1.0 | 1.0 | 1.0 | 1.0 | 1.0 | 1.0 | 0.0 | |
Quick Assets | 2274000000.0 | 2418000000.0 | 3817000000.0 | 4554000000.0 | 7354000000.0 | 10349000000.0 | 12147000000.0 | 14812000000.0 | 17214000000.0 | 23028000000.0 | 26231000000.0 | 34320000000.0 | 44150000000.0 | 57927000000.0 | 75837000000.0 | 108938000000.0 | 128940000000.0 | 112386000000.0 | NaN | |
Cash Op Expenses | 7890000000.0 | 10107000000.0 | 13925000000.0 | 18061000000.0 | 22900000000.0 | 32124000000.0 | 45978000000.0 | 53862000000.0 | 64226000000.0 | 75215000000.0 | 86416000000.0 | 107433000000.0 | 139448000000.0 | 175992000000.0 | 208060000000.0 | 295320000000.0 | 354396000000.0 | 385338000000.0 | NaN | |
Daily Cash Op Expenses | 21616438.3562 | 27690410.9589 | 38150684.9315 | 49482191.7808 | 62739726.0274 | 88010958.9041 | 125967123.2877 | 147567123.2877 | 175961643.8356 | 206068493.1507 | 236756164.3836 | 294336986.3014 | 382049315.0685 | 482169863.0137 | 570027397.2603 | 809095890.411 | 970947945.2055 | 1055720547.9452 | NaN | |
Defensive Interval | 105.1977 | 87.3226 | 100.0506 | 92.0331 | 117.2144 | 117.5876 | 96.4299 | 100.3747 | 97.8281 | 111.7493 | 110.7933 | 116.601 | 115.561 | 120.1382 | 133.041 | 134.6416 | 132.7981 | 106.4543 | NaN | |
META | WC / Net Income as % | NaN | NaN | NaN | NaN | NaN | 306.4356 | 370.5 | 19273.5849 | 798.0 | 416.5306 | 534.897 | 308.5642 | 281.1786 | 196.5584 | 276.8299 | 208.2241 | 115.649 | 140.1853 | NaN |
Large Revenues | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 1.0 | 1.0 | 1.0 | 1.0 | 1.0 | 1.0 | 1.0 | 1.0 | 1.0 | 1.0 | 1.0 | 1.0 | 1.0 | 0.0 | |
Quick Assets | NaN | NaN | NaN | NaN | NaN | 2158000000.0 | 4455000000.0 | 10796000000.0 | 12609000000.0 | 12877000000.0 | 20993000000.0 | 33442000000.0 | 47543000000.0 | 48701000000.0 | 64373000000.0 | 73289000000.0 | 62037000000.0 | 54204000000.0 | NaN | |
Cash Op Expenses | NaN | NaN | NaN | NaN | NaN | 659000000.0 | 1244000000.0 | 2503000000.0 | 2642000000.0 | 3563000000.0 | 4942000000.0 | 6950000000.0 | 9671000000.0 | 16337000000.0 | 27370000000.0 | 27985000000.0 | 38554000000.0 | 43641000000.0 | NaN | |
Daily Cash Op Expenses | NaN | NaN | NaN | NaN | NaN | 1805479.4521 | 3408219.1781 | 6857534.2466 | 7238356.1644 | 9761643.8356 | 13539726.0274 | 19041095.8904 | 26495890.411 | 44758904.1096 | 74986301.3699 | 76671232.8767 | 105627397.2603 | 119564383.5616 | NaN | |
Defensive Interval | NaN | NaN | NaN | NaN | NaN | 1195.2504 | 1307.1342 | 1574.3268 | 1741.9701 | 1319.1426 | 1550.4745 | 1756.3065 | 1794.3537 | 1088.074 | 858.4635 | 955.8865 | 587.3192 | 453.3457 | NaN | |
WMT | WC / Net Income as % | -42.8265 | -44.5374 | -45.7816 | -85.3743 | -48.0672 | -50.436 | -40.216 | -46.659 | -69.8747 | -50.93 | -12.186 | -29.8081 | -67.7197 | -191.2087 | -233.5832 | -107.4121 | -19.0822 | -46.142 | -141.6353 |
Large Revenues | 1.0 | 1.0 | 1.0 | 1.0 | 1.0 | 1.0 | 1.0 | 1.0 | 1.0 | 1.0 | 1.0 | 1.0 | 1.0 | 1.0 | 1.0 | 1.0 | 1.0 | 1.0 | 1.0 | |
Quick Assets | 7203000000.0 | 9076000000.0 | 10213000000.0 | 9223000000.0 | 11180000000.0 | 12051000000.0 | 12484000000.0 | 12487000000.0 | 14549000000.0 | 13958000000.0 | 15913000000.0 | 14329000000.0 | 12702000000.0 | 12370000000.0 | 14005000000.0 | 15749000000.0 | 24257000000.0 | 23040000000.0 | 16818000000.0 | |
Cash Op Expenses | 266493000000.0 | 292407000000.0 | 322694000000.0 | 350486000000.0 | 376070000000.0 | 377107000000.0 | 388666000000.0 | 412262000000.0 | 432860000000.0 | 440552000000.0 | 449331000000.0 | 448571000000.0 | 453029000000.0 | 469377000000.0 | 481770000000.0 | 490262000000.0 | 525120000000.0 | 538996000000.0 | 581200000000.0 | |
Daily Cash Op Expenses | 730117808.2192 | 801115068.4932 | 884093150.6849 | 960235616.4384 | 1030328767.1233 | 1033169863.0137 | 1064838356.1644 | 1129484931.5068 | 1185917808.2192 | 1206991780.8219 | 1231043835.6164 | 1228961643.8356 | 1241175342.4658 | 1285964383.5616 | 1319917808.2192 | 1343183561.6438 | 1438684931.5068 | 1476701369.863 | 1592328767.1233 | |
Defensive Interval | 9.8655 | 11.3292 | 11.552 | 9.6049 | 10.8509 | 11.6641 | 11.7238 | 11.0555 | 12.2681 | 11.5643 | 12.9264 | 11.6594 | 10.2338 | 9.6192 | 10.6105 | 11.7251 | 16.8605 | 15.6023 | 10.5619 |
It is also relatively straight forward to use the actual models provided you have the data available to flow through these functions. While the Toolkit
class itself parses data from Financial Modeling Prep, if you utilize the individual models you can provide your own data as well while reaching the same results.
from financetoolkit.ratios import (
efficiency_model,
liquidity_model,
profitability_model,
solvency_model,
valuation_model,
)
# Note: this is dummy data, not actual data
asset_turnover = efficiency_model.get_asset_turnover_ratio(
sales=pd.Series([100, 110, 120, 130, 80]),
total_assets_begin=pd.Series([500, 400, 300, 200, 100]),
total_assets_end=pd.Series([500, 430, 320, 200, 100]),
)
quick_ratio = liquidity_model.get_quick_ratio(
cash_and_equivalents=pd.Series([100, 110, 120, 130, 80]),
accounts_receivable=pd.Series([30, 20, 30, 20, 40]),
marketable_securities=pd.Series([30, 10, 30, 20, 40]),
current_liabilities=pd.Series([130, 120, 110, 150, 100]),
)
return_on_assets = profitability_model.get_return_on_assets(
net_income=pd.Series([80, 40, 40, 30, 20]),
total_assets_begin=pd.Series([150, 200, 300, 400, 500]),
total_assets_end=pd.Series([200, 300, 400, 500, 450]),
)
debt_to_assets = solvency_model.get_debt_to_assets_ratio(
total_debt=pd.Series([100, 110, 120, 130, 80]),
total_assets=pd.Series([200, 140, 160, 160, 300]),
)
price_to_earnings = valuation_model.get_price_earnings_ratio(
stock_price=pd.Series([30, 11, 12, 10, 30]),
earnings_per_share=pd.Series([0.5, 0.4, 0.1, 1.1, 1.2]),
)
components = {
"Asset Turnover": asset_turnover,
"Quick Ratio": quick_ratio,
"Return on Assets": return_on_assets,
"Debt to Assets": debt_to_assets,
"Price to Earnings": price_to_earnings,
}
pd.DataFrame(components)
Asset Turnover | Quick Ratio | Return on Assets | Debt to Assets | Price to Earnings | |
---|---|---|---|---|---|
0 | 0.2 | 1.2307692307692308 | 0.45714285714285713 | 0.5 | 60.0 |
1 | 0.26506024096385544 | 1.1666666666666667 | 0.16 | 0.7857142857142857 | 27.5 |
2 | 0.3870967741935484 | 1.6363636363636365 | 0.11428571428571428 | 0.75 | 120.0 |
3 | 0.65 | 1.1333333333333333 | 0.06666666666666667 | 0.8125 | 9.09090909090909 |
4 | 0.8 | 1.6 | 0.042105263157894736 | 0.26666666666666666 | 25.0 |