The Finance Toolkit can take in any dataset which means it works very well with the software and APIs from any other provider let is be Intrinio, OpenBB, Yahoo Finance, Quandl, etc. For this illustration, I have collected custom statements and have imported them as a CSV file but as you can imagine this would also work with direct API calls. This dataset is obtained from Yahoo Finance, which can be collected via yfinance
. Note that the yfinance
library is not part of the Finance Toolkit and needs to be installed separately.
import pandas as pd
from financetoolkit import Toolkit
First, let's read in the custom dataset obtained from Yahoo Finance.
# Balance Sheet Statements
tsla_balance = pd.read_csv("external_datasets/TSLA_balance.csv", index_col=0)
googl_balance = pd.read_csv("external_datasets/GOOGL_balance.csv", index_col=0)
# Income Statements
tsla_income = pd.read_csv("external_datasets/TSLA_income.csv", index_col=0)
googl_income = pd.read_csv("external_datasets/GOOGL_income.csv", index_col=0)
# Cash Flow Statements
tsla_cash = pd.read_csv("external_datasets/TSLA_cash.csv", index_col=0)
googl_cash = pd.read_csv("external_datasets/GOOGL_cash.csv", index_col=0)
# Show one of the datasets
tsla_income
ttm | 2022-12-31 | 2021-12-31 | 2020-12-31 | 2019-12-31 | |
---|---|---|---|---|---|
Breakdown | |||||
Total revenue | 9.402800e+10 | 8.146200e+10 | 5.382300e+10 | 3.153600e+10 | 2.457800e+10 |
Cost of revenue | 7.382500e+10 | 6.060900e+10 | 4.021700e+10 | 2.490600e+10 | 2.050900e+10 |
Gross profit | 2.020300e+10 | 2.085300e+10 | 1.360600e+10 | 6.630000e+09 | 4.069000e+09 |
Research development | 3.257000e+09 | 3.075000e+09 | 2.593000e+09 | 1.491000e+09 | 1.343000e+09 |
Selling general and administrative | 4.260000e+09 | 3.946000e+09 | 4.517000e+09 | 3.145000e+09 | 2.646000e+09 |
Total operating expenses | 7.517000e+09 | 7.021000e+09 | 7.110000e+09 | 4.636000e+09 | 3.989000e+09 |
Operating income or loss | 1.268600e+10 | 1.383200e+10 | 6.496000e+09 | 1.994000e+09 | 8.000000e+07 |
Interest expense | 1.430000e+08 | 1.910000e+08 | 3.710000e+08 | 7.480000e+08 | 6.850000e+08 |
Total other income/expenses net | 1.190000e+08 | -2.190000e+08 | 1.620000e+08 | -1.220000e+08 | -1.040000e+08 |
Income before tax | 1.335600e+10 | 1.371900e+10 | 6.343000e+09 | 1.154000e+09 | -6.650000e+08 |
Income tax expense | 1.165000e+09 | 1.132000e+09 | 6.990000e+08 | 2.920000e+08 | 1.100000e+08 |
Income from continuing operations | 1.219100e+10 | 1.258700e+10 | 5.644000e+09 | 8.620000e+08 | -7.750000e+08 |
Net income | 1.222200e+10 | 1.258300e+10 | 5.519000e+09 | 6.900000e+08 | -8.620000e+08 |
Net income available to common shareholders | 1.223500e+10 | 1.258300e+10 | 5.519000e+09 | 6.900000e+08 | -8.620000e+08 |
Basic average shares | 3.160500e+09 | 3.130000e+09 | 2.958000e+09 | 2.799000e+09 | 2.661000e+09 |
Diluted average shares | 3.477000e+09 | 3.475000e+09 | 3.387000e+09 | 3.249000e+09 | 2.661000e+09 |
EBITDA | NaN | 1.765700e+10 | 9.625000e+09 | 4.224000e+09 | 2.174000e+09 |
Basic EPS | 3.880000e+00 | 4.020000e+00 | 1.870000e+00 | 2.500000e-01 | -3.300000e-01 |
Diluted EPS | 3.510000e+00 | 3.620000e+00 | 1.630000e+00 | 2.100000e-01 | -3.300000e-01 |
Then, it's time to acquire the normalization files via the Toolkit to be used to normalize the results.
Toolkit("TSLA").get_normalization_files()
Files are being saved to /Users/jeroenbouma/Downloads. Please see the following: https://www.jeroenbouma.com/projects/financetoolkit/external-datasets to understand how to work with these files. In essence, all it requires is to match up the rows in your dataframe with the normalization format.
With this information, by copying over each name as defined by Yahoo Finance for the balance, income and cash flow statements as also defined above, the normalisation files can be filled. The result can be found within the examples/external_datasets
folder of the project as found here.
The way you should be filling these sheets is by looking at the index names of the DataFrame depicted above and placing the name at the correct position of the first column of the CSV (Column A). As an example the name Total revenue
can be matched in the income.csv
with Revenue
. Do not change the names in Column B since the FinanceToolkit is dependent on those. So for the income.csv
this will look like:
Income | Generic |
---|---|
Total revenue | Revenue |
Cost of revenue | Cost of Goods Sold |
Gross profit | Gross Profit |
Gross Profit Ratio | |
Research development | Research and Development Expenses |
General and Administrative Expenses | |
Selling and Marketing Expenses | |
Selling general and administrative | Selling, General and Administrative Expenses |
Other Expenses | |
Total operating expenses | Operating Expenses |
Cost and Expenses | |
Interest Income | |
Interest expense | Interest Expense |
Depreciation and Amortization | |
EBITDA | EBITDA |
EBITDA Ratio | |
Operating income or loss | Operating Income |
Operating Income Ratio | |
Total other income/expenses net | Total Other Income |
Income before tax | Income Before Tax |
Income Before Tax Ratio | |
Income tax expense | Income Tax Expense |
Net income | Net Income |
Net Income Ratio | |
Basic EPS | EPS |
Diluted EPS | EPS Diluted |
Basic average shares | Weighted Average Shares |
Diluted average shares | Weighted Average Shares Diluted |
As you can see some are not filled. This is because the Yahoo Finance source doesn't have data on each. This is fine, to some extend, as any calculations that are not possible because of this will simply be excluded.
Now it's time to convert each dataset in the right format.
from financetoolkit import helpers
balance_sheets = helpers.combine_dataframes(
{
"TSLA": tsla_balance,
"GOOGL": googl_balance,
},
)
income_statements = helpers.combine_dataframes(
{
"TSLA": tsla_income,
"GOOGL": googl_income,
},
)
cash_flow_statements = helpers.combine_dataframes(
{"TSLA": tsla_cash, "GOOGL": googl_cash},
)
# The TTM column is dropped as it contains only a portion of this year
income_statements = income_statements.drop(columns=["ttm"])
cash_flow_statements = cash_flow_statements.drop(columns=["ttm"])
# Show the Results
balance_sheets
2022-12-31 | 2021-12-31 | 2020-12-31 | 2019-12-31 | ||
---|---|---|---|---|---|
Breakdown | |||||
GOOGL | Cash and cash equivalents | 21879000000.0 | 20945000000.0 | 26465000000.0 | 18498000000.0 |
Other short-term investments | 91883000000.0 | 118704000000.0 | 110229000000.0 | 101177000000.0 | |
Total cash | 113762000000.0 | 139649000000.0 | 136694000000.0 | 119675000000.0 | |
Net receivables | 40258000000.0 | 39304000000.0 | 30930000000.0 | 25326000000.0 | |
Inventory | 2670000000.0 | 1170000000.0 | 728000000.0 | 999000000.0 | |
... | ... | ... | ... | ... | ... |
TSLA | Common stock | 3000000.0 | 1000000.0 | 1000000.0 | 0.0 |
Retained earnings | 12885000000.0 | 331000000.0 | -5399000000.0 | -6083000000.0 | |
Accumulated other comprehensive income | -361000000.0 | 54000000.0 | 363000000.0 | -36000000.0 | |
Total stockholders' equity | 44704000000.0 | 30189000000.0 | 22225000000.0 | 6618000000.0 | |
Total liabilities and stockholders' equity | 82338000000.0 | 62131000000.0 | 52148000000.0 | 34309000000.0 |
65 rows × 4 columns
With this done, it's now time to initialize the Toolkit and start using the Finance Toolkit with these custom datasets. By looking at the Balance Sheet Statement you can see that the column names have changed to the normalisation files.
Note: It is important to always ensure that dates go from left to right. For example this dataset starts at 2022 and ends at 2019. This should be reversed to accommodate shifting the DataFrames accordingly throughout the Toolkit. E.g. for growth metrics or specific ratios that require current and past values.
# initialize the Toolkit
companies = Toolkit(
tickers=["TSLA", "GOOGL"],
balance=balance_sheets,
income=income_statements,
cash=cash_flow_statements,
format_location="external_datasets",
reverse_dates=True, # Important when the dates are descending
)
# Show the Balance Sheet
companies.get_balance_sheet_statement()
Obtaining historical statistics: 100%|██████████| 2/2 [00:00<00:00, 9.31it/s]
2019 | 2020 | 2021 | 2022 | ||
---|---|---|---|---|---|
Breakdown | |||||
GOOGL | Cash and Cash Equivalents | 18498000000.0 | 26465000000.0 | 20945000000.0 | 21879000000.0 |
Short Term Investments | 101177000000.0 | 110229000000.0 | 118704000000.0 | 91883000000.0 | |
Cash and Short Term Investments | 119675000000.0 | 136694000000.0 | 139649000000.0 | 113762000000.0 | |
Accounts Receivable | 25326000000.0 | 30930000000.0 | 39304000000.0 | 40258000000.0 | |
Inventory | 999000000.0 | 728000000.0 | 1170000000.0 | 2670000000.0 | |
Other Current Assets | 4412000000.0 | 5490000000.0 | 7054000000.0 | 8105000000.0 | |
Total Current Assets | 152578000000.0 | 174296000000.0 | 188143000000.0 | 164795000000.0 | |
Long Term Investments | 13078000000.0 | 20703000000.0 | 29549000000.0 | 30492000000.0 | |
Goodwill | 20624000000.0 | 21175000000.0 | 22956000000.0 | 28960000000.0 | |
Intangible Assets | 1979000000.0 | 1445000000.0 | 1417000000.0 | 2084000000.0 | |
Other Fixed Assets | 2342000000.0 | 3953000000.0 | 5361000000.0 | 6623000000.0 | |
Fixed Assets | 123331000000.0 | 145320000000.0 | 171125000000.0 | 200469000000.0 | |
Total Assets | 275909000000.0 | 319616000000.0 | 359268000000.0 | 365264000000.0 | |
Accounts Payable | 5561000000.0 | 5589000000.0 | 6037000000.0 | 5128000000.0 | |
Tax Payables | 274000000.0 | 1485000000.0 | 808000000.0 | NaN | |
Deferred Revenue | 1908000000.0 | 2543000000.0 | 3288000000.0 | 3908000000.0 | |
Deferred Revenue | 358000000.0 | 481000000.0 | 535000000.0 | 599000000.0 | |
Other Current Liabilities | 9405000000.0 | 10409000000.0 | 9799000000.0 | 9106000000.0 | |
Total Current Liabilities | 45221000000.0 | 56834000000.0 | 64254000000.0 | 69300000000.0 | |
Long Term Debt | 4554000000.0 | 13932000000.0 | 14817000000.0 | 14701000000.0 | |
Deferred Tax Liabilities | 1701000000.0 | 3561000000.0 | 5257000000.0 | 514000000.0 | |
Other Non Current Liabilities | 2534000000.0 | 2269000000.0 | 2205000000.0 | 2247000000.0 | |
Total Non Current Liabilities | 29246000000.0 | 40238000000.0 | 43379000000.0 | 39820000000.0 | |
Total Liabilities | 74467000000.0 | 97072000000.0 | 107633000000.0 | 109120000000.0 | |
Common Stock | 50552000000.0 | 58510000000.0 | 61774000000.0 | 68184000000.0 | |
Retained Earnings | 152122000000.0 | 163401000000.0 | 191484000000.0 | 195563000000.0 | |
Accumulated Other Comprehensive Income | -1232000000.0 | 633000000.0 | -1623000000.0 | -7603000000.0 | |
Total Equity | 201442000000.0 | 222544000000.0 | 251635000000.0 | 256144000000.0 | |
Total Liabilities and Shareholder Equity | 275909000000.0 | 319616000000.0 | 359268000000.0 | 365264000000.0 | |
TSLA | Cash and Cash Equivalents | 6268000000.0 | 19384000000.0 | 17576000000.0 | 22185000000.0 |
Short Term Investments | NaN | NaN | 131000000.0 | 5932000000.0 | |
Cash and Short Term Investments | 6268000000.0 | 19384000000.0 | 17707000000.0 | 22185000000.0 | |
Accounts Receivable | 1324000000.0 | 1886000000.0 | 1913000000.0 | 2952000000.0 | |
Inventory | 3552000000.0 | 4101000000.0 | 5757000000.0 | 12839000000.0 | |
Other Current Assets | NaN | NaN | NaN | 2941000000.0 | |
Total Current Assets | 12103000000.0 | 26717000000.0 | 27100000000.0 | 40917000000.0 | |
Goodwill | 198000000.0 | 207000000.0 | 200000000.0 | 194000000.0 | |
Intangible Assets | 339000000.0 | 313000000.0 | 1717000000.0 | 593000000.0 | |
Other Fixed Assets | 1077000000.0 | 1536000000.0 | 2138000000.0 | 4193000000.0 | |
Fixed Assets | 22206000000.0 | 25431000000.0 | 35031000000.0 | 41421000000.0 | |
Total Assets | 34309000000.0 | 52148000000.0 | 62131000000.0 | 82338000000.0 | |
Accounts Payable | 3771000000.0 | 6051000000.0 | 10025000000.0 | 15255000000.0 | |
Deferred Revenue | 1889000000.0 | 2210000000.0 | 2372000000.0 | 2810000000.0 | |
Deferred Revenue | 1207000000.0 | 1284000000.0 | 2052000000.0 | 2804000000.0 | |
Other Current Liabilities | 317000000.0 | 241000000.0 | 294000000.0 | 354000000.0 | |
Total Current Liabilities | 10667000000.0 | 14248000000.0 | 19705000000.0 | 26709000000.0 | |
Long Term Debt | 11634000000.0 | 9607000000.0 | 5245000000.0 | 1597000000.0 | |
Deferred Tax Liabilities | NaN | 151000000.0 | 24000000.0 | 82000000.0 | |
Other Non Current Liabilities | 2691000000.0 | 3330000000.0 | 3546000000.0 | 5330000000.0 | |
Total Non Current Liabilities | 15532000000.0 | 14221000000.0 | 10843000000.0 | 9731000000.0 | |
Total Liabilities | 26199000000.0 | 28469000000.0 | 30548000000.0 | 36440000000.0 | |
Common Stock | 0.0 | 1000000.0 | 1000000.0 | 3000000.0 | |
Retained Earnings | -6083000000.0 | -5399000000.0 | 331000000.0 | 12885000000.0 | |
Accumulated Other Comprehensive Income | -36000000.0 | 363000000.0 | 54000000.0 | -361000000.0 | |
Total Equity | 6618000000.0 | 22225000000.0 | 30189000000.0 | 44704000000.0 | |
Total Liabilities and Shareholder Equity | 34309000000.0 | 52148000000.0 | 62131000000.0 | 82338000000.0 | |
Short Term Debt | 1785000000.0 | 2132000000.0 | 1589000000.0 | 1502000000.0 |
With this, it is now possible to do ratio calculations on these custom datasets. Let's have a look at the output of the extended Dupont model.
companies.models.get_extended_dupont_analysis()
Obtaining historical data: 100%|██████████| 3/3 [00:00<00:00, 9.69it/s]
2019 | 2020 | 2021 | 2022 | ||
---|---|---|---|---|---|
GOOGL | Interest Burden Ratio | 0.9067 | 0.8574 | 0.8675 | 1.0493 |
Tax Burden Ratio | 0.9559 | 0.9768 | 0.9659 | 0.8013 | |
Operating Profit Margin | 0.2448 | 0.2634 | 0.3522 | 0.2522 | |
Asset Turnover | NaN | 0.613 | 0.759 | 0.7807 | |
Equity Multiplier | NaN | 1.4046 | 1.4317 | 1.4269 | |
Return on Equity | NaN | 0.19 | 0.3207 | 0.2362 | |
TSLA | Interest Burden Ratio | -0.1203 | 1.7279 | 1.0241 | 1.0082 |
Tax Burden Ratio | -10.775 | 0.346 | 0.8496 | 0.9097 | |
Operating Profit Margin | -0.0271 | 0.0366 | 0.1178 | 0.1684 | |
Asset Turnover | NaN | 0.7295 | 0.942 | 1.1277 | |
Equity Multiplier | NaN | 2.9975 | 2.1803 | 1.929 | |
Return on Equity | NaN | 0.0478 | 0.2106 | 0.336 |
This can also be extended into the area of efficiency ratios.
companies.ratios.collect_efficiency_ratios()
Obtaining financial statements: 0it [00:00, ?it/s]
There is an index name missing in the provided financial statements. This is 'Operating Cash Flow'. This is required for the function (get_cash_conversion_efficiency) to run. Please fill this column to be able to calculate the ratios.
2019 | 2020 | 2021 | 2022 | ||
---|---|---|---|---|---|
GOOGL | Days of Inventory Outstanding (DIO) | NaN | 3.7197 | 3.1223 | 5.553 |
Days of Sales Outstanding (DSO) | NaN | 56.2477 | 49.751 | 51.3374 | |
Operating Cycle (CC) | NaN | 59.9674 | 52.8733 | 56.8904 | |
Days of Accounts Payable Outstanding (DPO) | NaN | 24.0154 | 19.1253 | 16.1455 | |
Cash Conversion Cycle (CCC) | NaN | 35.952 | 33.748 | 40.7448 | |
Receivables Turnover | NaN | 0.1541 | 0.1363 | 0.1407 | |
Inventory Turnover Ratio | NaN | 98.1262 | 116.9009 | 65.7307 | |
Accounts Payable Turnover Ratio | NaN | 15.1986 | 19.0846 | 22.6069 | |
SGA-to-Revenue Ratio | 0.1731 | 0.1589 | 0.1414 | 0.1495 | |
Fixed Asset Turnover | NaN | 1.3588 | 1.6283 | 1.5223 | |
Asset Turnover Ratio | NaN | 0.613 | 0.759 | 0.7807 | |
Operating Ratio | 0.778 | 0.7741 | 0.6945 | 0.7354 | |
TSLA | Days of Inventory Outstanding (DIO) | NaN | 56.0778 | 44.7344 | 55.9945 |
Days of Sales Outstanding (DSO) | NaN | 18.5764 | 12.8814 | 10.8991 | |
Operating Cycle (CC) | NaN | 74.6541 | 57.6159 | 66.8936 | |
Days of Accounts Payable Outstanding (DPO) | NaN | 71.9712 | 72.951 | 76.1207 | |
Cash Conversion Cycle (CCC) | NaN | 2.6829 | -15.3351 | -9.2271 | |
Receivables Turnover | NaN | 0.0509 | 0.0353 | 0.0299 | |
Inventory Turnover Ratio | NaN | 6.5088 | 8.1593 | 6.5185 | |
Accounts Payable Turnover Ratio | NaN | 5.0715 | 5.0034 | 4.795 | |
SGA-to-Revenue Ratio | 0.1077 | 0.0997 | 0.0839 | 0.0484 | |
Fixed Asset Turnover | NaN | 1.324 | 1.7804 | 2.1311 | |
Asset Turnover Ratio | NaN | 0.7295 | 0.942 | 1.1277 | |
Operating Ratio | 0.9967 | 0.9368 | 0.8793 | 0.8302 |
Optional parameters can also be used, as an example to see the growth of each item in the financial statement.
companies.get_balance_sheet_statement(growth=True)
2019 | 2020 | 2021 | 2022 | ||
---|---|---|---|---|---|
Breakdown | |||||
GOOGL | Cash and Cash Equivalents | NaN | 0.4307 | -0.2086 | 0.0446 |
Short Term Investments | NaN | 0.0895 | 0.0769 | -0.2259 | |
Cash and Short Term Investments | NaN | 0.1422 | 0.0216 | -0.1854 | |
Accounts Receivable | NaN | 0.2213 | 0.2707 | 0.0243 | |
Inventory | NaN | -0.2713 | 0.6071 | 1.2821 | |
Other Current Assets | NaN | 0.2443 | 0.2849 | 0.149 | |
Total Current Assets | NaN | 0.1423 | 0.0794 | -0.1241 | |
Long Term Investments | NaN | 0.583 | 0.4273 | 0.0319 | |
Goodwill | NaN | 0.0267 | 0.0841 | 0.2615 | |
Intangible Assets | NaN | -0.2698 | -0.0194 | 0.4707 | |
Other Fixed Assets | NaN | 0.6879 | 0.3562 | 0.2354 | |
Fixed Assets | NaN | 0.1783 | 0.1776 | 0.1715 | |
Total Assets | NaN | 0.1584 | 0.1241 | 0.0167 | |
Accounts Payable | NaN | 0.005 | 0.0802 | -0.1506 | |
Tax Payables | NaN | 4.4197 | -0.4559 | 5.3465 | |
Deferred Revenue | NaN | 0.3328 | 0.293 | 0.1886 | |
Deferred Revenue | NaN | 0.3436 | 0.1123 | 0.1196 | |
Other Current Liabilities | NaN | 0.1068 | -0.0586 | -0.0707 | |
Total Current Liabilities | NaN | 0.2568 | 0.1306 | 0.0785 | |
Long Term Debt | NaN | 2.0593 | 0.0635 | -0.0078 | |
Deferred Tax Liabilities | NaN | 1.0935 | 0.4763 | -0.9022 | |
Other Non Current Liabilities | NaN | -0.1046 | -0.0282 | 0.019 | |
Total Non Current Liabilities | NaN | 0.3758 | 0.0781 | -0.082 | |
Total Liabilities | NaN | 0.3036 | 0.1088 | 0.0138 | |
Common Stock | NaN | 0.1574 | 0.0558 | 0.1038 | |
Retained Earnings | NaN | 0.0741 | 0.1719 | 0.0213 | |
Accumulated Other Comprehensive Income | NaN | -1.5138 | -3.564 | 3.6845 | |
Total Equity | NaN | 0.1048 | 0.1307 | 0.0179 | |
Total Liabilities and Shareholder Equity | NaN | 0.1584 | 0.1241 | 0.0167 | |
TSLA | Cash and Cash Equivalents | NaN | 2.0925 | -0.0933 | 0.2622 |
Short Term Investments | NaN | 2.0925 | -0.9932 | 44.2824 | |
Cash and Short Term Investments | NaN | 2.0925 | -0.0865 | 0.2529 | |
Accounts Receivable | NaN | 0.4245 | 0.0143 | 0.5431 | |
Inventory | NaN | 0.1546 | 0.4038 | 1.2302 | |
Other Current Assets | NaN | 0.1546 | 0.4038 | -0.4891 | |
Total Current Assets | NaN | 1.2075 | 0.0143 | 0.5099 | |
Goodwill | NaN | 0.0455 | -0.0338 | -0.03 | |
Intangible Assets | NaN | -0.0767 | 4.4856 | -0.6546 | |
Other Fixed Assets | NaN | 0.4262 | 0.3919 | 0.9612 | |
Fixed Assets | NaN | 0.1452 | 0.3775 | 0.1824 | |
Total Assets | NaN | 0.52 | 0.1914 | 0.3252 | |
Accounts Payable | NaN | 0.6046 | 0.6568 | 0.5217 | |
Deferred Revenue | NaN | 0.1699 | 0.0733 | 0.1847 | |
Deferred Revenue | NaN | 0.0638 | 0.5981 | 0.3665 | |
Other Current Liabilities | NaN | -0.2397 | 0.2199 | 0.2041 | |
Total Current Liabilities | NaN | 0.3357 | 0.383 | 0.3554 | |
Long Term Debt | NaN | -0.1742 | -0.454 | -0.6955 | |
Deferred Tax Liabilities | NaN | -0.987 | -0.8411 | 2.4167 | |
Other Non Current Liabilities | NaN | 0.2375 | 0.0649 | 0.5031 | |
Total Non Current Liabilities | NaN | -0.0844 | -0.2375 | -0.1026 | |
Total Liabilities | NaN | 0.0866 | 0.073 | 0.1929 | |
Common Stock | NaN | inf | 0.0 | 2.0 | |
Retained Earnings | NaN | -0.1124 | -1.0613 | 37.9275 | |
Accumulated Other Comprehensive Income | NaN | -11.0833 | -0.8512 | -7.6852 | |
Total Equity | NaN | 2.3583 | 0.3583 | 0.4808 | |
Total Liabilities and Shareholder Equity | NaN | 0.52 | 0.1914 | 0.3252 | |
Short Term Debt | NaN | 0.1944 | -0.2547 | -0.0548 |
And you can look into performance and risk measurements as well.
beta_plot = companies.performance.get_beta(period="monthly").plot(
figsize=(15, 5), title="Beta of Tesla and Apple compared to the S&P 500"
)
beta_plot.axhline(y=1.0, color="red", linestyle="--")
<matplotlib.lines.Line2D at 0x28e51fc70>
companies.risk.get_maximum_drawdown(period="quarterly").plot.area(
figsize=(15, 5), title="Maximum Drawdown for each Quarter", stacked=False
)
<Axes: title={'center': 'Maximum Drawdown for each Quarter'}>
And lastly, the historical data can be viewed which includes OHLC, Volume, Dividends, Volatility and (Cumulative) Returns.
companies.get_historical_data()
Open | High | Low | Close | ... | Volatility | Excess Return | Excess Volatility | Cumulative Return | |||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
TSLA | GOOGL | Benchmark | TSLA | GOOGL | Benchmark | TSLA | GOOGL | Benchmark | TSLA | ... | Benchmark | TSLA | GOOGL | Benchmark | TSLA | GOOGL | Benchmark | TSLA | GOOGL | Benchmark | |
Date | |||||||||||||||||||||
2014-01-07 | 9.8413 | 28.1532 | 183.09 | 10.0267 | 28.5208 | 183.79 | 9.6833 | 28.0571 | 182.95 | 9.9573 | ... | 0.011 | -0.0133 | -0.0101 | -0.0233 | 0.0366 | 0.0198 | 0.0143 | 1.0 | 1.0 | 1.0 |
2014-01-08 | 9.9233 | 28.6787 | 183.45 | 10.2467 | 28.7117 | 183.83 | 9.9173 | 28.3606 | 182.89 | 10.0853 | ... | 0.011 | -0.017 | -0.0278 | -0.0297 | 0.0366 | 0.0198 | 0.0143 | 1.0129 | 1.0021 | 1.0002 |
2014-01-09 | 10.1667 | 28.6146 | 184.11 | 10.2287 | 28.6341 | 184.13 | 9.79 | 28.1672 | 182.8 | 9.8353 | ... | 0.011 | -0.0544 | -0.0392 | -0.0289 | 0.0366 | 0.0198 | 0.0143 | 0.9877 | 0.9924 | 1.0009 |
2014-01-10 | 9.8973 | 28.5055 | 183.95 | 9.9267 | 28.5055 | 184.22 | 9.4833 | 28.0843 | 183.01 | 9.7147 | ... | 0.011 | -0.0409 | -0.0287 | -0.0259 | 0.0366 | 0.0198 | 0.0143 | 0.9756 | 0.9924 | 1.0036 |
2014-01-13 | 9.7187 | 28.1899 | 183.67 | 9.8 | 28.7014 | 184.18 | 9.188 | 27.9572 | 181.34 | 9.2893 | ... | 0.011 | -0.0721 | -0.0347 | -0.0416 | 0.0366 | 0.0198 | 0.0143 | 0.9329 | 0.9861 | 0.9902 |
... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
2023-12-29 | 255.1 | 139.63 | 476.49 | 255.19 | 140.36 | 477.03 | 247.43 | 138.78 | 473.3 | 248.48 | ... | 0.011 | -0.0573 | -0.0426 | -0.0416 | 0.0366 | 0.0198 | 0.0143 | 24.9545 | 4.9014 | 3.1038 |
2024-01-02 | 250.08 | 138.55 | 472.16 | 251.25 | 139.45 | 473.67 | 244.41 | 136.48 | 470.49 | 248.42 | ... | 0.011 | -0.0397 | -0.0504 | -0.0451 | 0.0366 | 0.0198 | 0.0143 | 24.9484 | 4.8481 | 3.0865 |
2024-01-03 | 244.98 | 137.25 | 470.43 | 245.68 | 139.63 | 471.19 | 236.32 | 137.08 | 468.17 | 238.45 | ... | 0.011 | -0.0792 | -0.0337 | -0.0473 | 0.0366 | 0.0198 | 0.0143 | 23.9472 | 4.8744 | 3.0613 |
2024-01-04 | 239.25 | 138.42 | 468.3 | 242.7 | 139.16 | 470.96 | 237.73 | 136.35 | 467.05 | 237.93 | ... | 0.011 | -0.0421 | -0.0581 | -0.0431 | 0.0366 | 0.0198 | 0.0143 | 23.895 | 4.7856 | 3.0514 |
2024-01-05 | 236.86 | 136.745 | 467.49 | 239.0 | 137.08 | 469.02 | 234.9001 | 136.265 | 467.13 | 238.71 | ... | 0.011 | -0.0372 | -0.038 | -0.0372 | 0.0366 | 0.0198 | 0.0143 | 23.9733 | 4.7975 | 3.0613 |
2517 rows × 36 columns
Note that it is possible that your dataset doesn't cover all financial statement items if your normalization files are incomplete. This will become apparent when some ratios can not be calculated.
# Missing column returns an empty series
display(companies.ratios.get_debt_to_assets_ratio())
# Missing column skips the ratio in the total overview
display(companies.ratios.collect_profitability_ratios())
Obtaining financial statements: 0it [00:00, ?it/s]
There is an index name missing in the provided financial statements. This is 'Total Debt'. This is required for the function (get_debt_to_assets_ratio) to run. Please fill this column to be able to calculate the ratios.
Series([], dtype: object)
Obtaining financial statements: 0it [00:00, ?it/s]
There is an index name missing in the provided financial statements. This is 'Depreciation and Amortization'. This is required for the function (get_interest_coverage_ratio) to run. Please fill this column to be able to calculate the ratios. There is an index name missing in the provided financial statements. This is 'Dividends Paid'. This is required for the function (get_return_on_invested_capital) to run. Please fill this column to be able to calculate the ratios.
2019 | 2020 | 2021 | 2022 | ||
---|---|---|---|---|---|
GOOGL | Gross Margin | 0.5558 | 0.5358 | 0.5694 | 0.5538 |
Operating Margin | 0.222 | 0.2259 | 0.3055 | 0.2646 | |
Net Profit Margin | 0.2122 | 0.2206 | 0.2951 | 0.212 | |
Income Before Tax Profit Margin | 0.2448 | 0.2634 | 0.3522 | 0.2522 | |
Effective Tax Rate | 0.1333 | 0.1625 | 0.162 | 0.1592 | |
Return on Assets (ROA) | NaN | 0.1352 | 0.224 | 0.1655 | |
Return on Equity (ROE) | NaN | 0.19 | 0.3207 | 0.2362 | |
Return on Capital Employed (ROCE) | 0.1722 | 0.1835 | 0.3087 | 0.2422 | |
Return on Tangible Assets | NaN | 0.1045 | 0.1715 | 0.127 | |
Income Quality Ratio | 1.5875 | 1.6172 | 1.2054 | 1.5256 | |
Net Income per EBT | 0.8667 | 0.8375 | 0.838 | 0.8408 | |
Free Cash Flow to Operating Cash Flow Ratio | 0.5681 | 0.6579 | 0.7312 | 0.6559 | |
EBT to EBIT Ratio | 0.9975 | 0.9972 | 0.9962 | 0.995 | |
EBIT to Revenue | 0.2454 | 0.2642 | 0.3535 | 0.2535 | |
TSLA | Gross Margin | 0.1656 | 0.2102 | 0.2528 | 0.256 |
Operating Margin | 0.0033 | 0.0632 | 0.1207 | 0.1698 | |
Net Profit Margin | -0.0351 | 0.0219 | 0.1025 | 0.1545 | |
Income Before Tax Profit Margin | -0.0271 | 0.0366 | 0.1178 | 0.1684 | |
Effective Tax Rate | -0.1654 | 0.253 | 0.1102 | 0.0825 | |
Return on Assets (ROA) | NaN | 0.016 | 0.0966 | 0.1742 | |
Return on Equity (ROE) | NaN | 0.0478 | 0.2106 | 0.336 | |
Return on Capital Employed (ROCE) | -0.0028 | 0.0456 | 0.1553 | 0.25 | |
Return on Tangible Assets | NaN | 0.0097 | 0.063 | 0.1177 | |
Income Quality Ratio | -2.79 | 8.613 | 2.0832 | 1.1702 | |
Net Income per EBT | 1.1463 | 0.7026 | 0.8876 | 0.9175 | |
Free Cash Flow to Operating Cash Flow Ratio | 0.4025 | 0.4545 | 0.3029 | 0.5129 | |
EBT to EBIT Ratio | 11.2239 | 0.5676 | 0.9437 | 0.9863 | |
EBIT to Revenue | -0.0027 | 0.0549 | 0.1224 | 0.1707 |
It is also possible to still include your Financial Modeling Prep key and run the related functionality.
# initialize the Toolkit
companies = Toolkit(
tickers=["TSLA", "GOOGL"],
balance=balance_sheets,
income=income_statements,
cash=cash_flow_statements,
api_key="FMP_KEY",
format_location="external_datasets",
reverse_dates=True, # Important when the dates are descending
)
# Show the Analyst Estimates from Financial Modeling Prep
companies.get_analyst_estimates()
Obtaining historical statistics: 100%|██████████| 2/2 [00:00<00:00, 9.50it/s] Obtaining analyst estimates: 100%|██████████| 2/2 [00:00<00:00, 9.74it/s]
date | 2014 | 2015 | 2016 | 2017 | 2018 | 2019 | 2020 | 2021 | 2022 | 2023 | 2024 | |
---|---|---|---|---|---|---|---|---|---|---|---|---|
TSLA | Estimated Revenue Low | 3096377368.0 | 3031073263.0 | 3563669919.0 | 10424883038.0 | 14213344964.0 | 9528177383.0 | 16540536575.0 | 41987852497.0 | 61863038539.0 | 89650300000.0 | 90735100000.0 |
Estimated Revenue High | 4004408595.0 | 3919953669.0 | 4608737488.0 | 13482042489.0 | 18381493587.0 | 12322372524.0 | 21391148090.0 | 54301041968.0 | 80004745473.0 | 97335500000.0 | 135949000000.0 | |
Estimated Revenue Average | 3504090326.0 | 3430187356.0 | 4032913241.0 | 11797570986.0 | 16084875537.0 | 10782792347.0 | 18718498200.0 | 47516568631.0 | 70008803539.0 | 97309747770.0 | 119556983730.0 | |
Estimated EBITDA Low | 67202937.0 | -1790598161.0 | 813638881.0 | 132981646.0 | 12456436555.0 | 5018474813.0 | 2331077632.0 | 6222540492.0 | 8451256459.0 | 9503646657.0 | 12787406330.0 | |
Estimated EBITDA High | 116549325.0 | -1193732107.0 | 1334534318.0 | 337625225.0 | 18884056737.0 | 7632302505.0 | 3014680123.0 | 9333810739.0 | 12676884692.0 | 14255469991.0 | 19159455417.0 | |
Estimated EBITDA Average | 91876131.0 | -1492165134.0 | 1074086600.0 | 235303436.0 | 15670246646.0 | 6325388659.0 | 2638020373.0 | 7778175616.0 | 10564070576.0 | 11879558324.0 | 16849308929.0 | |
Estimated EBIT Low | -432667751.0 | -3590749718.0 | -429111338.0 | -1797932097.0 | 3847184569.0 | 45613001.0 | 6292253089.0 | 10078959157.0 | 12587376986.0 | 13981202161.0 | 6394341449.0 | |
Estimated EBIT High | -288445167.0 | -2393833145.0 | -115781580.0 | -1198621397.0 | 6997703164.0 | 1266188429.0 | 9438379634.0 | 15118438737.0 | 18881065481.0 | 20971803245.0 | 9580684054.0 | |
Estimated EBIT Average | -360556459.0 | -2992291432.0 | -272446459.0 | -1498276747.0 | 5422443867.0 | 655900715.0 | 7865316362.0 | 12598698947.0 | 15734221234.0 | 17476502703.0 | 8425495499.0 | |
Estimated Net Income Low | -707480721.0 | -4429783647.0 | -604415639.0 | -2181290577.0 | 2099149004.0 | -1433231913.0 | 1746428838.0 | 3641422676.0 | 5460936341.0 | 6124613739.0 | 8062000002.0 | |
Estimated Net Income High | -471653814.0 | -2953189097.0 | -359430847.0 | -1454193717.0 | 4586996630.0 | -329062941.0 | 2619643259.0 | 5462134014.0 | 8191404512.0 | 9186920611.0 | 18417500005.0 | |
Estimated Net Income Average | -589567268.0 | -3691486372.0 | -481923243.0 | -1817742147.0 | 3343072817.0 | -881147427.0 | 2183036049.0 | 4551778345.0 | 6826170427.0 | 9101951320.0 | 12574779170.0 | |
Estimated SGA Expense Low | 945468432.0 | 286025570.0 | 1399742160.0 | 1872842029.0 | 10421778962.0 | 4984100512.0 | 12365515385.0 | 2939271443.0 | 3049942310.0 | 3455119556.0 | 8562168082.0 | |
Estimated SGA Expense High | 1418202648.0 | 369904283.0 | 2099613242.0 | 2809263044.0 | 15632668444.0 | 7476150770.0 | 18548273078.0 | 4408907166.0 | 4574913468.0 | 5182679337.0 | 12828753026.0 | |
Estimated SGA Expense Average | 1181835540.0 | 323687753.0 | 1749677701.0 | 2341052537.0 | 13027223703.0 | 6230125641.0 | 15456894232.0 | 3674089305.0 | 3812427889.0 | 4318899447.0 | 11281929376.0 | |
Estimated EPS Average | -0.0177 | -0.0621 | -0.0976 | -0.5893 | -0.2399 | 0.0264 | 0.5052 | 1.91 | 3.47 | 2.6523 | 3.6066 | |
Estimated EPS High | -0.0248 | -0.087 | -0.1367 | -0.8259 | -0.3361 | 0.037 | 0.708 | 2.6766 | 4.8627 | 2.83 | 5.3 | |
Estimated EPS Low | -0.0126 | -0.0443 | -0.0695 | -0.42 | -0.1709 | 0.0188 | 0.3601 | 1.3612 | 2.473 | 2.51 | 2.32 | |
Number of Analysts | 51.0 | 49.0 | 47.0 | 45.0 | 43.0 | 41.0 | 39.0 | 37.0 | 35.0 | 33.0 | 34.0 | |
GOOGL | Estimated Revenue Low | 65268485936.0 | 69863055218.0 | 86956450751.0 | 100521038821.0 | 145256564742.0 | 152962870406.0 | 153067982228.0 | 231959966099.0 | 284302576965.0 | 250440000000.0 | 276000000000.0 |
Estimated Revenue High | 69764375481.0 | 74675432509.0 | 92946272519.0 | 107445230199.0 | 155262273645.0 | 163499412813.0 | 163611765052.0 | 247938065967.0 | 303886193241.0 | 256100000000.0 | 292830000000.0 | |
Estimated Revenue Average | 67787957128.0 | 72559884361.0 | 90313113151.0 | 104401316690.0 | 150863707685.0 | 158867489456.0 | 158976658767.0 | 240914003317.0 | 295277125281.0 | 254370000000.0 | 282690000000.0 | |
Estimated EBITDA Low | 18780939496.0 | 19198264630.0 | 24254021846.0 | 17491760180.0 | 28977367529.0 | 38185917614.0 | 36199309683.0 | 64461779570.0 | 78387338355.0 | 86226072190.0 | 89060703635.0 | |
Estimated EBITDA High | 28171409246.0 | 28797396948.0 | 36381032769.0 | 26237640271.0 | 43466051293.0 | 57278876422.0 | 54298964526.0 | 96692669355.0 | 117581007534.0 | 129339108285.0 | 94491470455.0 | |
Estimated EBITDA Average | 23476174371.0 | 23997830789.0 | 30317527308.0 | 21864700226.0 | 36221709411.0 | 47732397018.0 | 45249137105.0 | 80577224463.0 | 97984172945.0 | 107782590238.0 | 91219457648.0 | |
Estimated EBIT Low | 13552007555.0 | 14966768712.0 | 18928896440.0 | 19537501417.0 | 16900815982.0 | 25737843472.0 | 24208375544.0 | 48990664306.0 | 64812498549.0 | 71293748403.0 | 70323787089.0 | |
Estimated EBIT High | 20328011335.0 | 22450153068.0 | 28393344661.0 | 29306252125.0 | 25351223973.0 | 38606765210.0 | 36312563316.0 | 73485996460.0 | 97218747826.0 | 106940622607.0 | 74612009323.0 | |
Estimated EBIT Average | 16940009445.0 | 18708460890.0 | 23661120551.0 | 24421876771.0 | 21126019978.0 | 32172304341.0 | 30260469430.0 | 61238330383.0 | 81015623188.0 | 89117185505.0 | 72028374537.0 | |
Estimated Net Income Low | 11617824069.0 | 12621305194.0 | 15522946080.0 | 7492014868.0 | 19532977824.0 | 25108117211.0 | 23401409380.0 | 47335069756.0 | 56411506308.0 | 62052656938.0 | 79480360006.0 | |
Estimated Net Income High | 17426736105.0 | 18931957791.0 | 23284419122.0 | 14342751763.0 | 29299466738.0 | 37662175817.0 | 35102114072.0 | 71002604636.0 | 84617259463.0 | 93078985408.0 | 94876390007.0 | |
Estimated Net Income Average | 14522280087.0 | 15776631493.0 | 19403682601.0 | 10917383316.0 | 24416222281.0 | 31385146514.0 | 29251761726.0 | 59168837196.0 | 70514382886.0 | 73009853150.0 | 83774546770.0 | |
Estimated SGA Expense Low | 11489239912.0 | 14996937776.0 | 13955942982.0 | 14806871777.0 | 17356320960.0 | 21149137629.0 | 17790419858.0 | 22821906759.0 | 31573740728.0 | 34731114799.0 | 44249303663.0 | |
Estimated SGA Expense High | 17233859867.0 | 22495406665.0 | 20933914474.0 | 22210307665.0 | 26034481441.0 | 31723706445.0 | 26685629788.0 | 34232860141.0 | 47360611093.0 | 52096672201.0 | 46947549245.0 | |
Estimated SGA Expense Average | 14361549890.0 | 18746172221.0 | 17444928728.0 | 18508589721.0 | 21695401201.0 | 26436422037.0 | 22238024823.0 | 28527383450.0 | 39467175911.0 | 43413893500.0 | 45321868306.0 | |
Estimated EPS Average | 1.31 | 1.44 | 1.71 | 1.52 | 1.99 | 2.34 | 2.29 | 4.3 | 5.01 | 5.78 | 6.66 | |
Estimated EPS High | 1.4384 | 1.5811 | 1.8775 | 1.6689 | 2.185 | 2.5693 | 2.5144 | 4.7213 | 5.5009 | 5.91 | 7.21 | |
Estimated EPS Low | 1.1328 | 1.2452 | 1.4787 | 1.3144 | 1.7208 | 2.0234 | 1.9802 | 3.7183 | 4.3322 | 5.29 | 6.04 | |
Number of Analysts | 53.0 | 51.0 | 49.0 | 47.0 | 45.0 | 43.0 | 41.0 | 39.0 | 37.0 | 35.0 | 35.0 |