Skip to content

PolicyRatesReader

PolicyRatesReader

Reader class for central bank policy rates data.

This class handles reading and processing of policy rates from various central banks. It supports special cases for certain countries and provides default rates where necessary.

Parameters:

Name Type Description Default
path Path | str

Path to the main policy rates CSV file

required
country_code_path Path | str

Path to the country code mappings CSV file

required

Attributes:

Name Type Description
path Path

Path to the policy rates data

df DataFrame

Main policy rates DataFrame

c_map DataFrame

Country code mapping DataFrame

path = path instance-attribute
df = pd.read_csv(path, engine='pyarrow') instance-attribute
c_map = pd.read_csv(country_code_path) instance-attribute
__init__(path: Path | str, country_code_path: Path | str)

Initialize the PolicyRatesReader with data and country code paths.

get_policy_rates(country: Country | str | Region) -> pd.DataFrame

Get policy rates for a specific country.

Parameters:

Name Type Description Default
country Country | str

Country to get rates for, either as Country object or ISO 3-letter code

required

Returns:

Type Description
DataFrame

pd.DataFrame: DataFrame with dates as index and policy rates as values, rates are in decimal form

Note
  • For EU countries, returns ECB rates
  • Special handling for Costa Rica and Singapore
  • Uses default rates for certain countries
  • Returns quarterly data
singapore_rates()

Get Singapore policy rates from a separate data file.

Returns:

Type Description

pd.DataFrame: DataFrame with dates as index and Singapore policy rates as values, rates are in decimal form

Note

Uses SORA (Singapore Overnight Rate Average) data

costa_rica_rates()

Get Costa Rica policy rates from a separate data file.

Returns:

Type Description

pd.DataFrame: DataFrame with dates as index and Costa Rica policy rates as values, rates are in decimal form

country_code_switch(codes)

Convert country codes from Alpha-2 to Alpha-3 format.

Parameters:

Name Type Description Default
codes list[str]

List of Alpha-2 country codes

required

Returns:

Type Description

list[str]: List of corresponding Alpha-3 country codes

get_dates() -> list[pd.Timestamp] staticmethod

Generate list of quarterly dates from 2000 to 2024.

Returns:

Type Description
list[Timestamp]

list[pd.Timestamp]: List of first days of each quarter

prune(prune_date: date)

Prune policy rate data to only include entries after specified date.

Parameters:

Name Type Description Default
prune_date date

Date to prune data from

required
Note

Modifies the data in place