pydeflate.get_data.exchange_data

Classes

Exchange

An abstract class to update, load and return exchange rate data.

ExchangeOECD

The OECD exchange rate data

ExchangeWorldBank

The World Bank exchange rate data

ExchangeIMF

The IMF exchange rate data

Functions

_exchange_ratio(→ pandas.DataFrame)

_calculate_deflator(→ pandas.DataFrame)

Module Contents

pydeflate.get_data.exchange_data._exchange_ratio(source_xe: pandas.DataFrame, target_xe: pandas.DataFrame) pandas.DataFrame
pydeflate.get_data.exchange_data._calculate_deflator(xe: pandas.DataFrame, base_year: int) pandas.DataFrame
class pydeflate.get_data.exchange_data.Exchange

Bases: abc.ABC

An abstract class to update, load and return exchange rate data.

method

the method to use to calculate the exchange rate.

method: str | None
_data: pandas.DataFrame | None = None
abstract update(**kwargs) None

Update underlying data

abstract load_data(**kwargs) None

Load required data to construct deflator

abstract usd_exchange_rate(direction: str = 'lcu_to_uds') pandas.DataFrame

Get the exchange rate of a currency to USD (or vice versa)

Parameters:
  • direction – the direction of the exchange rate. Either “lcu_to_usd”

  • "usd_to_lcu". (or)

Returns:

A dataframe with the exchange rate of the currency to USD (or vice versa).

exchange_rate(currency_iso: str) pandas.DataFrame

Get an exchange rate for a given ISO

Parameters:

currency_iso – the iso_code of the currency to get the exchange rate for.

Returns:

A dataframe with the exchange rate for the specified currency.

exchange_deflator(source_iso: str, target_iso: str, base_year: int) pandas.DataFrame

Get an exchange rate deflator for a given ISO

Parameters:
  • source_iso – the iso_code in which the “original” data is based. The default should be “LCU”.

  • target_iso – the iso_code of the currency to get the exchange rate for.

  • base_year – the base year to calculate the deflator.

Returns:

A dataframe with the exchange rate deflator for the specified currency.

class pydeflate.get_data.exchange_data.ExchangeOECD

Bases: Exchange

The OECD exchange rate data

method

the method to use to calculate the exchange rate. For this source,

the only valid method is “implied”.
method: str = 'implied'
_load_try_count: int = 0
static update(**kwargs) None

Update the DAC1 data, which is the source for the OECD exchange rates.

load_data(**kwargs) None

Load the OECD DAC price deflators data.

If the data is not found, it will be downloaded. DAC deflators are transformed into price deflators by using the implied exchange rate information from the OECD DAC data.

The deflators that are loaded is therefore not the DAC deflator, but the price deflator used to produce the DAC deflators.

usd_exchange_rate(direction: str = 'lcu_usd') pandas.DataFrame

Get the exchange rate of a currency to USD (or vice versa)

Parameters:
  • direction – the direction of the exchange rate. Either “lcu_to_usd”

  • "usd_to_lcu". (or)

Returns:

A dataframe with the exchange rate of the currency to USD (or vice versa).

class pydeflate.get_data.exchange_data.ExchangeWorldBank

Bases: Exchange

The World Bank exchange rate data

method

the method to use to calculate the exchange rate. For this source,

the valid methods are "yearly_average" and "effective_exchange".
method: str = 'yearly_average'
_load_try_count: int = 0
__post_init__()

Check that the method is valid

update() None

Update the World Bank data

load_data(**kwargs) None

Load the World Bank data

usd_exchange_rate(direction: str = 'lcu_usd') pandas.DataFrame

Get the exchange rate of a currency to USD (or vice versa)

Parameters:
  • direction – the direction of the exchange rate. Either “lcu_to_usd”

  • "usd_to_lcu". (or)

Returns:

A dataframe with the exchange rate of the currency to USD (or vice versa).

class pydeflate.get_data.exchange_data.ExchangeIMF

Bases: Exchange

The IMF exchange rate data

method

the method to use to calculate the exchange rate. For this source,

the only valid method is “implied”.
method: str = 'implied'
_imf: pydeflate.get_data.imf_data.IMF | None = None
__post_init__()

Load an IMF object to manage getting the data

update(**kwargs) None

Update the IMF data

load_data(**kwargs) None

Load the IMF data

usd_exchange_rate(direction: str = 'lcu_usd') pandas.DataFrame

Get the exchange rate of a currency to USD (or vice versa)

Parameters:
  • direction – the direction of the exchange rate. Either “lcu_to_usd”

  • "usd_to_lcu". (or)

Returns:

A dataframe with the exchange rate of the currency to USD (or vice versa).