Skip to content

Releases: JerBouma/FinanceToolkit

FinanceToolkit v2.0.0

01 Mar 17:31
Compare
Choose a tag to compare

It has been a long time since I made a significant update as I was working on the v2.0.0 of the Finance Toolkit featuring numerous improvements to the code as well as major new additions.

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:

image

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:

image

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:

image

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.

image

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.

image

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

image

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.

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:

image

FinanceToolkit v1.9.9

12 Dec 18:21
Compare
Choose a tag to compare

Functionality for the Economics menu broke due to the fact I forgot to include headers into my request towards OECD, thanks for reporting #162. Furthermore, the Close and Adj Close price were the same for data acquired from Yahoo Finance, this has now been fixed and is correct. I've also suppressed Yahoo Finance logging messages as I'll handle all of it myself as well.

FinanceToolkit v1.9.8

29 Sep 09:35
Compare
Choose a tag to compare

This release features a fix to issues with Yahoo Finance which is used as a fallback whenever FinancialModelingPrep doesn't have the data or because your plan limits you from accessing this data. E.g. if you have the Free plan you can only get historical data on U.S. listed stocks so all other historical data comes from Yahoo Finance. I used to directly query from Yahoo Finance myself but given that it can break over time, it makes more sense to add in an optional dependency (yfinance). This means that by default this dependency is not installed given that the Finance Toolkit doesn't have to rely on this package if you have the proper FMP plan.

This is what I am referring to (see "The following tickers acquired historical data..")

image

In case you've used pip install financetoolkit -U in a new environment you will receive the following message when you have a Free plan and try to download data on stocks not on U.S. exchanges:

image

As can be read, this can be resolved by using pip install 'financetoolkit[yfinance]' as shown below:

image

FinanceToolkit v1.9.6

07 Sep 12:52
Compare
Choose a tag to compare

The last couple of releases were all minor bugfixes therefore it didn't merit a proper release. However, for this one quite a fix things under the hood have changed entirely inside the Economy menu. Given that OECD recently updated their databases, all of the original links broke and therefore needed fixing. This unfortunately also resulted in some functionality being scrapped given that the datapoints were archived altogether.

Furthermore, I am aware of issues with Yahoo Finance's data download. You won't notice any to this when using an API Key from FMP but if you don't, I had built a fallback method that went to Yahoo Finance. Given that Yahoo Finance doesn't officially support the collection of data for now this functionality within the Finance Toolkit won't function (it will return 0s). I have still to consider whether to remove the functionality altogether or come up with a fix (however given that it is unofficial, things can break at any time again). Given that the package yfinance exists, I might introduce it as an add-on if you still wish to have this functionality.

Please let me know if you do.

FinanceToolkit v1.9.0

29 Apr 20:17
d5dac40
Compare
Choose a tag to compare

The release of the Finance Toolkit v1.9.0 includes an entirely new Fixed Income module. This module contains a wide variety of fixed income related calculations such as the Effective Yield, the Macaulay Duration, the Modified Duration Convexity, the Yield to Maturity and models such as Black and Bachelier to valuate derivative instruments such as Swaptions.

For example, it is possible to perform Bond Calculations with collect_bond_statistics which can valuate a variety of bonds based on used input:

Bond 1 Bond 2 Bond 3 Bond 4 Bond 5 Bond 6
Par Value 100 250 50 1000 85 320
Coupon Rate 0.05 0.02 0.075 0 0.15 0.015
Years to Maturity 5 10 2 10 3 1
Yield to Maturity 0.08 0.021 0.03 0 0.16 0.04
Frequency 1 1 4 1 2 12
Present Value 88.0219 247.766 54.3518 1000 83.0353 312.171
Current Yield 0.0568 0.0202 0.069 0 0.1535 0.0154
Effective Yield 0.05 0.02 0.0771 0 0.1556 0.0151
Macaulay's Duration 4.5116 9.1576 1.8849 10 2.5667 0.9932
Modified Duration 4.1774 8.9693 1.8709 10 2.3766 0.9899
Effective Duration 4.0677 8.5181 1.8477 9.4713 2.2952 0.9844
Dollar Duration 3.677 22.2228 1.0168 100 1.9734 3.0902
DV01 0.0004 0.0022 0 0.01 0.0001 0
Convexity 22.4017 93.7509 4.0849 110 7.0923 1.0662

This can be done with the following code:

from financetoolkit import FixedIncome

fixedincome = FixedIncome()

# Valuate a specific bond, for example Bond 1
fixedincome.collect_bond_statistics(
    par_value=100,
    coupon_rate=0.05,
    years_to_maturity=5,
    yield_to_maturity=0.08,
    frequency=1,
)

Not only Bonds can be valuated, the module can also be used to valudate derivatives such as Swaptions utilizing the Black and Bachelier models. For example, the Black model can be used to valuate a Swaption:

from financetoolkit import FixedIncome

fixedincome = FixedIncome()

# You can also provide lists of values for the strike rate and years to maturity
# to define your own strike rates and years to maturity to display in the DataFrame
fixedincome.get_derivative_price(model_type='black', forward_rate=0.0325)

This returns a large DataFrame that shows the present value of such a swaption contract at a variety of strike rates and maturities.

Strike Rate 2025-04-21 2026-04-21 2027-04-21 2028-04-20 2029-04-20 2030-04-20 2031-04-20 2032-04-19 2033-04-19 2034-04-19
0.005 0 0 0 0 0 0 0 0 0 0
0.01 0 0 0 0 0 0 0 0 0 0
0.015 0 0 0 0 0 0 0 0 0 0
0.02 0 0 0 0 0 0 0 0 0 0
0.025 0 0 0 0 0 0 0 0 0 0
0.03 0 0 0 0.04 0.25 0.9 2.3 4.68 8.22 12.98
0.035 24200.6 23426.7 22677.6 21952.5 21251.2 20573.2 19918.5 19286.4 18676.5 18088
0.04 72601.7 70280.1 68032.7 65857.2 63751.2 61712.6 59739.2 57828.9 55979.6 54189.6
0.045 121003 117133 113388 109762 106252 102854 99565.3 96381.4 93299.4 90315.9
0.05 169404 163987 158743 153667 148753 143996 139391 134934 130619 126442
0.055 217805 210840 204098 197571 191254 185138 179218 173487 167939 162569
0.06 266206 257694 249453 241476 233754 226280 219044 212039 205259 198695
0.065 314607 304547 294808 285381 276255 267421 258870 250592 242578 234821
0.07 363008 351400 340163 329286 318756 308563 298696 289144 279898 270948
0.075 411410 398254 385518 373191 361257 349705 338522 327697 317218 307074
0.08 459811 445107 430874 417095 403758 390846 378348 366250 354538 343200
0.085 508212 491960 476229 461000 446258 431988 418174 404802 391858 379327
0.09 556613 538814 521584 504905 488759 473130 458000 443355 429177 415453
0.095 605014 585667 566939 548810 531260 514272 497827 481907 466497 451580
0.1 653415 632521 612294 592714 573761 555413 537653 520460 503817 487706
0.105 701816 679374 657649 636619 616262 596555 577479 559012 541137 523832
0.11 750217 726227 703004 680524 658762 637697 617305 597565 578456 559959
0.115 798619 773081 748359 724429 701263 678839 657131 636118 615776 596085
0.12 847020 819934 793715 768334 743764 719980 696957 674670 653096 632211
0.125 895421 866787 839070 812238 786265 761122 736783 713223 690416 668338
0.13 943822 913641 884425 856143 828766 802264 776609 751775 727735 704464

It is also possible to access Government Bond rates from 30+ countries. For example, using get_government_bond_yields(short_term=False, period='monthly'):

Australia Austria Belgium Brazil Bulgaria Canada Chile China Colombia Costa Rica Croatia Czech Republic Denmark Estonia Euro Area 19 Finland France Germany Greece Hungary Iceland India Indonesia Ireland Israel Italy Japan Latvia Lithuania Luxembourg Mexico Netherlands New Zealand Norway Poland Portugal Romania Russia Slovakia Slovenia South Africa South Korea Spain Sweden Switzerland United Kingdom United States
2023-05 0.035 0.0303 0.0304 0.0728 0.0403 0.0305 0.0555 0.0269 0.1111 nan 0.0371 0.045 0.0254 0.0394 0.0321 0.0298 0.0294 0.0234 0.0398 0.0778 nan 0.0701 0.0636 0.0279 0.0379 0.0431 0.0043 0.0383 0.0288 0.0295 0.0876 0.0273 0.0423 0.0323 0.0593 0.0316 0.063 nan 0.0359 0.0315 0.1194 0.034 0.0341 0.0232 0.0085 0.0396 0.0357
2023-06 0.0392 0.0305 0.0305 0.0728 0.0403 0.0334 0.0531 0.0264 0.1015 nan 0.0373 0.0435 0.0257 0.0394 0.0316 0.03 0.0293 0.0238...
Read more

FinanceToolkit v1.8.5

02 Apr 15:53
Compare
Choose a tag to compare

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):

image

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 #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.

FinanceToolkit v1.8.3

04 Feb 12:39
Compare
Choose a tag to compare

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.

Binomial Tree

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).

image

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:

image

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.

image

FinanceToolkit v1.8.1

22 Jan 17:04
b863aa9
Compare
Choose a tag to compare

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:

image

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):

image

Furthermore, I've fixed small bugs, updated the documentation and more. All in all it should be a more pleasant experience!

FinanceToolkit v1.8.0

17 Jan 16:33
Compare
Choose a tag to compare

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:

image

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.23...
Read more

FinanceToolkit v1.7.4

05 Jan 15:25
Compare
Choose a tag to compare

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:

image

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:

image

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.