Transparent and Efficient Financial Analysis
This release contains new Fixed Income metrics as part of the Economics module, these contain Option-Adjusted Spreads, Effective Yields, Total Returns and Yield to Worst. For example, see the Option-Adjusted Spread below (see documentation here):
The Option-Adjusted Spread (OAS) is the spread relative to a risk-free interest rate, usually measured in basis points (bp), that equates the theoretical present value of a series of uncertain cash flows to the market price of a fixed-income investment. The spread is added to the risk-free rate to compensate for the uncertainty of the cash flows. This is usually a better alternative than the usual Z-spread used to price derivatives.
Furthermore, @northern-64bit (maintainer of scikit-multilearn-ng) introduced new AR and MA models that can be utilised with any type of time series. For more information, see https://github.com/JerBouma/FinanceToolkit/pull/117. @northern-64bit actually introduced many more models in the Finance Toolkit as seen here.
Furthermore, I've introduced bug fixes solving #128 and #129.
This release includes the Binomial Model, a mathematical model for pricing both American as well as European options. The Binomial Model is a discrete-time model that calculates the price of an option by creating a riskless hedge portfolio that replicates the payoff of the option. The model is based on the assumption that the price of the underlying asset follows a binomial distribution. The Binomial Model is a simple and intuitive model that is widely used in practice. It is also the basis for more complex models. See for an elaborate explanation the documentation as found here.
For example, when using the following code:
from financetoolkit import Toolkit
companies = Toolkit(["AAPL", "MSFT"], api_key="FINANCIAL_MODELING_PREP_KEY")
companies.options.get_binomial_model(show_input_info=True)
It returns a large DataFrame with the binomial tree for each company and each strike price around the current price (as defined by the start_date
parameter).
The resulting output is a DataFrame containing the tickers, strike prices and movements as the index and the time to expiration as the columns. The movements index contains the number of up movements and the number of down movements. The output is the binomial tree displayed in a table. E.g. when using 10 time steps, the table for each strike price from each company will contain the actual binomial tree as also depicted in the image as seen below. Find the documentation here.
When selecting for example Apple at a Strike Price of 140 you will get the actual Binomial Tree depicted as a table, this represents the tree you see in the image at the top.
Movement | 2024-02-02 | 2024-03-09 | 2024-04-15 | 2024-05-21 | 2024-06-27 | 2024-08-02 | 2024-09-08 | 2024-10-14 | 2024-11-20 | 2024-12-26 | 2025-02-01 |
---|---|---|---|---|---|---|---|---|---|---|---|
UUUUUUUUUU | 54.7747 | 69.9327 | 87.4757 | 107.31 | 129.344 | 153.573 | 180.122 | 209.208 | 241.069 | 275.965 | 314.18 |
UUUUUUUUUD | nan | 39.9569 | 52.8423 | 68.2288 | 86.0206 | 106.037 | 128.14 | 152.365 | 178.911 | 207.994 | 239.852 |
UUUUUUUUDD | nan | nan | 27.3011 | 37.7763 | 50.8718 | 66.5774 | 84.6651 | 104.825 | 126.925 | 151.146 | 177.689 |
UUUUUUUDDD | nan | nan | nan | 16.9659 | 24.8886 | 35.4656 | 48.9066 | 65.0645 | 83.4462 | 103.602 | 125.698 |
UUUUUUDDDD | nan | nan | nan | nan | 9.1158 | 14.4288 | 22.208 | 33.0259 | 47.083 | 63.8384 | 82.2161 |
UUUUUDDDDD | nan | nan | nan | nan | nan | 3.8311 | 6.7007 | 11.4806 | 19.124 | 30.5822 | 45.85 |
UUUUDDDDDD | nan | nan | nan | nan | nan | nan | 0.9669 | 1.9327 | 3.8631 | 7.722 | 15.4353 |
UUUDDDDDDD | nan | nan | nan | nan | nan | nan | nan | 0 | 0 | 0 | 0 |
UUDDDDDDDD | nan | nan | nan | nan | nan | nan | nan | nan | 0 | 0 | 0 |
UDDDDDDDDD | nan | nan | nan | nan | nan | nan | nan | nan | nan | 0 | 0 |
DDDDDDDDDD | nan | nan | nan | nan | nan | nan | nan | nan | nan | nan | 0 |
The model contains parameters to lengthen the time steps, change the risk-free rate and the dividend yield but more importantly, make it possible to calculate the price of both American and European options as well as Call and Put options. For example, let's calculate the price of a American Put option with a strike price of 140 for Apple again:
from financetoolkit import Toolkit
companies = Toolkit(["AAPL", "MSFT"], api_key="FINANCIAL_MODELING_PREP_KEY")
companies.options.get_binomial_model(
show_input_info=True,
put_option=True,
american_option=True,
timesteps=12,
risk_free_rate=0.01)
Which returns the Option valuations for an American Put Option.
Movement | 2024-02-02 | 2024-03-03 | 2024-04-02 | 2024-05-03 | 2024-06-02 | 2024-07-03 | 2024-08-02 | 2024-09-01 | 2024-10-02 | 2024-11-01 | 2024-12-02 | 2025-01-01 | 2025-02-01 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
UUUUUUUUUUUU | 2.3581 | 1.1115 | 0.4236 | 0.116 | 0.0171 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
UUUUUUUUUUUD | nan | 3.7011 | 1.8524 | 0.7546 | 0.2225 | 0.0355 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
UUUUUUUUUUDD | nan | nan | 5.6933 | 3.0346 | 1.3274 | 0.4238 | 0.0736 | 0 | 0 | 0 | 0 | 0 | 0 |
UUUUUUUUUDDD | nan | nan | nan | 8.5588 | 4.8737 | 2.3002 | 0.8005 | 0.1529 | 0 | 0 | 0 | 0 | 0 |
UUUUUUUUDDDD | nan | nan | nan | nan | 12.5322 | 7.6463 | 3.9148 | 1.4975 | 0.3173 | 0 | 0 | 0 | 0 |
UUUUUUUDDDDD | nan | nan | nan | nan | nan | 17.8023 | 11.6676 | 6.518 | 2.7676 | 0.6586 | 0 | 0 | 0 |
UUUUUUDDDDDD | nan | nan | nan | nan | nan | nan | 24.4233 | 17.2193 | 10.5575 | 5.0375 | 1.3671 | 0 | 0 |
UUUUUDDDDDDD | nan | nan | nan | nan | nan | nan | nan | 32.2051 | 24.4052 | 16.5049 | 8.9884 | 2.8376 | 0 |
UUUUDDDDDDDD | nan | nan | nan | nan | nan | nan | nan | nan | 40.6414 | 32.9347 | 24.6074 | 15.6102 | 5.89 |
UUUDDDDDDDDD | nan | nan | nan | nan | nan | nan | nan | nan | nan | 48.9936 | 41.9389 | 34.3151 | 26.0772 |
UUDDDDDDDDDD | nan | nan | nan | nan | nan | nan | nan | nan | nan | nan | 56.6615 | 50.2044 | 43.2257 |
UDDDDDDDDDDD | nan | nan | nan | nan | nan | nan | nan | nan | nan | nan | nan | 63.702 | 57.7929 |
DDDDDDDDDDDD | nan | nan | nan | nan | nan | nan | nan | nan | nan | nan | nan | nan | 70.1673 |
Under the hood of this model the stock prices are simulated based on up and down movements. These can be graphically depicted as a binomial tree and help in understanding the calculated option prices for each node in. More information about these stock price simulations can be found in the documentation here and as follows:
from financetoolkit import Toolkit
companies = Toolkit(["AAPL", "MSFT"], api_key="FINANCIAL_MODELING_PREP_KEY")
companies.options.get_stock_price_simulations(show_input_info=True, timesteps=10)
Which would return for Apple the following graph when plotted:
Given that the Finance Toolkit is modular, you do not have to use the Toolkit functionality directly and can also call each functionality of the model separately. For example, this shows the output of using the model directly, specifying each parameter yourself.
This new release contains intraday historical data which makes it possible to calculate Risk, Performance and Technical metrics based on a 1 min, 5 min, 15 min, 30 min or 1 hour interval. For example, you can obtain the Capital Asset Pricing Model (CAPM) per model in which it calculates the beta for each hour.
Or for example Williams %R on an hourly basis as follows:
Next to that, I've done a lot of polishing. A user noticed that there were some issues with working with delisted companies. As Financial Modeling Prep allows you to get data on these companies whereas Yahoo Finance doesn't, I needed to make sure that the Finance Toolkit didn't attempt to query the Yahoo Finance and return an error. This has been resolved (all of these companies are delisted):
Furthermore, I've fixed small bugs, updated the documentation and more. All in all it should be a more pleasant experience!
It's time for another major release which consists of a full blown Options menu including all First, Second and Third Order Greeks such as Delta, Vega, Gamma, Theta and Ultima. Find the entire list of Greeks here. Update your Finance Toolkit now with:
pip install financetoolkit -U
Based on the Black Scholes formula, it is now possible to get theoretical option prices and greeks for a range of stocks being able to plot charts such as the following:
For example, the following code gets you all Greeks for Tesla.
from financetoolkit import Toolkit
toolkit = Toolkit(["TSLA", "MU"], api_key="FINANCIAL_MODELING_PREP_KEY")
all_greeks = toolkit.options.collect_all_greeks(start_date='2024-01-03')
all_greeks.loc['TSLA', '2024-01-04']
Which returns (Stock Price: 238.45, Volatility: 55.4%, Dividend Yield: 0.0% and Risk Free Rate: 3.91%):
Strike Price | Delta | Dual Delta | Vega | Theta | Rho | Epsilon | Lambda | Gamma | Dual Gamma | Vanna | Charm | Vomma | Vera | Veta | PD | Speed | Zomma | Color | Ultima |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
180 | 1 | -0.9999 | 0 | -0.0193 | 0.4931 | -0.6533 | 4.0782 | 0 | 0 | -0 | 0 | 0 | -0 | 0 | 0 | -0 | 0 | 0 | 0 |
185 | 1 | -0.9999 | 0 | -0.0198 | 0.5068 | -0.6533 | 4.4595 | 0 | 0 | -0 | 0 | 0 | -0 | 0 | 0 | -0 | 0 | 0 | 0 |
190 | 1 | -0.9999 | 0 | -0.0204 | 0.5205 | -0.6533 | 4.9195 | 0 | 0 | -0 | 0 | 0 | -0 | 0 | 0 | -0 | 0 | 0 | 0 |
195 | 1 | -0.9999 | 0 | -0.0209 | 0.5342 | -0.6533 | 5.4853 | 0 | 0 | -0 | 0 | 0 | -0 | 0 | 0 | -0 | 0 | 0 | 0 |
200 | 1 | -0.9999 | 0 | -0.0214 | 0.5479 | -0.6533 | 6.1981 | 0 | 0 | -0 | 0 | 0 | -0 | 0.0012 | 0 | -0 | 0 | 0 | 0 |
205 | 1 | -0.9999 | 0 | -0.022 | 0.5616 | -0.6533 | 7.1239 | 0 | 0 | -0 | 0.0004 | 0.0003 | -0 | 0.1071 | 0 | -0 | 0 | 0.0003 | 0.0001 |
210 | 1 | -0.9999 | 0 | -0.0226 | 0.5753 | -0.6533 | 8.3747 | 0 | 0 | -0.0002 | 0.0199 | 0.0108 | -0.0001 | 4.1973 | 0 | -0 | 0.0001 | 0.012 | 0.0032 |
215 | 0.9998 | -0.9997 | 0.0001 | -0.0252 | 0.5889 | -0.6532 | 10.1567 | 0.0001 | 0.0001 | -0.0041 | 0.414 | 0.1838 | -0.0027 | 72.9841 | 0.0001 | -0 | 0.002 | 0.198 | 0.0324 |
220 | 0.9974 | -0.9971 | 0.001 | -0.0512 | 0.601 | -0.6516 | 12.8704 | 0.0012 | 0.0014 | -0.04 | 4.0384 | 1.3972 | -0.0264 | 580.934 | 0.0014 | -0.0005 | 0.0141 | 1.4208 | 0.1193 |
225 | 0.9783 | -0.9767 | 0.0065 | -0.2027 | 0.6021 | -0.6391 | 17.2415 | 0.0075 | 0.0084 | -0.1863 | 18.7659 | 4.6975 | -0.1235 | 2158.08 | 0.0084 | -0.0022 | 0.0409 | 4.115 | 0.0867 |
230 | 0.8966 | -0.8912 | 0.0224 | -0.6437 | 0.5616 | -0.5857 | 24.2406 | 0.026 | 0.028 | -0.4003 | 40.2357 | 6.3078 | -0.2677 | 3809 | 0.028 | -0.0049 | 0.0261 | 2.5995 | -0.1644 |
235 | 0.6987 | -0.6885 | 0.0435 | -1.2217 | 0.4433 | -0.4565 | 34.5702 | 0.0504 | 0.0519 | -0.3092 | 30.7944 | 2.0098 | -0.2139 | 3626.75 | 0.0519 | -0.004 | -0.0676 | -6.8748 | -0.0997 |
240 | 0.4187 | -0.4074 | 0.0488 | -1.361 | 0.2679 | -0.2735 | 48.191 | 0.0565 | 0.0558 | 0.1652 | -17.2254 | 0.4231 | 0.0945 | 3408.71 | 0.0558 | 0.0014 | -0.0971 | -9.7985 | -0.0227 |
245 | 0.1798 | -0.1722 | 0.0327 | -0.911 | 0.1156 | -0.1174 | 64.4551 | 0.0379 | 0.0359 | 0.4473 | -45.5831 | 5.1158 | 0.2833 | 4082.47 | 0.0359 | 0.0049 | -0.0092 | -0.8794 | -0.1971 |
250 | 0.0534 | -0.0503 | 0.0136 | -0.3769 | 0.0344 | -0.0349 | 82.5525 | 0.0157 | 0.0143 | 0.322 | -32.7 | 6.4816 | 0.2066 | 3305.97 | 0.0143 | 0.0036 | 0.0467 | 4.7605 | -0.0412 |
255 | 0.0108 | -0.01 | 0.0036 | -0.0992 | 0.007 | -0.0071 | 101.798 | 0.0041 | 0.0036 | 0.12 | -12.1728 | 3.4389 | 0.0774 | 1510.91 | 0.0036 | 0.0014 | 0.0324 | 3.2868 | 0.1451 |
260 | 0.0015 | -0.0014 | 0.0006 | -0.017 | 0.001 | -0.001 | 121.702 | 0.0007 | 0.0006 | 0.0266 | -2.6915 | 0.9828 | 0.0172 | 404.445 | 0.0006 | 0.0003 | 0.0101 | 1.0246 | 0.1043 |
265 | 0.0001 | -0.0001 | 0.0001 | -0.002 | 0.0001 | -0.0001 | 141.935 | 0.0001 | 0.0001 | 0.0037 | -0.3769 | 0.1682 | 0.0024 | 66.8956 | 0.0001 | 0 | 0.0018 | 0.1826 | 0.031 |
270 | 0 | -0 | 0 | -0.0002 | 0 | -0 | 162.286 | 0 | 0 | 0.0003 | -0.0349 | 0.0183 | 0.0002 | 7.148 | 0 | 0 | 0.0002 | 0.0203 | 0.0051 |
275 | 0 | -0 | 0 | -0 | 0 | -0 | 182.618 | 0 | 0 | 0 | -0.0022 | 0.0013 | 0 | 0.5115 | 0 | 0 | 0 | 0.0015 | 0.0005 |
280 | 0 | -0 | 0 | -0 | 0 | -0 | 202.841 | 0 | 0 | 0 | -0.0001 | 0.0001 | 0 | 0.0253 | 0 | 0 | 0 | 0.0001 | 0 |
285 | 0 | -0 | 0 | -0 | 0 | -0 | 222.899 | 0 | 0 | 0 | -0 | 0 | 0 | 0.0009 | 0 | 0 | 0 | 0 | 0 |
290 | 0 | -0 | 0 | -0 | 0 | -0 | 242.753 | 0 | 0 | 0 | -0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
295 | 0 | -0 | 0 | -0 | 0 | -0 | 262.382 | 0 | 0 | 0 | -0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
Here, it automatically creates Strike Prices around the current stock price (or any price in the past if you change the start_date) parameter as well as plots forward for the time to expiration. Things that you can change with ease yourself if you like. For example:
from financetoolkit import Toolkit
toolkit = Toolkit(["MSFT", "ASML"], api_key="FINANCIAL_MODELING_PREP_KEY")
rho = toolkit.options.get_rho(
start_date="2020-01-02",
strike_price_range=0.15,
expiration_time_range=20,
put_option=True,
show_input_info=True
)
rho.loc['MSFT']
Which returns:
Based on the period 2013-01-22 to 2024-01-17 the following parameters were used:
Stock Price: ASML (291.79), Benchmark (305.06), MSFT (154.78)
Volatility: ASML (34.77%), Benchmark (17.46%), MSFT (26.99%)
Dividend Yield: MSFT (0.96%), ASML (0.6%)
Risk Free Rate: 1.88%
Strike Price | 2020-01-03 | 2020-01-04 | 2020-01-05 | 2020-01-06 | 2020-01-07 | 2020-01-08 | 2020-01-09 | 2020-01-10 | 2020-01-11 | 2020-01-12 | 2020-01-13 | 2020-01-14 | 2020-01-15 | 2020-01-16 | 2020-01-17 | 2020-01-18 | 2020-01-19 | 2020-01-20 | 2020-01-21 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
130 | -0 | -0 | -0 | -0 | -0 | -0 | -0 | -0 | -0.0001 | -0.0002 | -0.0004 | -0.0008 | -0.0015 | -0.0026 | -0.0041 | -0.0062 | -0.0089 | -0.0124 | -0.0167 |
135 | -0 | -0 | -0 | -0 | -0 | -0.0001 | -0.0003 | -0.001 | -0.0022 | -0.0043 | -0.0076 | -0.0122 | -0.0185 | -0.0265 | -0.0365 | -0.0486 | -0.0629 | -0.0794 | -0.0982 |
140 | -0 | -0 | -0 | -0.0003 | -0.0015 | -0.0045 | -0.0101 | -0.0192 | -0.0322 | -0.0493 | -0.0709 | -0.0968 | -0.1271 | -0.1616 | -0.2003 | -0.2429 | -0.2895 | -0.3397 | -0.3934 |
145 | -0 | -0.0004 | -0.0047 | -0.017 | -0.0396 | -0.0727 | -0.1156 | -0.1676 | -0.2277 | -0.295 | -0.3689 | -0.4486 | -0.5335 | -0.6233 | -0.7174 | -0.8154 | -0.917 | -1.022 | -1.13 |
150 | -0.0055 | -0.0485 | -0.1251 | -0.223 | -0.3353 | -0.4579 | -0.5883 | -0.7249 | -0.8666 | -1.0125 | -1.162 | -1.3145 | -1.4698 | -1.6275 | -1.7873 | -1.949 | -2.1125 | -2.2776 | -2.4442 |
155 | -0.2302 | -0.4512 | -0.671 | -0.8903 | -1.1094 | -1.3284 | -1.5474 | -1.7663 | -1.9853 | -2.2043 | -2.4234 | -2.6425 | -2.8617 | -3.081 | -3.3004 | -3.5198 | -3.7393 | -3.9589 | -4.1785 |
160 | -0.4343 | -0.8348 | -1.2016 | -1.5461 | -1.8754 | -2.1938 | -2.504 | -2.8078 | -3.1063 | -3.4006 | -3.6912 | -3.9787 | -4.2636 | -4.5461 | -4.8265 | -5.1051 | -5.382 | -5.6574 | -5.9314 |
165 | -0.452 | -0.9034 | -1.35 | -1.7871 | -2.2125 | -2.6264 | -3.0295 | -3.4229 | -3.8077 | -4.1848 | -4.5552 | -4.9194 | -5.2782 | -5.6322 | -5.9817 | -6.3272 | -6.6691 | -7.0076 | -7.3431 |
170 | -0.4657 | -0.9314 | -1.397 | -1.8618 | -2.3248 | -2.7846 | -3.2402 | -3.6907 | -4.1358 | -4.5753 | -5.0092 | -5.4376 | -5.8608 | -6.2788 | -6.6921 | -7.1007 | -7.5049 | -7.9051 | -8.3013 |
Furthermore, each module now has it's own dedicated Jupyter Notebook. Find all of them below or on my website here.
This release features the Black Scholes Model, Present Value of Growth Opportunities (PVGO) and a variety of bug fixes.
Starting with the Black Scholes model, I've built in a method that automatically calculates the theoretical options value with strike prices that are near the current stock price and for a lengthy period of time. All of this you can expand yourself if desired with the strike_price_range
, strike_step_size
and expiration_time_range
parameters. By default, the strike prices between 75% and 125% of the current stock price are used and the time to expiration is calculated for the upcoming 30 days.
For example:
from financetoolkit import Toolkit
companies = Toolkit(
tickers=['GOOGL', "MSFT", 'AAPL'],
api_key="FMP_KEY",
start_date='2022-01-01',
end_date='2023-01-01'
)
companies.risk.get_black_scholes_model()
Which returns:
I've also added in the Present Value of Growth Opportunities (PVGO), a metric that uses WACC and Earnings per Share to determine the attractiveness of companies in the near future. This was requested by #88.
from financetoolkit import Toolkit
companies = Toolkit(
tickers=['GOOGL', "MSFT", 'AAPL'],
api_key="FMP_KEY",
quarterly=True
)
companies.models.get_present_value_of_growth_opportunities(calculate_daily=True)
Which returns:
Next to that, #94 noted that the Average Shares got adjusted through currency conversions. This has been corrected. Read in the new Q&A why numbers can sometimes deviate from FinancialModelingPrep.
Happy New Year Everyone 🍾
This release includes an entirely new class which is the Discovery class. This class will help in discovering new instruments that can be inputted directly into the Finance Toolkit for further analysis. Find the documentation here.
For example, by importing the Discovery module directly, it is possible to obtain a large list of companies.
from financetoolkit import Discovery
discovery = Discovery(api_key="FINANCIAL_MODELING_PREP_KEY")
stock_list = discovery.get_stock_list()
# The total list equals over 60.000 rows
stock_list.iloc[48000:48010]
Which returns:
Symbol | Name | Price | Exchange | Exchange Code |
---|---|---|---|---|
RBL.AX | Redbubble Limited | 0.54 | Australian Securities Exchange | ASX |
RBL.BO | Rane Brake Lining Limited | 870.05 | Bombay Stock Exchange | BSE |
RBL.NS | Rane Brake Lining Limited | 870.05 | National Stock Exchange of India | NSE |
RBLAY | Robinsons Land Corporation | 4.61 | Other OTC | PNK |
RBLBANK.BO | RBL Bank Limited | 280.9 | Bombay Stock Exchange | BSE |
RBLBANK.NS | RBL Bank Limited | 280.9 | National Stock Exchange of India | NSE |
RBLN-B.CO | Roblon A/S | 91.8 | Copenhagen | CPH |
RBLX | Roblox Corporation | 45.72 | New York Stock Exchange | NYSE |
RBMNF | Rugby Resources Ltd. | 0.065 | Other OTC | PNK |
RBMS.JK | PT Ristia Bintang Mahkotasejati Tbk | 50 | Jakarta Stock Exchange | JKT |
It also enables stock screeners:
from financetoolkit import Discovery
discovery = Discovery(api_key="FINANCIAL_MODELING_PREP_KEY")
discovery.get_stock_screener(
market_cap_higher=1000000,
market_cap_lower=200000000000,
price_higher=100,
price_lower=200,
beta_higher=1,
beta_lower=1.5,
volume_higher=100000,
volume_lower=2000000,
dividend_higher=1,
dividend_lower=2,
is_etf=False
)
Which returns:
Symbol | Name | Market Cap | Sector | Industry | Beta | Price | Dividend | Volume | Exchange | Exchange Code | Country |
---|---|---|---|---|---|---|---|---|---|---|---|
NKE | NIKE, Inc. | 163403295604 | Consumer Cyclical | Footwear & Accessories | 1.079 | 107.36 | 1.48 | 1045865 | New York Stock Exchange | NYSE | US |
SAF.PA | Safran SA | 66234006559 | Industrials | Aerospace & Defense | 1.339 | 160.16 | 1.35 | 119394 | Paris | EURONEXT | FR |
ROST | Ross Stores, Inc. | 46724188589 | Consumer Cyclical | Apparel Retail | 1.026 | 138.785 | 1.34 | 169879 | NASDAQ Global Select | NASDAQ | US |
HES | Hess Corporation | 44694706090 | Energy | Oil & Gas E&P | 1.464 | 145.51 | 1.75 | 123147 | New York Stock Exchange | NYSE | US |
Which then can be directly inputted into the Finance Toolkit:
from financetoolkit import Toolkit
companies = Toolkit(
tickers=['NKE', 'SAF.PA', 'ROST', 'HES'],
api_key="FINANCIAL_MODELING_PREP_KEY",
)
companies.ratios.get_price_earnings_ratio()
Which returns:
2014 | 2015 | 2016 | 2017 | 2018 | 2019 | 2020 | 2021 | 2022 | 2023 | |
---|---|---|---|---|---|---|---|---|---|---|
HES | 8.4355 | -3.9366 | -2.8064 | -3.3368 | -39.7483 | -79.129 | -5.4733 | 25.1712 | 19.5719 | |
NKE | 29.4181 | 31.0527 | 21.9158 | 23.5325 | 60.6729 | 39.2127 | 86.2596 | 45.9014 | 30.8813 | 33.6161 |
ROST | 19.5859 | 19.8813 | 21.7047 | 21.3971 | 18.6637 | 24.4335 | 493.771 | 22.9419 | 26.2563 | |
SAF.PA | -152.997 | -57.6348 | 14.3119 | 7.1287 | 34.6723 | 24.0264 | 142.461 | 686.616 | -21.0077 |
Next to that, I've also grouped the TQDM statements when using Ratios or Models. So instead of 5 bars, it displays just 2. Furthermore, I've extended the custom ratios functionality, see here.
Added a lot more economic metrics (over 50) into the Finance Toolkit, find the total list here. For example, get insights into how the United States Government spend their income:
from financetoolkit import Economics
economics = Economics()
central_government_spending = economics.get_central_government_spending()
central_government_spending['United States']
Which returns:
General Public Services | Defence | Public Order and Safety | Economic Affairs | Environmental Protection | Housing and Community Amenities | Health | Recreation, Culture and Religion | Education | Social Protection | |
---|---|---|---|---|---|---|---|---|---|---|
2007 | 0.1578 | 0.186 | 0.0148 | 0.0578 | 0 | 0.0192 | 0.2486 | 0.0015 | 0.0222 | 0.2921 |
2008 | 0.1392 | 0.1861 | 0.0148 | 0.069 | 0 | 0.0188 | 0.2369 | 0.0014 | 0.0221 | 0.3117 |
2009 | 0.1198 | 0.1772 | 0.0148 | 0.0639 | 0 | 0.0406 | 0.2417 | 0.0014 | 0.028 | 0.3127 |
2010 | 0.1211 | 0.1759 | 0.0148 | 0.0585 | 0 | 0.0309 | 0.2416 | 0.0015 | 0.0346 | 0.3211 |
2011 | 0.1324 | 0.1754 | 0.0149 | 0.0562 | 0 | 0.0271 | 0.2416 | 0.0014 | 0.0337 | 0.3173 |
2012 | 0.1348 | 0.173 | 0.0154 | 0.056 | 0 | 0.0216 | 0.2491 | 0.0014 | 0.0296 | 0.3191 |
2013 | 0.1333 | 0.162 | 0.0145 | 0.055 | 0 | 0.0172 | 0.2589 | 0.0013 | 0.0281 | 0.3296 |
2014 | 0.135 | 0.1525 | 0.0143 | 0.0524 | 0 | 0.0168 | 0.2765 | 0.0013 | 0.0269 | 0.3244 |
2015 | 0.1294 | 0.1461 | 0.0141 | 0.0473 | 0 | 0.0161 | 0.2919 | 0.0012 | 0.026 | 0.3279 |
2016 | 0.1321 | 0.141 | 0.0141 | 0.0526 | 0 | 0.0156 | 0.2952 | 0.0013 | 0.0244 | 0.3238 |
2017 | 0.1325 | 0.1408 | 0.0137 | 0.0526 | 0 | 0.0171 | 0.2961 | 0.0013 | 0.0233 | 0.3226 |
2018 | 0.1407 | 0.1427 | 0.0135 | 0.0519 | 0 | 0.014 | 0.2967 | 0.0012 | 0.0226 | 0.3165 |
2019 | 0.1417 | 0.1461 | 0.013 | 0.052 | 0 | 0.0133 | 0.2971 | 0.0012 | 0.021 | 0.3147 |
Or plotted:
Or see the Income Inequality in the Netherlands:
from financetoolkit import Toolkit
toolkit = Toolkit("MSFT")
income_inequality = toolkit.economics.get_income_inequality()
income_inequality['Netherlands']
Which returns:
Gini Coefficient | P90/P10 | P90/P50 | P50/P10 | Palma Ratio | S80/S20 | |
---|---|---|---|---|---|---|
2013 | 0.287 | 3.4 | 1.8 | 1.9 | 1.05 | 4.3 |
2014 | 0.305 | 3.4 | 1.8 | 1.9 | 1.16 | 4.6 |
2015 | 0.305 | 3.4 | 1.8 | 1.9 | 1.06 | 4.4 |
2016 | 0.292 | 3.4 | 1.8 | 1.9 | 1.07 | 4.4 |
2017 | 0.298 | 3.4 | 1.8 | 1.9 | 1.11 | 4.5 |
2018 | 0.295 | 3.3 | 1.8 | 1.9 | 1.09 | 4.4 |
2019 | 0.312 | 3.4 | 1.8 | 1.9 | 1.21 | 4.7 |
2020 | 0.295 | 3.3 | 1.8 | 1.9 | 1.09 | 4.4 |
2021 | 0.297 | 3.4 | 1.8 | 1.9 | 1.1 | 4.5 |
Or plotted:
And so much more!
In addition to the many new Economics indicators in the previous release, I've added some new key economic rates.
I've added in the European Central Banks which include:
These can be shown by using:
from financetoolkit import Economics
economics = Economics(start_date='2000-01-01')
economics.get_european_central_bank_rates()
Which returns (when plotted):
I've also added in the Federal Funds rates which include:
These can be shown by using (and defining the rate):
from financetoolkit import Economics
economics = Economics(start_date='2016-01-01')
# Effective Federal Funds Rate
economics.get_federal_reserve_rates(rate='EFFR')
# Secured Overnight Financing Rate
economics.get_federal_reserve_rates(rate='SOFR')
Which returns (when plotted):
This release features an entirely new module called Economics
. This is meant to collect key economic indicators such as the Gross Domestic Product (GDP), Consumer Price Index (CPI) and Long and Short Term Interest Rates for 60+ countries. Find a complete overview here. This module can be called via the Toolkit:
from financetoolkit import Toolkit
companies = Toolkit(tickers=["AAPL", "TSLA"], api_key="FMP_KEY")
companies.economics.get_house_prices()
But also as standalone module (given that it doesn't require a company ticker):
from financetoolkit import Economics
economics = Economics()
economics.get_house_prices()
Both return the same dataset:
Australia | Austria | Belgium | Brazil | Bulgaria | Canada | Chile | China | Colombia | Croatia | Czech Republic | Denmark | EA | Estonia | Euro Area 17 | Finland | France | Germany | Greece | Hungary | Iceland | India | Indonesia | Ireland | Israel | Italy | Japan | Latvia | Lithuania | Luxembourg | Mexico | Netherlands | New Zealand | Norway | OECD - Total | Poland | Portugal | Romania | Russia | Saudi Arabia | Slovakia | Slovenia | South Africa | South Korea | Spain | Sweden | Switzerland | Turkey | United Kingdom | United States | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
2013 | 84.1065 | 92.1 | 98.962 | 98.269 | 95.915 | 89.9958 | 78.0367 | 96.4912 | 85.1748 | 104.627 | 93.875 | 90.0977 | 98.267 | 82.2933 | 98.4009 | 100.353 | 103.8 | 92.5982 | 113.816 | 84.87 | 85.2075 | 76.6863 | 88.5178 | 77.0045 | 88.8228 | 109.1 | 96.148 | 97.6225 | 90.645 | 90.8947 | 88.6885 | 95.7715 | 83.5338 | 91.75 | 92.1431 | 97.4165 | 93.085 | 99.26 | 95.574 | nan | 93.5868 | 106.21 | 87.4525 | 95.7696 | 96.2393 | 80.785 | 94.867 | 75.946 | 87.3505 | 90.7087 |
2014 | 91.7202 | 95.33 | 98.417 | 99.1345 | 97.29 | 94.828 | 88.4455 | 101.132 | 91.9212 | 102.975 | 96.175 | 93.4987 | 98.482 | 93.5795 | 98.5693 | 99.995 | 101.925 | 95.499 | 105.32 | 88.4275 | 92.3855 | 88.032 | 94.73 | 89.7232 | 94.4668 | 103.95 | 97.648 | 103.475 | 96.47 | 94.8777 | 92.4655 | 96.5565 | 88.9588 | 94.25 | 95.5783 | 98.4538 | 97.0375 | 97.22 | 97.9095 | 101.189 | 94.9068 | 99.2025 | 94.146 | 97.2716 | 96.5393 | 88.4025 | 97.4497 | 86.1545 | 94.3388 | 95.1076 |
2015 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 |
2016 | 105.5 | 108.532 | 102.641 | 100.868 | 107.02 | 110.589 | 106.573 | 112.23 | 109.995 | 100.888 | 107.15 | 104.727 | 104.01 | 104.745 | 104.012 | 101.285 | 100.925 | 107.527 | 97.623 | 113.377 | 109.767 | 106.686 | 103.159 | 107.484 | 107.459 | 100.25 | 102.213 | 108.487 | 105.4 | 106.006 | 107.282 | 105.052 | 114.178 | 107.025 | 105.352 | 101.859 | 107.115 | 105.95 | 102.856 | 95.091 | 106.703 | 103.252 | 105.616 | 101.622 | 104.623 | 108.243 | 101.627 | 113.615 | 106.975 | 105.586 |
2017 | 114.308 | 114.26 | 106.373 | 101.733 | 116.295 | 123.751 | 115.275 | 126.989 | 117.332 | 104.745 | 119.7 | 109.378 | 108.513 | 110.511 | 108.454 | 102.388 | 103.975 | 114.104 | 96.6342 | 127.24 | 131.196 | 115.658 | 106.415 | 119.162 | 111.649 | 99.175 | 104.805 | 118.013 | 114.797 | 111.96 | 115.687 | 112.978 | 121.596 | 112.35 | 111.13 | 105.768 | 117.015 | 112.355 | 108.782 | 88.9675 | 112.99 | 111.785 | 110.064 | 102.854 | 111.105 | 115.427 | 103.591 | 125.392 | 111.834 | 112.078 |
2018 | 112.664 | 119.64 | 109.415 | 102.599 | 123.955 | 128.378 | 126.812 | 134.268 | 123.825 | 111.14 | 130 | 114.529 | 113.668 | 117.066 | 113.604 | 103.335 | 107.15 | 121.681 | 98.379 | 145.495 | 142.006 | 122.248 | 109.895 | 131.363 | 110.724 | 98.625 | 106.849 | 129.3 | 123.18 | 119.862 | 125.951 | 123.656 | 125.966 | 113.975 | 116.592 | 112.765 | 129.032 | 118.618 | 116.147 | 86.4625 | 121.32 | 121.547 | 114.246 | 104.275 | 118.58 | 114.35 | 106.728 | 134.891 | 115.496 | 118.951 |
2019 | 108.084 | 126.6 | 113.779 | 103.464 | 131.417 | 129.959 | 137.5 | 139.503 | 130.601 | 121.103 | 141.9 | 117.53 | 118.641 | 125.267 | 118.505 | 103.77 | 110.675 | 128.707 | 105.481 | 170.167 | 148.291 | 126.309 | 111.91 | 134.431 | 112.812 | 98.525 | 108.553 | 140.875 | 131.61 | 131.987 | 136.739 | 132.658 | 129.9 | 116.8 | 121.327 | 122.55 | 141.882 | 122.69 | 119.822 | 83.5023 | 132.395 | 129.69 | 118.273 | 103.968 | 124.715 | 117.188 | 110.572 | 141.024 | 116.592 | 124.942 |
2020 | 113.916 | 136.311 | 118.595 | 104.332 | 137.412 | 138.454 | 146.659 | 144.577 | 133.834 | 130.38 | 153.85 | 123.531 | 124.813 | 132.792 | 124.761 | 105.595 | 116.825 | 138.685 | 110.223 | 178.577 | 157.788 | 129.465 | 113.646 | 134.847 | 116.261 | 100.4 | 108.63 | 145.768 | 141.178 | 151.115 | 144.687 | 142.761 | 143.109 | 121.775 | 128.945 | 135.335 | 154.327 | 128.435 | 144.26 | 84.833 | 145.061 | 135.657 | 121.228 | 107.451 | 127.505 | 122.11 | 115.355 | 173.709 | 119.904 | 134.761 |
2021 | 133.764 | 153.262 | 127.058 | 105.198 | 149.333 | 159.222 | 164.029 | 150.101 | 141.909 | 139.912 | 184.225 | 138.01 | 134.675 | 152.778 | 134.765 | 110.448 | 124.625 | 154.739 | 118.606 | 208.037 | 177.563 | 132.749 | 115.27 | 146 | 126.076 | 102.95 | 115.102 | 161.645 | 163.84 | 172.151 | 156.073 | 164.241 | 180.981 | 134.525 | 145.113 | 147.76 | 168.84 | 134.088 | 175.268 | 85.7263 | 154.334 | 151.317 | 126.269 | 116.89 | 132.195 | 134.463 | 123.334 | 237.534 | 130.515 | 157.24 |
2022 | 142.65 | 170.765 | 134.194 | 106.063 | 169.917 | 177.235 | 175.906 | 151.385 | 152.542 | 160.685 | 215.275 | 137.36 | 144.219 | 186.76 | 144.178 | 111.745 | 132.5 | 162.941 | 132.69 | 254.345 | 214.848 | 136.925 | nan | 163.977 | 147.852 | 106.875 | 124.755 | 184.005 | 195.048 | 188.6 | 169.973 | 186.321 | 182.022 | 141.575 | 165.45 | 165.18 | 190.17 | 143.697 | 225.506 | 87.5558 | 175.471 | 173.648 | 130.758 | 119.32 | 141.978 | 139.25 | 132.603 | 601.714 | 143.214 | 179.097 |
It is also possible to plot things such as the Employment Rate as also found in the README:
Or the Long Term (10 year) and Short Term (3 month) Interest Rates:
Or any of the other metrics:
Are you looking for any specific economic parameter? Let me know and I'll start working on it.
This releases introduces the GARCH model including volatility forecasting. Next to that, it includes a bugfix for the currency conversion.
Designed by @northern-64bit (LinkedIn) in #82, this release introduces GARCH (Generalized autoregressive conditional heteroskedasticity) which is stochastic model for time series, which is for instance used to model volatility clusters, stock return and inflation. It is a generalisation of the ARCH models.
It can be found inside the risk
module and can be ran with the following code:
from financetoolkit import Toolkit
toolkit = Toolkit(["AMZN", "TSLA"], api_key=FMP_KEY)
toolkit.risk.get_garch()
Which produces the following result:
Date | AMZN | TSLA | Benchmark |
---|---|---|---|
2012 | 0 | 0 | 0 |
2013 | 0.2038 | 5.027 | 0.024 |
2014 | 0.4016 | 10.2307 | 0.0537 |
2015 | 0.53 | 13.2345 | 0.0688 |
2016 | 0.7664 | 15.6152 | 0.079 |
2017 | 0.8181 | 17.5204 | 0.0887 |
2018 | 0.8896 | 19.0642 | 0.0997 |
2019 | 0.9235 | 20.2789 | 0.104 |
2020 | 0.9479 | 21.2567 | 0.1169 |
2021 | 1.0203 | 27.5585 | 0.1209 |
2022 | 1.0201 | 27.0986 | 0.129 |
2023 | 1.0445 | 26.7482 | 0.1305 |
You can also forecast in the future for any period and for any interval. For example, the quarterly expected volatility estimations can be shown with:
from financetoolkit import Toolkit
toolkit = Toolkit(["AMZN", "TSLA"], api_key=FMP_KEY)
toolkit.risk.get_garch_forecast(period='quarterly')
Which returns:
AMZN | TSLA | Benchmark | |
---|---|---|---|
2024Q1 | 0 | 0 | 0 |
2024Q2 | 0 | 0 | 0 |
2024Q3 | 0.006 | 0.3185 | 0.0003 |
2024Q4 | 0.0114 | 0.6051 | 0.0006 |
2025Q1 | 0.0162 | 0.8631 | 0.0008 |
2025Q2 | 0.0206 | 1.0953 | 0.001 |
2025Q3 | 0.0245 | 1.3042 | 0.0012 |
2025Q4 | 0.0281 | 1.4923 | 0.0014 |
2026Q1 | 0.0312 | 1.6615 | 0.0015 |
2026Q2 | 0.0341 | 1.8138 | 0.0017 |
Next to that, a bug fix went in related to the currency conversions which makes it more robust when there is data missing. If you didn't know, when you have a Premium FMP plan the Finance Toolkit will now automatically convert currencies that do not match up with the historical data. For more see here: https://github.com/JerBouma/FinanceToolkit/releases/tag/v1.6.3