Lender#

class bamengine.roles.lender.Lender(equity_base, credit_supply, interest_rate, recv_loan_apps_head, recv_loan_apps, opex_shock=None)[source]#

Bases: Role

Lender role for banks.

Represents the credit supply and interest rate state for banks. Each array index corresponds to a bank ID (0 to n_banks-1).

Parameters:
  • equity_base (Float1D) – Bank equity/capital base.

  • credit_supply (Float1D) – Maximum credit available to lend (based on equity and capital requirements).

  • interest_rate (Float1D) – Interest rate charged on loans.

  • recv_loan_apps_head (Idx1D) – Queue head pointer for received loan applications.

  • recv_loan_apps (Idx2D) – Queue of borrower firm IDs, shape (n_banks, n_firms).

  • opex_shock (Float1D, optional) – Scratch buffer for operational expense shock calculations (not persisted).

Examples

Access from simulation:

>>> import bamengine as bam
>>> sim = bam.Simulation.init(n_banks=10, seed=42)
>>> lend = sim.lend
>>> lend.credit_supply.shape
(10,)
>>> lend.interest_rate.shape
(10,)

Calculate total credit supply:

>>> import numpy as np
>>> total_supply = lend.credit_supply.sum()
>>> total_supply
1500.0

Find banks with high interest rates:

>>> high_rate = lend.interest_rate > 0.03
>>> high_rate.sum()
3

Check equity distribution:

>>> mean_equity = lend.equity_base.mean()
>>> mean_equity
150.0

Find bank with highest credit supply:

>>> max_supply_bank = np.argmax(lend.credit_supply)
>>> max_supply_bank
5

Notes

Banks are the only agents with a single role (Lender). Firms have three roles (Producer, Employer, Borrower) and households have two (Worker, Consumer).

Credit supply is constrained by bank equity and the capital requirement ratio (v): credit_supply = equity_base / v

See also

Borrower

Credit demand role for firms

LoanBook

Loan relationship between borrowers and lenders

credit_market

Credit market logic

equity_base#

Bank equity / capital base.

credit_supply#

Maximum credit available to lend (equity_base / v).

interest_rate#

Interest rate charged on loans.

__init__(equity_base, credit_supply, interest_rate, recv_loan_apps_head, recv_loan_apps, opex_shock=None)#
name = 'Lender'#
recv_loan_apps_head#

Queue head pointer for received loan applications.

recv_loan_apps#

Queue of borrower firm IDs, shape (n_banks, n_firms).

opex_shock#

Scratch buffer for operational expense shock calculations.