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 |
|
year |
|
quarter |
|
month |
|
resolution |
|
series |
|
value |
|
unit |
|
geography |
|
source |
|
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.
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
Exceptions
Base exception for Bank of England data errors. |
|
Raised when a DataFrame fails |
Functions
|
Fetch the unified UK base rate at a given resolution. |
|
Fetch the event-based history of base-rate changes back to 1694. |
|
Validate that a DataFrame conforms to the macroeconomic schema. |
Module Contents
- 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.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:
ExceptionBase 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:
BoEDataErrorRaised 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:
- Returns:
DataFrame conforming to
SCHEMA_COLUMNS, sorted bydate.- Raises:
ValueError – If
resolutionis not recognised.BoEDataError – If the workbook download or parse fails.
- Return type:
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 bydate.- Raises:
BoEDataError – If the workbook download or parse fails, or no changes could be parsed.
- Return type:
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_COLUMNSare present.At least one row is present.
geographyis exclusively “UK” andsourceexclusively “BoE”.seriesis exclusively “base_rate” andunitexclusively “%”.resolutiononly contains known values.valueis numeric, non-null and within a sane 0-25% range.
- Parameters:
df (pandas.DataFrame) – DataFrame to validate.
- Returns:
Trueif all checks pass.- Raises:
BoEValidationError – If any check fails.
- Return type:
Example
>>> df = get_latest_data(resolution="annual") >>> validate_data(df) True