credit_market#
Credit market events for credit supply, demand, and loan provision.
This module defines the credit market phase events that execute after labor market events. Banks decide credit supply and interest rates, firms determine credit needs, and loans are matched through a batch application process. Firms that fail to secure sufficient credit fire workers to match available funds.
Event Sequence#
The credit market events execute in this order:
BanksDecideCreditSupply - Banks set total lendable funds based on equity
BanksDecideInterestRate - Banks set interest rates with random markup
FirmsDecideCreditDemand - Firms calculate funding shortfall
FirmsCalcFinancialFragility - Firms calculate leverage and fragility
FirmsPrepareLoanApplications - Firms select banks to apply to (sorted by rate)
CreditMarketRound - Batch credit market matching (max_H times)
FirmsFireWorkers - Batch firing when credit insufficient
Design Notes#
Events operate on borrower, lender, and loanbook (Borrower, Lender, LoanBook)
Banks rank loan applicants by net worth (descending) for default risk assessment
Firms fire randomly selected workers to minimize layoffs
Credit supply constrained by bank equity and capital requirement (v parameter)
Interest rates: \(r = \bar{r} \times (1 + \varepsilon)\), where \(\varepsilon \sim U(0, h_\phi)\)
Batch matching: all borrowers simultaneously send their next application, applicants are grouped by bank, ranked by ascending fragility, and loans provisioned using grouped cumsum to track supply exhaustion
Examples
Execute credit market events:
>>> import bamengine as be
>>> sim = be.Simulation.init(n_firms=100, n_banks=10, seed=42)
>>> # Credit market events run as part of default pipeline
>>> sim.step()
Execute individual credit market event:
>>> event = sim.get_event("banks_decide_credit_supply")
>>> event.execute(sim)
>>> sim.lend.credit_supply.mean()
2500.0
Check loan book after credit provision:
>>> sim.lb.size
45
>>> sim.lb.principal[: sim.lb.size].sum()
1250.0
See also
bamengine.events._internal.credit_marketSystem function implementations
BorrowerFirm credit demand and financial state
LenderBank credit supply and interest rates
LoanBookLoan relationship between borrowers and lenders
Event Classes#
Banks decide total credit supply based on equity and capital requirement. |
|
Banks set interest rates as markup over base rate with random shock. |
|
Firms calculate credit demand based on funding shortfall. |
|
Firms calculate projected financial fragility metric for credit evaluation. |
|
Firms select banks to apply to, sorted by interest rate (ascending). |
|
One round of batch credit market matching. |
|
Batch firing of workers when credit is insufficient. |