have been working on the v2.0.0 of the Finance Toolkit for a while which features numerous improvements to the code as well as major new additions. Install the Finance Toolkit now to get started with 150+ metrics!
pip install financetoolkit -U
In Python:
from financetoolkit import Toolkit
companies = Toolkit(
tickers=['GOOGL', 'MSFT', 'AMZN'],
api_key="FINANCIAL_MODELING_PREP_KEY",
)
Portfolio Functionalities
I've added a brand new class to the Finance Toolkit called Portfolio
(use from financetoolkit import Portfolio
) which allows you to load in your own transactions data and see performance over any period of time (as opposed to some benchmark).
For a full list of details see here. Some things that are now possible:
- Load in your own transactions data, based on a custom template that is provided automatically when initializing the class.
- See an overview of your entire portfolio including invested amount, current value, return, benchmark return, alpha, beta and more.
- Explore individual transactions and see how they have contributed to the overall performance of your portfolio. This also allows you to get a breakdown per period whether it be weekly, monthly, quarterly or yearly.
- Delve deeper into how your portfolio performed with daily (cumulative) returns, portfolio weights and more.
As a simple example:
from financetoolkit import Portfolio
instance = Portfolio(example=True, api_key="FMP_KEY")
instance.get_portfolio_overview()
The table below shows one of the functionalities of the Portfolio module but is purposely shrunken down given the >30 assets.
Identifier | Volume | Costs | Price | Invested | Latest Price | Latest Value | Return | Return Value | Benchmark Return | Volatility | Benchmark Volatility | Alpha | Beta | Weight |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
AAPL | 137 | -28 | 38.9692 | 5310.78 | 241.84 | 33132.1 | 5.2386 | 27821.3 | 2.2258 | 0.3858 | 0.1937 | 3.0128 | 1.2027 | 0.0405 |
ALGN | 81 | -34 | 117.365 | 9472.53 | 187.03 | 15149.4 | 0.5993 | 5676.9 | 2.1413 | 0.5985 | 0.1937 | -1.542 | 1.5501 | 0.0185 |
AMD | 78 | -30 | 11.9075 | 898.784 | 99.86 | 7789.08 | 7.6662 | 6890.3 | 3.7945 | 0.6159 | 0.1937 | 3.8718 | 1.6551 | 0.0095 |
AMZN | 116 | -28 | 41.5471 | 4791.46 | 212.28 | 24624.5 | 4.1392 | 19833 | 1.8274 | 0.4921 | 0.1937 | 2.3118 | 1.1594 | 0.0301 |
ASML | 129 | -25 | 33.3184 | 4273.07 | 709.08 | 91471.3 | 20.4065 | 87198.3 | 3.8005 | 0.4524 | 0.1937 | 16.606 | 1.4407 | 0.1119 |
VOO | 77 | -12 | 238.499 | 18352.5 | 546.33 | 42067.4 | 1.2922 | 23715 | 1.1179 | 0.1699 | 0.1937 | 0.1743 | 0.9973 | 0.0515 |
WMT | 92 | -18 | 17.8645 | 1625.53 | 98.61 | 9072.12 | 4.581 | 7446.59 | 2.4787 | 0.2334 | 0.1937 | 2.1024 | 0.4948 | 0.0111 |
Portfolio | 2142 | -532 | 59.8406 | 128710 | 381.689 | 817577 | 5.3521 | 688867 | 2.0773 | 0.4193 | 0.1937 | 3.2747 | 1.2909 | 1 |
In which the weights and returns can be depicted as follows:
This is however only minor as opposed to the integration with the Finance Toolkit itself meaning that you are able to use all of the 150+ metrics directly with your own portfolio. It also includes a "Portfolio" ticker which represents the weighted sum over time of your assets in the portfolio. As an example
from financetoolkit import Portfolio
instance = Portfolio(example=True, api_key="FMP_KEY")
profit_margin = instance.toolkit.ratios.get_net_profit_margin()
Which returns when plotted for the Portfolio the following:
This makes it so that you can not only evaluate your portfolio through basic OHLC data but also understand the financial health of the companies you are invested in and how this impacts your overall portfolio.
Caching Capabilities
I've had this request a couple of times now and given the ever-growing size of the project it made sense to integrate caching functionalities. When using use_cached_data=True
when you initialize the Finance Toolkit any of the core functionalities will automatically be saved to a pickle file (e.g. if you collect a balance sheet statement, these will be saved to the cached
folder under balance_sheet_statement.pickle
). If you then re-run the Finance Toolkit you will notice the data collection is instant, this is because the data is loaded from the pickle file.
As an example:

If I wish to receive this data again, I no longer need an API key or set the tickers and can simply keep use_cached_data=True
.

Please note that it will force the settings as found in the pickle files so if you wish to use a different time period, you will have to recollect.

You can also change the folder by entering a string instead of a boolean for the use_cached_data
parameter.

Global Macro Database Integration
I've seen the work from Karsten Muller related to the "Global Macro Database" project (see LinkedIn and the GitHub project here) which has Economics metrics going back all the way to the 1800s. An invaluable resource which I've integrated into the Finance Toolkit as well. You will see that the Key Economic Indicators list is therefore greatly expanded.
As an example:
from financetoolkit import Economics
economics = Economics(api_key=API_KEY, start_date="2017-12-31")
economics.get_unemployment_rate()
The current list of Economic parameters is:
- Gross Domestic Product (GDP)
- Total Consumption
- Total Investment
- Total Fixed Investment
- Exports
- Imports
- Current Account Balance
- Government Debt
- Government (Tax) Revenue
- Government Expenditure
- Government Deficit
- Trust in Government
- Consumer Price Index (CPI)
- Inflation Rate
- Consumer Confidence Index (CCI)
- Business Confidence Index (BCI)
- Composite Leading Indicator (CLI)
- House Prices
- Rent Prices
- Share Prices
- Exchange Rates
- Money Supply
- Central Bank Policy Rate
- Long Term Interest Rates (10 year)
- Short Term Interest Rates (3 month)
- Renewable Energy as % of Total Energy
- Carbon Footprint
- Unemployment Rate
- Labour Productivity
- Income Inequality
- Population
- Poverty Rate
Many Bugfixes and Improvements
I've added better error handling for Bandwidth Limits, more information when data is collected from a different source, numerous minor fixes e.g. recalculating ratios found in the financial statements when applying trailing (#172 and #173) and cleaned up a lot of other details.
The Streamlit Dashboard is also updated with new additions including a brand new Portfolio Dashboard, see below: