32 lines
817 B
Python
32 lines
817 B
Python
"""Unit tests for Sheet 2: Commercial Bank (Part II — 2.2)."""
|
|
|
|
import pytest
|
|
from fqbm.state import FQBMState
|
|
from fqbm.sheets.commercial_bank import (
|
|
commercial_bank_step,
|
|
CommercialBankParams,
|
|
loans_max,
|
|
capital_ratio,
|
|
)
|
|
|
|
|
|
def test_loan_deposit_identity():
|
|
"""dLoans = dDeposits."""
|
|
state = FQBMState(Loans=900, Deposits=1000, E_b=100)
|
|
params = CommercialBankParams(d_deposits=50)
|
|
out = commercial_bank_step(state, params)
|
|
assert out.Loans == 950
|
|
assert out.Deposits == 1050
|
|
|
|
|
|
def test_loans_max():
|
|
"""Loans_max = Equity / k."""
|
|
assert loans_max(100, 0.08) == pytest.approx(1250)
|
|
assert loans_max(100, 0.10) == 1000
|
|
|
|
|
|
def test_capital_ratio():
|
|
"""CR = Equity / RWA."""
|
|
assert capital_ratio(100, 1000) == 0.1
|
|
assert capital_ratio(80, 1000) == 0.08
|