bolster.data_sources.boe_base_rate

Bank of England official Bank Rate (base rate).

Wraps the Bank of England’s published base-rate spreadsheet to provide standardised access to the UK policy interest rate:

  • A unified daily rate series back to 1973, formed by coalescing the successive rate regimes the BoE has used (Minimum Lending Rate, Minimum Band 1 Dealing Rate, Repo Rate and the current Official Bank Rate) into a single continuous level.

  • An event-based history of rate changes back to 1694, exposed via get_rate_changes().

The base rate is a level (a standing interest rate), not a flow, so when it is resampled to coarser resolutions the last observation in each period is used rather than a sum or mean.

This is the second of three macroeconomic context modules and emits the same fixed output schema as bolster.data_sources.ons_cpi, so that the macro series can be joined and resampled against one another:

Column

Description

date

datetime64[ns] period-start (Jan 2024 -> 2024-01-01, Q1 2024 -> 2024-01-01, year 2024 -> 2024-01-01, a daily observation keeps its own date)

year

int calendar year

quarter

str “Q1”..”Q4”, or pd.NA for annual/monthly/daily

month

int 1-12, or pd.NA for quarterly/annual/daily

resolution

str “daily” | “monthly” | “quarterly” | “annual”

series

str always “base_rate”

value

float rate in per-cent

unit

str always “%”

geography

str always “UK”

source

str always “BoE”

Note

The Bank of England’s dynamic statistics API (/boe-apps/statistics-api/, /boe-apps/sdw/) returns HTTP 403 for automated requests. The static spreadsheet linked below is the only reliable programmatic route and is what this module uses.

Source:

https://www.bankofengland.co.uk/boeapps/database/Bank-Rate.asp

Example

>>> from bolster.data_sources import boe_base_rate
>>> df = boe_base_rate.get_latest_data(resolution="annual")  
>>> sorted(df.columns)  
['date', 'geography', 'month', 'quarter', 'resolution', 'series', 'source', 'unit', 'value', 'year']

Attributes

logger

DATA_URL

RAW_DATA_SHEET

HISTORICAL_SHEET

GEOGRAPHY

SOURCE

SERIES

UNIT

SCHEMA_COLUMNS

RATE_CHANGES_COLUMNS

RESOLUTIONS

Exceptions

BoEDataError

Base exception for Bank of England data errors.

BoEValidationError

Raised when a DataFrame fails validate_data().

Functions

get_latest_data([resolution, force_refresh])

Fetch the unified UK base rate at a given resolution.

get_rate_changes([force_refresh])

Fetch the event-based history of base-rate changes back to 1694.

validate_data(df)

Validate that a DataFrame conforms to the macroeconomic schema.

Module Contents

bolster.data_sources.boe_base_rate.logger[source]
bolster.data_sources.boe_base_rate.DATA_URL = 'https://www.bankofengland.co.uk/-/media/boe/files/monetary-policy/baserate.xls'[source]
bolster.data_sources.boe_base_rate.RAW_DATA_SHEET = 'Raw Data'[source]
bolster.data_sources.boe_base_rate.HISTORICAL_SHEET = 'HISTORICAL SINCE 1694'[source]
bolster.data_sources.boe_base_rate.GEOGRAPHY = 'UK'[source]
bolster.data_sources.boe_base_rate.SOURCE = 'BoE'[source]
bolster.data_sources.boe_base_rate.SERIES = 'base_rate'[source]
bolster.data_sources.boe_base_rate.UNIT = '%'[source]
bolster.data_sources.boe_base_rate.SCHEMA_COLUMNS = ['date', 'year', 'quarter', 'month', 'resolution', 'series', 'value', 'unit', 'geography', 'source'][source]
bolster.data_sources.boe_base_rate.RATE_CHANGES_COLUMNS = ['date', 'year', 'series', 'value', 'unit', 'geography', 'source'][source]
bolster.data_sources.boe_base_rate.RESOLUTIONS = ('daily', 'monthly', 'quarterly', 'annual')[source]
exception bolster.data_sources.boe_base_rate.BoEDataError[source]

Bases: Exception

Base exception for Bank of England data errors.

Initialize self. See help(type(self)) for accurate signature.

exception bolster.data_sources.boe_base_rate.BoEValidationError[source]

Bases: BoEDataError

Raised when a DataFrame fails validate_data().

Initialize self. See help(type(self)) for accurate signature.

bolster.data_sources.boe_base_rate.get_latest_data(resolution='monthly', force_refresh=False)[source]

Fetch the unified UK base rate at a given resolution.

The base rate is a standing level, so coarser resolutions take the last observation in each period (i.e. the rate in force at period end).

Parameters:
  • resolution (str) – “daily”, “monthly” (default), “quarterly” or “annual”.

  • force_refresh (bool) – Accepted for API parity; binary downloads are not cached.

Returns:

DataFrame conforming to SCHEMA_COLUMNS, sorted by date.

Raises:
Return type:

pandas.DataFrame

Example

>>> df = get_latest_data(resolution="annual")  
>>> df.iloc[-1][["series", "unit", "geography", "source"]].tolist()  
['base_rate', '%', 'UK', 'BoE']
bolster.data_sources.boe_base_rate.get_rate_changes(force_refresh=False)[source]

Fetch the event-based history of base-rate changes back to 1694.

Each row is a rate change effective on a given date (the value is the new rate). The series is irregular by nature. Where the source records only a year and month (the earliest entries pre-date daily records), the change is dated to the first of that month.

Parameters:

force_refresh (bool) – Accepted for API parity; binary downloads are not cached.

Returns:

DataFrame with columns RATE_CHANGES_COLUMNS, sorted by date.

Raises:

BoEDataError – If the workbook download or parse fails, or no changes could be parsed.

Return type:

pandas.DataFrame

Example

>>> df = get_rate_changes()  
>>> df.iloc[0][["date", "value"]].tolist()  
[Timestamp('1694-10-01 00:00:00'), 6.0]
bolster.data_sources.boe_base_rate.validate_data(df)[source]

Validate that a DataFrame conforms to the macroeconomic schema.

Checks performed:

  • All SCHEMA_COLUMNS are present.

  • At least one row is present.

  • geography is exclusively “UK” and source exclusively “BoE”.

  • series is exclusively “base_rate” and unit exclusively “%”.

  • resolution only contains known values.

  • value is numeric, non-null and within a sane 0-25% range.

Parameters:

df (pandas.DataFrame) – DataFrame to validate.

Returns:

True if all checks pass.

Raises:

BoEValidationError – If any check fails.

Return type:

bool

Example

>>> df = get_latest_data(resolution="annual")  
>>> validate_data(df)  
True