Banks API Reference¶
This section documents the Banks agent in the macromodel package, which implements the banking sector and its financial intermediation functions.
macromodel.agents.banks.banks.Banks
¶
Banking system that intermediates between savers and borrowers.
This class represents the banking sector that facilitates financial intermediation through: - Deposit management (firms and households) - Loan provision (short/long-term, consumption, mortgages) - Interest rate setting (loans and deposits) - Profit generation and equity accumulation - Market share tracking - Insolvency handling
The banks operate with: - Policy rate-based interest rate adjustment - Differentiated rates for different products - Balance sheet management - Profit computation and distribution - Financial stability monitoring
Attributes:
| Name | Type | Description |
|---|---|---|
parameters |
BankParameters
|
Banking sector parameters |
functions |
dict[str, Any]
|
Function implementations |
policy_rate_markup |
float
|
Markup over policy rate |
ts |
TimeSeries
|
Time series tracking bank variables |
states |
dict
|
State variables including: - corr_firms: Corresponding firm IDs - corr_households: Corresponding household IDs - is_insolvent: Bank solvency status - Pass Through/ECT parameters for different products |
from_pickled_agent(synthetic_banks: SyntheticBanks, configuration: BanksConfiguration, policy_rate_markup: float, n_industries: int, scale: int, country_name: str, all_country_names: list[str])
classmethod
¶
Create banking system from pickled data.
Initializes banks with: - Configuration parameters - Synthetic bank data - Interest rate parameters - Corresponding firm/household mappings
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
synthetic_banks
|
SyntheticBanks
|
Synthetic bank data |
required |
configuration
|
BanksConfiguration
|
Bank configuration |
required |
policy_rate_markup
|
float
|
Markup over policy rate |
required |
n_industries
|
int
|
Number of industries |
required |
scale
|
int
|
Scale factor for histograms |
required |
country_name
|
str
|
Name of the country |
required |
all_country_names
|
list[str]
|
List of all countries |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Banks |
Initialized banking system |
reset(configuration: BanksConfiguration) -> None
¶
Reset banking system to initial state.
Resets all state variables and updates function implementations based on the provided configuration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
configuration
|
BanksConfiguration
|
New configuration |
required |
compute_estimated_profits(estimated_growth: float, estimated_inflation: float) -> np.ndarray
¶
Calculate estimated future profits.
Estimates profits based on: - Current profit levels - Expected economic growth - Expected inflation
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
estimated_growth
|
float
|
Expected economic growth rate |
required |
estimated_inflation
|
float
|
Expected inflation rate |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
np.ndarray: Estimated profits by bank |
set_interest_rates(central_bank_policy_rate: float) -> None
¶
Set interest rates for all banking products.
Updates rates for: - Short-term firm loans - Long-term firm loans - Household consumption loans - Mortgages - Firm deposits - Household deposits - Overdraft facilities
Each rate considers: - Central bank policy rate - Previous rate levels - Pass-through parameters - Error correction terms
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
central_bank_policy_rate
|
float
|
Current policy rate |
required |
compute_interest_received_on_deposits(central_bank_policy_rate: float) -> np.ndarray
¶
Calculate net interest received on deposits.
Computes interest considering: - Positive and negative deposit balances - Different rates for firms and households - Overdraft rates for negative balances - Regular deposit rates for positive balances
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
central_bank_policy_rate
|
float
|
Current policy rate |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
np.ndarray: Net interest received by bank |
compute_profits() -> np.ndarray
¶
Calculate total bank profits.
Combines: - Interest received on loans - Net interest received on deposits
Returns:
| Type | Description |
|---|---|
ndarray
|
np.ndarray: Total profits by bank |
update_deposits(current_firm_deposits: np.ndarray, current_household_deposits: np.ndarray, firm_corresponding_bank: np.ndarray, households_corresponding_bank: np.ndarray) -> None
¶
Update deposit balances.
Records: - Firm deposits by bank - Household deposits by bank - Total deposits from firms - Total deposits from households
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
current_firm_deposits
|
ndarray
|
Current firm deposits |
required |
current_household_deposits
|
ndarray
|
Current household deposits |
required |
firm_corresponding_bank
|
ndarray
|
Bank IDs for firms |
required |
households_corresponding_bank
|
ndarray
|
Bank IDs for households |
required |
update_loans(credit_market: CreditMarket) -> None
¶
Update loan balances.
Records: - Short-term firm loans - Long-term firm loans - Household consumption loans - Mortgages - Total outstanding loans
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
credit_market
|
CreditMarket
|
Credit market instance |
required |
compute_market_share() -> np.ndarray
¶
Calculate market share of each bank.
Based on: - Total outstanding loans - Total deposits from firms - Total deposits from households
Returns:
| Type | Description |
|---|---|
ndarray
|
np.ndarray: Market share by bank |
compute_equity(profit_taxes: float) -> np.ndarray
¶
Calculate bank equity.
Considers: - Current equity levels - After-tax profits - Insolvency status
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
profit_taxes
|
float
|
Tax rate on profits |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
np.ndarray: Equity by bank |
compute_liability() -> np.ndarray
¶
Calculate total bank liabilities.
Sums: - Deposits from firms - Deposits from households
Returns:
| Type | Description |
|---|---|
ndarray
|
np.ndarray: Total liabilities by bank |
compute_deposits() -> np.ndarray
¶
Calculate total deposits.
Sums: - Deposits from firms - Deposits from households
Returns:
| Type | Description |
|---|---|
ndarray
|
np.ndarray: Total deposits by bank |
handle_insolvency(credit_market: CreditMarket) -> float
¶
Handle insolvent banks.
Processes: - Identification of insolvent banks - Marking of insolvent status - Credit market adjustments - Loss computation
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
credit_market
|
CreditMarket
|
Credit market instance |
required |
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
Total losses from insolvency |
compute_insolvency_rate() -> float
¶
Calculate bank insolvency rate.
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
Fraction of banks that are insolvent |
save_to_h5(group: h5py.Group)
¶
Save bank data to HDF5.
Stores all time series data in the specified HDF5 group.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
group
|
Group
|
HDF5 group to save data in |
required |
Functions¶
Bank Demography¶
macromodel.agents.banks.func.demography.BankDemography
¶
Abstract base class for bank demography management.
This class defines strategies for handling bank demographics and insolvency through: - Solvency monitoring - Insolvency detection - Capital adequacy assessment - Restructuring decisions
The strategies consider: - Equity to asset ratios - Minimum capital requirements - System-wide stability - Resolution mechanisms
Attributes:
| Name | Type | Description |
|---|---|---|
solvency_ratio |
float
|
Minimum required equity to assets ratio |
Interest Rate Setting¶
macromodel.agents.banks.func.interest_rates.InterestRatesSetter
¶
Abstract base class for interest rate determination.
This class defines strategies for setting interest rates on all banking products through: - Policy rate transmission - Pass-through mechanisms - ECT adjustments - Product differentiation
The rates include: - Firm lending rates - Household lending rates - Deposit rates - Overdraft rates
Profit Estimation¶
macromodel.agents.banks.func.profit_estimator.BankProfitsSetter
¶
Abstract base class for bank profit estimation.
This class defines strategies for estimating future bank profits based on: - Current profit levels - Economic growth expectations - Inflation projections - Bank-specific conditions
The estimates consider: - Historical performance - Macroeconomic outlook - Price level dynamics - Individual bank factors