SyntheticBanks¶
The SyntheticBanks class is an abstract base class that defines the interface for preprocessing and organizing banking system data. It provides the core functionality for managing bank-level data and relationships.
Core Functionality¶
The class handles:
- Bank balance sheet data organization
- Customer relationship mapping
- Initial state calculations
- Interest rate management
- Market share calculations
Key Methods¶
initialise_deposits_and_loans: Sets up initial deposits and loans for all banksset_bank_equity: Sets equity level for each bankset_deposits_from_firms: Sets initial deposits from firmsset_deposits_from_households: Sets initial deposits from householdsset_loans_to_firms: Sets initial loans to firmsset_loans_to_households: Sets initial loans to householdsset_bank_deposits: Sets total deposits for each bankset_market_share: Calculates and sets market share for each bankset_liability: Calculates and sets total liabilities for each bank
Implementation¶
Module for preprocessing synthetic banking system data.
This module provides an abstract base class for preprocessing and organizing banking system data that will be used to initialize behavioral models in the simulation package. Key preprocessing includes:
- Data Collection and Organization:
- Bank balance sheet data preparation
- Initial deposit and loan allocation
-
Interest rate parameter estimation
-
Relationship Data:
- Bank-firm connections
- Bank-household connections
-
Market share calculations
-
Financial Data Processing:
- Interest rate parameter estimation
- Balance sheet validation
- Data consistency checks
Note
This module is NOT used for simulating bank behavior. It only handles the preprocessing and organization of data that will later be used to initialize behavioral models in the simulation package.
SyntheticBanks
¶
Abstract base class for preprocessing and organizing banking system data.
This class provides a framework for collecting and organizing banking system data that will be used to initialize behavioral models. It is NOT used for simulating bank behavior - it only handles data preprocessing.
The preprocessed data is stored in a pandas DataFrame with the following columns
- Equity: Initial bank equity
- Corresponding Firms ID: Firm-bank relationship mapping
- Corresponding Households ID: Household-bank relationship mapping
- Deposits from Households: Initial household deposits
- Mortgages to Households: Initial mortgage values
- Consumption Loans to Households: Initial consumer loan values
- Deposits from Firms: Initial firm deposits
- Loans to Firms: Initial firm loans
- Deposits: Total initial deposits
- Short-Term Interest Rates on Firm Loans: Initial rate parameters
- Long-Term Interest Rates on Firm Loans: Initial rate parameters
- Interest Rates on Household Payday Loans: Initial rate parameters
- Interest Rates on Household Consumption Loans: Initial rate parameters
- Interest Rates on Mortgages: Initial rate parameters
- Interest Rates on Firm Deposits: Initial rate parameters
- Overdraft Rate on Firm Deposits: Initial rate parameters
- Interest Rates on Household Deposits: Initial rate parameters
- Overdraft Rate on Household Deposits: Initial rate parameters
- Interest received from Loans: Initial interest calculations
- Interest received from Deposits: Initial interest calculations
- Profits: Initial profit calculations
- Corporate Taxes Paid: Initial tax calculations
- Liability: Initial liability calculations
- Market Share: Initial market share calculations
Note
This is a data container class. The actual banking behavior (lending decisions, rate setting, etc.) is implemented in the simulation package, which uses this preprocessed data for initialization.
Attributes:
| Name | Type | Description |
|---|---|---|
country_name |
str
|
Country identifier for data collection |
year |
int
|
Reference year for preprocessing |
quarter |
int
|
Reference quarter for preprocessing |
number_of_banks |
int
|
Number of banks to preprocess data for |
bank_data |
DataFrame
|
Preprocessed bank-level data |
firm_passthrough |
float
|
Estimated rate adjustment parameter |
firm_ect |
float
|
Estimated error correction parameter |
firm_rate |
float
|
Initial firm loan rate |
hh_consumption_passthrough |
float
|
Estimated consumer rate parameter |
hh_consumption_ect |
float
|
Estimated consumer ECT parameter |
hh_consumption_rate |
float
|
Initial consumer loan rate |
hh_mortgage_passthrough |
float
|
Estimated mortgage rate parameter |
hh_mortgage_ect |
float
|
Estimated mortgage ECT parameter |
hh_mortgage_rate |
float
|
Initial mortgage rate |
country_name = country_name
instance-attribute
¶
year = year
instance-attribute
¶
quarter = quarter
instance-attribute
¶
number_of_banks = number_of_banks
instance-attribute
¶
bank_data = bank_data
instance-attribute
¶
firm_passthrough = firm_passthrough
instance-attribute
¶
firm_ect = firm_ect
instance-attribute
¶
firm_rate = firm_rate
instance-attribute
¶
hh_consumption_passthrough = hh_consumption_passthrough
instance-attribute
¶
hh_consumption_ect = hh_consumption_ect
instance-attribute
¶
hh_consumption_rate = hh_consumption_rate
instance-attribute
¶
hh_mortgage_passthrough = hh_mortgage_passthrough
instance-attribute
¶
hh_mortgage_ect = hh_mortgage_ect
instance-attribute
¶
hh_mortgage_rate = hh_mortgage_rate
instance-attribute
¶
__init__(country_name: str, year: int, number_of_banks: int, bank_data: pd.DataFrame, quarter: int, firm_passthrough: float, firm_ect: float, firm_rate: float, hh_consumption_passthrough: float, hh_consumption_ect: float, hh_consumption_rate: float, hh_mortgage_passthrough: float, hh_mortgage_ect: float, hh_mortgage_rate: float) -> None
abstractmethod
¶
Initialize a synthetic banking system.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
country_name
|
str
|
Country identifier |
required |
year
|
int
|
Reference year for data |
required |
number_of_banks
|
int
|
Number of banks to create |
required |
bank_data
|
DataFrame
|
Initial bank-level data |
required |
quarter
|
int
|
Reference quarter (1-4) |
required |
firm_passthrough
|
float
|
Rate adjustment factor for firm loans |
required |
firm_ect
|
float
|
Error correction term for firm rates |
required |
firm_rate
|
float
|
Base rate for firm loans |
required |
hh_consumption_passthrough
|
float
|
Rate adjustment for consumer loans |
required |
hh_consumption_ect
|
float
|
Error correction for consumer rates |
required |
hh_consumption_rate
|
float
|
Base rate for consumer loans |
required |
hh_mortgage_passthrough
|
float
|
Rate adjustment for mortgages |
required |
hh_mortgage_ect
|
float
|
Error correction for mortgage rates |
required |
hh_mortgage_rate
|
float
|
Base mortgage rate |
required |
initialise_deposits_and_loans(synthetic_population: SyntheticPopulation, firm_deposits: np.ndarray, firm_debt: np.ndarray) -> None
¶
Initialize the deposits and loans for all banks in the system.
This method sets up the initial state of bank balance sheets by: 1. Setting household deposits based on their wealth allocation 2. Setting household loans (mortgages and other debt) 3. Setting firm deposits and loans 4. Calculating total bank deposits
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
synthetic_population
|
SyntheticPopulation
|
Population data including household wealth |
required |
firm_deposits
|
ndarray
|
Array of firm deposit amounts |
required |
firm_debt
|
ndarray
|
Array of firm debt amounts |
required |
set_deposits_from_firms(firm_deposits: np.ndarray) -> None
abstractmethod
¶
Set the initial deposits from firms for each bank.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
firm_deposits
|
ndarray
|
Array of deposit amounts by firm |
required |
set_deposits_from_households(household_deposits: np.ndarray) -> None
abstractmethod
¶
Set the initial deposits from households for each bank.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
household_deposits
|
ndarray
|
Array of deposit amounts by household |
required |
set_loans_to_firms(firm_debt: np.ndarray) -> None
abstractmethod
¶
Set the initial loans to firms for each bank.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
firm_debt
|
ndarray
|
Array of debt amounts by firm |
required |
set_loans_to_households(household_mortgage_debt: np.ndarray, household_other_debt: np.ndarray) -> None
abstractmethod
¶
Set the initial loans to households for each bank.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
household_mortgage_debt
|
ndarray
|
Array of mortgage debt by household |
required |
household_other_debt
|
ndarray
|
Array of non-mortgage debt by household |
required |
set_bank_equity(bank_equity: float) -> None
abstractmethod
¶
Set the equity level for each bank.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
bank_equity
|
float
|
Equity amount to set for each bank |
required |
set_bank_deposits(firm_deposits: np.ndarray, household_deposits: np.ndarray, firm_debt: np.ndarray, household_debt: np.ndarray) -> None
abstractmethod
¶
Set the total deposits for each bank.
Calculates and sets total deposits by combining: - Firm deposits - Household deposits - Firm debt - Household debt
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
firm_deposits
|
ndarray
|
Array of firm deposit amounts |
required |
household_deposits
|
ndarray
|
Array of household deposit amounts |
required |
firm_debt
|
ndarray
|
Array of firm debt amounts |
required |
household_debt
|
ndarray
|
Array of household debt amounts |
required |
initialise_rates_profits_liabilities(policy_rate: float, tau_bank: float, risk_premium: float, consumption_loans_markup: float, mortgage_markup: float, household_overdraft_markup: float)
¶
Initialize bank rates, profits, and liabilities.
This method sets up the complete financial structure of banks by: 1. Setting interest rates for all products 2. Calculating interest income from loans and deposits 3. Computing profits and taxes 4. Setting liabilities and market shares
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
policy_rate
|
float
|
Central bank policy rate |
required |
tau_bank
|
float
|
Bank tax rate |
required |
risk_premium
|
float
|
Risk premium for loans |
required |
consumption_loans_markup
|
float
|
Markup for consumer loans |
required |
mortgage_markup
|
float
|
Markup for mortgages |
required |
household_overdraft_markup
|
float
|
Markup for household overdrafts |
required |
set_initial_interest_rates(central_bank_policy_rate: float, bank_markup_interest_rate_short_term_firm_loans: float, bank_markup_interest_rate_long_term_firm_loans: float, bank_markup_interest_rate_household_payday_loans: float, bank_markup_interest_rate_household_consumption_loans: float, bank_markup_interest_rate_mortgages: float, bank_markup_interest_rate_overdraft_firm: float, bank_markup_interest_rate_overdraft_household: float) -> None
¶
Set initial interest rates for all bank products.
This method initializes rates for: - Firm loans (short and long term) - Household loans (payday, consumption, mortgages) - Deposits (firm and household) - Overdrafts
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
central_bank_policy_rate
|
float
|
Base rate from central bank |
required |
bank_markup_interest_rate_short_term_firm_loans
|
float
|
Markup for short-term firm loans |
required |
bank_markup_interest_rate_long_term_firm_loans
|
float
|
Markup for long-term firm loans |
required |
bank_markup_interest_rate_household_payday_loans
|
float
|
Markup for payday loans |
required |
bank_markup_interest_rate_household_consumption_loans
|
float
|
Markup for consumer loans |
required |
bank_markup_interest_rate_mortgages
|
float
|
Markup for mortgages |
required |
bank_markup_interest_rate_overdraft_firm
|
float
|
Markup for firm overdrafts |
required |
bank_markup_interest_rate_overdraft_household
|
float
|
Markup for household overdrafts |
required |
set_interest_received_from_loans() -> None
¶
Calculate and set the interest income received from all loans.
This method computes the total interest income from: - Firm loans (short and long term) - Household loans (mortgages, consumption, payday) - Overdraft facilities
The calculated interest income is stored in the bank_data DataFrame.
set_interest_received_from_deposits(central_bank_policy_rate: float) -> None
¶
Calculate and set the interest income received from deposits.
This method computes interest income from: - Household deposits - Firm deposits - Interbank deposits
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
central_bank_policy_rate
|
float
|
Base rate from central bank used for deposit rate calculations |
required |
set_profits() -> None
¶
Calculate and set bank profits.
Computes profits by: 1. Adding all interest income (from loans and deposits) 2. Subtracting interest expenses 3. Subtracting operational costs 4. Adjusting for any extraordinary items
set_corporate_taxes_paid(tau_bank: float) -> None
¶
Calculate and set corporate taxes paid by banks.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tau_bank
|
float
|
Corporate tax rate applicable to banks |
required |
set_market_share() -> None
¶
Calculate and set market share for each bank.
Market share is computed based on: - Total assets - Total deposits - Number of customers (firms and households)
set_liability() -> None
¶
Calculate and set total liabilities for each bank.
Liabilities include: - Customer deposits (firm and household) - Interbank borrowing - Other funding sources
DefaultSyntheticBanks¶
DefaultSyntheticBanks is a concrete implementation of SyntheticBanks that provides preprocessing of banking system data using standard data sources (OECD, Eurostat, Compustat). This class handles the initialization and organization of data that will be used to initialize behavioral models in the simulation package.
Data Source Integration¶
The class integrates data from multiple sources:
- OECD economic indicators
- Eurostat banking statistics
- Compustat bank-level data
- National accounts data
Initial State Processing¶
The class processes:
- Bank balance sheet data
- Historical rate parameters
- Customer relationship mappings
- Initial state calculations
Parameter Estimation¶
Key parameters estimated include:
- Interest rate parameters
- Balance sheet ratios
- Market share calculations
- Risk premiums
Factory Methods¶
The class provides two factory methods:
from_readers: Creates aDefaultSyntheticBanksinstance using standard data sourcesfrom_readers_compustat: Creates aDefaultSyntheticBanksinstance using detailed Compustat data
Implementation¶
Module for preprocessing synthetic banking system data.
This module provides a concrete implementation for preprocessing banking system data that will be used to initialize behavioral models. Key preprocessing includes:
- Data Collection and Processing:
- Bank balance sheet data preparation
- Historical rate parameter estimation
-
Initial state calculations
-
Bank Data Organization:
- Standard bank data preprocessing
- Compustat-based data preprocessing
-
Data validation and consistency checks
-
Parameter Estimation:
- Interest rate parameters
- Balance sheet ratios
- Market share calculations
Note
This module is NOT used for simulating bank behavior. It preprocesses data that will be used to initialize behavioral models in the simulation package. The actual banking decisions and operations are implemented elsewhere.
DefaultSyntheticBanks
¶
Default implementation for preprocessing banking system data.
This class preprocesses and organizes banking system data by collecting historical data and estimating parameters. These will be used to initialize behavioral models, but this class does NOT implement any behavioral logic.
The class provides two preprocessing paths: 1. Standard preprocessing using OECD/Eurostat data 2. Compustat-based preprocessing for detailed bank profiles
The preprocessing includes: - Bank balance sheet data organization - Interest rate parameter estimation - Relationship mapping (bank-firm, bank-household) - Initial state calculations
Note
This is a data container class. The actual banking behavior (lending, rate setting, etc.) is implemented in the simulation package, which uses these preprocessed parameters.
Attributes:
| Name | Type | Description |
|---|---|---|
country_name |
str
|
Country identifier for data collection |
year |
int
|
Reference year for preprocessing |
number_of_banks |
int
|
Number of banks to preprocess data for |
bank_data |
DataFrame
|
Preprocessed bank-level data |
quarter |
int
|
Reference quarter for preprocessing |
firm_passthrough |
float
|
Estimated rate adjustment parameter |
firm_ect |
float
|
Estimated error correction parameter |
firm_rate |
float
|
Initial firm loan rate |
hh_consumption_passthrough |
float
|
Estimated consumer rate parameter |
hh_consumption_ect |
float
|
Estimated consumer ECT parameter |
hh_consumption_rate |
float
|
Initial consumer loan rate |
hh_mortgage_passthrough |
float
|
Estimated mortgage rate parameter |
hh_mortgage_ect |
float
|
Estimated mortgage ECT parameter |
hh_mortgage_rate |
float
|
Initial mortgage rate |
proxy_country |
Optional[Country]
|
Country to use as proxy when missing data |
__init__(country_name: str, year: int, number_of_banks: int, bank_data: pd.DataFrame, quarter: int, firm_passthrough: float, firm_ect: float, firm_rate: float, hh_consumption_passthrough: float, hh_consumption_ect: float, hh_consumption_rate: float, hh_mortgage_passthrough: float, hh_mortgage_ect: float, hh_mortgage_rate: float, proxy_country: Optional[Country] = None)
¶
Initialize the banking system data container.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
country_name
|
str
|
Country identifier for data collection |
required |
year
|
int
|
Reference year for preprocessing |
required |
number_of_banks
|
int
|
Number of banks to preprocess data for |
required |
bank_data
|
DataFrame
|
Initial data to preprocess |
required |
quarter
|
int
|
Reference quarter for preprocessing |
required |
firm_passthrough
|
float
|
Estimated rate adjustment parameter |
required |
firm_ect
|
float
|
Estimated error correction parameter |
required |
firm_rate
|
float
|
Initial firm loan rate |
required |
hh_consumption_passthrough
|
float
|
Estimated consumer rate parameter |
required |
hh_consumption_ect
|
float
|
Estimated consumer ECT parameter |
required |
hh_consumption_rate
|
float
|
Initial consumer loan rate |
required |
hh_mortgage_passthrough
|
float
|
Estimated mortgage rate parameter |
required |
hh_mortgage_ect
|
float
|
Estimated mortgage ECT parameter |
required |
hh_mortgage_rate
|
float
|
Initial mortgage rate |
required |
proxy_country
|
Optional[Country]
|
Country to use as proxy when missing data |
None
|
from_readers(single_bank: bool, country_name: Country, year: int, readers: DataReaders, scale: int, banks_data_configuration: BanksDataConfiguration, quarter: int, inflation_data: pd.DataFrame, exchange_rate_from_eur: float = 1.0, proxy_eu_country: Optional[Country] = None) -> DefaultSyntheticBanks
classmethod
¶
Create a preprocessed banking system data container using standard data sources.
This method preprocesses data using OECD/Eurostat sources to prepare: 1. Bank balance sheet data (scaled appropriately) 2. Initial rate parameters 3. Bank relationship mappings
For standard preprocessing: - Number of banks is derived from actual bank branches (scaled) - Bank equity is distributed based on historical data - Rate parameters are estimated from historical rates
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
single_bank
|
bool
|
Whether to preprocess data for a single bank |
required |
country_name
|
Country
|
Country to preprocess data for |
required |
year
|
int
|
Reference year for preprocessing |
required |
readers
|
DataReaders
|
Data source readers |
required |
scale
|
int
|
Scaling factor for bank numbers |
required |
banks_data_configuration
|
BanksDataConfiguration
|
Preprocessing configuration |
required |
quarter
|
int
|
Reference quarter for preprocessing |
required |
inflation_data
|
DataFrame
|
Historical inflation data |
required |
exchange_rate_from_eur
|
float
|
Exchange rate for conversion. Defaults to 1.0. |
1.0
|
proxy_eu_country
|
Optional[Country]
|
EU country for proxy data. Defaults to None. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
DefaultSyntheticBanks |
DefaultSyntheticBanks
|
Container with preprocessed banking system data |
from_readers_compustat(country_name: Country, year: int, readers: DataReaders, single_bank: bool, scale: int, quarter: int, inflation_data: pd.DataFrame, exchange_rate_from_eur: float = 1.0, proxy_eu_country: Optional[Country] = None) -> DefaultSyntheticBanks
classmethod
¶
Create a preprocessed banking system data container using Compustat data.
This method preprocesses detailed Compustat data to prepare: 1. Historical balance sheet information 2. Actual deposit and loan distributions 3. Historical equity levels and ratios
The preprocessing steps: 1. Fetch and filter relevant Compustat bank data 2. Sample and scale data appropriately 3. Align with country-level totals 4. Estimate initial parameters
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
country_name
|
Country
|
Country to preprocess data for |
required |
year
|
int
|
Reference year for preprocessing |
required |
readers
|
DataReaders
|
Data source readers |
required |
single_bank
|
bool
|
Whether to preprocess data for a single bank |
required |
scale
|
int
|
Scaling factor for bank numbers |
required |
quarter
|
int
|
Reference quarter for preprocessing |
required |
inflation_data
|
DataFrame
|
Historical inflation data |
required |
exchange_rate_from_eur
|
float
|
Exchange rate for conversion. Defaults to 1.0. |
1.0
|
proxy_eu_country
|
Optional[Country]
|
EU country for proxy data. Defaults to None. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
DefaultSyntheticBanks |
DefaultSyntheticBanks
|
Container with preprocessed banking system data |
initialise_rates(country_name, inflation_data, proxy_eu_country, quarter, readers, year)
classmethod
¶
Preprocess and estimate initial interest rate parameters.
This method: 1. Collects historical rate data 2. Estimates rate adjustment parameters 3. Calculates initial rates for different products
The preprocessing includes parameter estimation for: - Firm loan rates - Consumer loan rates - Mortgage rates - Default parameters when data is insufficient
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
country_name
|
Country
|
Country to process data for |
required |
inflation_data
|
DataFrame
|
Historical inflation data |
required |
proxy_eu_country
|
Optional[Country]
|
EU country for proxy data |
required |
quarter
|
int
|
Reference quarter |
required |
readers
|
DataReaders
|
Data source readers |
required |
year
|
int
|
Reference year |
required |
Returns:
| Name | Type | Description |
|---|---|---|
tuple |
Nine estimated parameters: - firm_ect: Estimated error correction for firm rates - firm_passthrough: Estimated adjustment for firm rates - firm_rate: Initial firm rate - hh_consumption_ect: Estimated consumer rate ECT - hh_consumption_passthrough: Estimated consumer rate adjustment - hh_consumption_rate: Initial consumer rate - hh_mortgage_ect: Estimated mortgage ECT - hh_mortgage_passthrough: Estimated mortgage adjustment - hh_mortgage_rate: Initial mortgage rate |
set_bank_equity(bank_equity: float) -> None
¶
Set the equity level for each bank.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
bank_equity
|
float
|
Equity amount to set for each bank |
required |
set_deposits_from_firms(firm_deposits: np.ndarray) -> None
¶
Set the initial deposits from firms for each bank.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
firm_deposits
|
ndarray
|
Array of deposit amounts by firm |
required |
set_deposits_from_households(household_deposits: np.ndarray) -> None
¶
Set the initial deposits from households for each bank.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
household_deposits
|
ndarray
|
Array of deposit amounts by household |
required |
set_loans_to_firms(firm_debt: np.ndarray) -> None
¶
Set the initial loans to firms for each bank.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
firm_debt
|
ndarray
|
Array of debt amounts by firm |
required |
set_loans_to_households(household_mortgage_debt: np.ndarray, household_other_debt: np.ndarray) -> None
¶
Set the initial loans to households for each bank.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
household_mortgage_debt
|
ndarray
|
Array of mortgage debt by household |
required |
household_other_debt
|
ndarray
|
Array of non-mortgage debt by household |
required |
set_bank_deposits(firm_deposits: np.ndarray, firm_debt: np.ndarray, household_deposits: np.ndarray, household_debt: np.ndarray) -> None
¶
Set the total deposits for each bank.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
firm_deposits
|
ndarray
|
Array of firm deposit amounts |
required |
firm_debt
|
ndarray
|
Array of firm debt amounts |
required |
household_deposits
|
ndarray
|
Array of household deposit amounts |
required |
household_debt
|
ndarray
|
Array of household debt amounts |
required |