BanksDecideCreditSupply#
- class bamengine.events.credit_market.BanksDecideCreditSupply[source]#
Bases:
EventBanks decide total credit supply based on equity and capital requirement.
Banks set their maximum lendable funds based on their equity base and the regulatory capital requirement coefficient (v). Lower v means banks can lend more relative to their equity (higher leverage).
Algorithm
For each bank k:
\[C_k = E_k / v\]where:
\(C_k\): total credit supply (lendable funds) for bank k
\(E_k\): equity base of bank k
\(v\): capital requirement coefficient (Simulation parameter)
Mathematical Notation
\[C_k = \frac{E_k}{v}\]Typical value: v = 0.1 implies banks can lend 10× their equity base.
Examples
Execute this event:
>>> import bamengine as be >>> sim = be.Simulation.init(n_firms=100, n_banks=10, seed=42) >>> event = sim.get_event("banks_decide_credit_supply") >>> event.execute(sim)
Check credit supply:
>>> sim.lend.credit_supply.mean() 2500.0
Verify credit supply formula:
>>> import numpy as np >>> expected_supply = sim.lend.equity_base / sim.v >>> np.allclose(sim.lend.credit_supply, expected_supply) True
Check total available credit:
>>> total_credit = sim.lend.credit_supply.sum() >>> total_credit 25000.0
Notes
This event must execute at the start of the credit market phase, before BanksDecideInterestRate and FirmsDecideCreditDemand.
The capital requirement coefficient v is a Simulation-level parameter (not in config), accessed via sim.v.
Credit supply is reset each period based on current equity. Any unused credit from previous periods does not carry over.
See also
CreditMarketRoundUses credit_supply to provision loans
LenderBank state with equity_base and credit_supply
bamengine.events._internal.credit_market.banks_decide_credit_supplyImplementation
- 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_credit_supply'#