BanksDecideInterestRate#
- class bamengine.events.credit_market.BanksDecideInterestRate[source]#
Bases:
EventBanks set interest rates as markup over base rate with random shock.
Banks apply a random markup to the baseline policy rate to set their lending rates. The markup introduces heterogeneity in bank rates and competition for low-rate lenders.
Algorithm
For each bank k:
Generate rate shock: \(\varepsilon_k \sim U(0, h_\phi)\)
Apply markup: \(r_k = \bar{r} \times (1 + \varepsilon_k)\)
Mathematical Notation
\[r_k = \bar{r} \times (1 + \varepsilon_k)\]where:
\(r_k\): interest rate charged by bank k
\(\bar{r}\): baseline policy rate (Simulation parameter)
\(\varepsilon_k\): random shock \(\sim U(0, h_\phi)\)
\(h_\phi\): maximum interest rate shock parameter (config)
Examples
Execute this event:
>>> import bamengine as be >>> sim = be.Simulation.init(n_banks=10, seed=42) >>> event = sim.get_event("banks_decide_interest_rate") >>> event.execute(sim)
Check interest rates:
>>> sim.lend.interest_rate.mean() 0.035
Verify rates are above base rate:
>>> (sim.lend.interest_rate >= sim.r_bar).all() True
Find lowest-rate bank:
>>> import numpy as np >>> cheapest_bank = np.argmin(sim.lend.interest_rate) >>> sim.lend.interest_rate[cheapest_bank] 0.031
Notes
This event must execute after BanksDecideCreditSupply and before FirmsPrepareLoanApplications (firms sort banks by rate).
The baseline policy rate \(\bar{r}\) is a Simulation-level parameter accessed via sim.r_bar.
All banks charge rates \(\geq \bar{r}\) since shock \(\varepsilon \geq 0\).
See also
FirmsPrepareLoanApplicationsFirms sort banks by interest rate
CreditMarketRoundUses interest_rate for new loans
bamengine.events._internal.credit_market.banks_decide_interest_rateImplementation
- execute(sim)[source]#
Execute the event’s logic.
Mutates simulation state in-place. This method must be implemented by all Event subclasses.
- Parameters:
sim (
Simulation) – The simulation instance containing all state and configuration.- Returns:
All mutations are in-place.
- Return type:
Examples
Implement execute in a custom event:
>>> from bamengine import event, ops >>> >>> @event ... class CustomPricingEvent: ... def execute(self, sim): ... prod = sim.get_role("Producer") ... # Apply 10% markup to all prices ... new_prices = ops.multiply(prod.price, 1.1) ... ops.assign(prod.price, new_prices)
Access configuration and RNG:
>>> @event ... class StochasticEvent: ... def execute(self, sim): ... shock = sim.config.h_rho ... random_values = sim.rng.uniform(0, shock, size=sim.n_firms) ... # Use random_values in calculations
Notes
The execute method receives full Simulation access, including: - All roles: sim.get_role(“RoleName”) or sim.prod, sim.wrk, etc. - Configuration: sim.config - RNG: sim.rng - Economy state: sim.ec
- __init__()#
- name = 'banks_decide_interest_rate'#