Skip to content

FinanceToolkit v1.6.3

Compare
Choose a tag to compare
@JerBouma JerBouma released this 04 Dec 16:52
· 328 commits to main since this release

This release features currency conversions. A user noticed that the financial statements are not always in the expected currency (different from the historical data):

image

This could lead to confusion when comparing numbers between companies and or when calculating ratios that require both data from the financial statement and the historical market data. This has now been resolved with an automatic converter that converts the financial statements accordingly. With this, the end of quarter or end of year exchange rate is used.

image

This is also saved in a seperate function called get_exchange_rates as shown below:

image

This is quite a major change given that there are plenty of financial statements that report their financial statements in their local currency while the listed historical prices are in USD. This ensures that those numbers can be compared. This can be disabled by setting convert_currency to False in the Toolkit initialisation. Note that by default it is automatically turned off when using the Free plan of FinancialModelingPrep as it could drain the API calls for that specific day.

I've also added in a parameter that recognises if you are using a Free or Premium plan from FinancialModelingPrep. This is a dependency for the sleep_timer which will wait a maximum of 60 seconds before making a new request to FMP. This is only relevant for the Premium plans since there is a rate limit per minute. For the Free plan it doesn't matter given that you are limited to 250 requests per day. In any case, this should make the Free experience smoother since you are not waiting for no reason. This solves #80.

Note: this consumes 1 API call so if you don't want that, just set sleep_timer to True or False.

if sleep_timer is None:
    # This tests the API key to determine the subscription plan. This is relevant for the sleep timer
    # but also for other components of the Toolkit. This prevents wait timers from occurring while
    # it wouldn't result to any other answer than a rate limit error.
    determine_plan = helpers.get_financial_data(
        url=f"https://financialmodelingprep.com/api/v3/income-statement/AAPL?period=quarter&apikey={api_key}",
        sleep_timer=False,
    )

    self._fmp_plan = "Premium"

    for option in ["NOT AVAILABLE", "LIMIT REACH", "INVALID API KEY"]:
        if option in determine_plan:
            self._fmp_plan = "Free"
            break
else:
    self._fmp_plan = "Premium"