This functionality looks at the exchange rates between the currency of the historical data and the currency of the financial statements. Given that these can deviate from each other, e.g. the historical data is in USD but the financial statements are in EUR, it is important to adjust for this. This is especially relevant for models that use the historical data and the financial statements.

This function therefore shows the exchange rates that are used to convert the financial statements to the currency of the historical data. The historical market data is quote currency and the financial statements are base currency.

Note that you can get currency data from any currency as well by supplying the currency as a ticker. For example, if you want to get the exchange rates between USD and EUR you can use USDEUR=X as a ticker.

Important to note is that when an api_key is included in the Toolkit initialization that the data collection defaults to FinancialModelingPrep which is a more stable source and utilises your subscription. However, if this is undesired, it can be disabled by setting enforce_source to “YahooFinance”. If data collection fails from FinancialModelingPrep it automatically reverts back to YahooFinance.

Also known as: currency exchange, FX rates, foreign exchange rates.

Exchange Rates in Python

get_exchange_rates is part of the Toolkit module of the open-source Finance Toolkit. Install it with:

pip install financetoolkit -U

Then call get_exchange_rates as shown below.

from financetoolkit import Toolkit

toolkit = Toolkit("ASML", api_key="FINANCIAL_MODELING_PREP_KEY")

toolkit.get_exchange_rates(period="monthly")

Which returns:

Date Open High Low Close Adj Close Volume Return Cumulative Return
2023-03 1.0905 1.0926 1.0861 1.0905 1.0905 0 0.0277 0.7896
2023-04 1.1011 1.1037 1.0963 1.0969 1.0969 131812 0.0059 0.7943
2023-05 1.0693 1.0771 1.066 1.076 1.0733 162069 -0.0215 0.7772
2023-06 1.09 1.09 1.08 1.09 1.0868 0 0.0126 0.787
2023-07 1.0996 1.102 1.0952 1.1007 1.1024 183278 0.0144 0.7983
2023-08 1.0842 1.0882 1.077 1.0796 1.09 171695 -0.0112 0.7893
2023-09 1.06 1.06 1.06 1.06 1.06 0 -0.0275 0.7676
2023-10 1.0614 1.0674 1.0556 1.0578 1.0615 184667 0.0014 0.7686
2023-11 1.0973 1.0984 1.0878 1.0892 1.0974 173646 0.0338 0.7946
2023-12 1.088 1.0898 1.0848 1.0871 1.0871 90494 -0.0094 0.7872

Parameters

get_exchange_rates accepts the following parameters:

  • period (str): The interval at which the historical data should be returned - daily, weekly, monthly, quarterly, or yearly. Defaults to “daily”.
  • return_column (str): The column to use for the return calculation. Defaults to “Adj Close”.
  • fill_nan (bool): Defines whether to forward fill NaN values. This defaults to True to prevent holes in the dataset. This is especially relevant for technical indicators.
  • overwrite (bool): Defines whether to overwrite the existing data.
  • rounding (int): Defines the number of decimal places to round the data to.
  • show_ticker_seperation (bool, optional): A boolean representing whether to show which tickers acquired data from FinancialModelingPrep and which tickers acquired data from YahooFinance.
Share