SyntheticCreditMarket¶
The SyntheticCreditMarket class is a container for preprocessed credit market relationship data between financial institutions and borrowers. It organizes initial loan states and parameters for model initialization.
Core Functionality¶
The class handles:
-
Credit Relationship Data:
- Bank-firm loan relationships
- Bank-household loan relationships
- Initial loan parameters
-
Loan Type Organization:
- Long-term firm loans
- Short-term firm loans
- Consumer loans
- Payday loans
- Mortgage loans
-
Loan Parameter Processing:
- Principal amounts
- Interest rates
- Installment calculations
- Maturity periods
Key Attributes¶
country_name: Country identifier for data collectionyear: Reference year for preprocessinglongterm_loans: Preprocessed firm long-term loan datashortterm_loans: Preprocessed firm short-term loan dataconsumption_expansion_loans: Preprocessed consumer loan datapayday_loans: Preprocessed payday loan datamortgage_loans: Preprocessed mortgage loan data
Factory Methods¶
The class provides a factory method create_from_agents that creates a SyntheticCreditMarket instance by:
- Processing credit relationship data from various economic agents
- Matching borrowers with corresponding banks
- Calculating initial loan parameters
- Organizing data into loan type categories
Implementation¶
Module for preprocessing synthetic credit market relationship data.
This module provides a framework for preprocessing and organizing credit relationship data between banks, firms, and households. Key preprocessing includes:
- Credit Relationship Data:
- Bank-firm loan relationships
- Bank-household loan relationships
-
Initial loan parameters
-
Loan Type Organization:
- Long-term firm loans
- Short-term firm loans
- Consumer loans
- Payday loans
-
Mortgage loans
-
Loan Parameter Processing:
- Principal amounts
- Interest rates
- Installment calculations
- Maturity periods
Note
This module is NOT used for simulating credit market behavior. It only handles the preprocessing and organization of credit relationship data that will later be used to initialize behavioral models in the simulation package.
SyntheticCreditMarket
dataclass
¶
Container for preprocessed credit market relationship data.
This class organizes credit relationship data between financial institutions and borrowers, preprocessing initial loan states and parameters for model initialization. It does NOT implement credit market behavior - it only handles data preprocessing.
The preprocessed data is organized into five loan categories: 1. Long-term Loans: Initial firm long-term borrowing data 2. Short-term Loans: Initial firm short-term credit data 3. Consumer Loans: Initial household consumption borrowing data 4. Payday Loans: Initial household short-term credit data 5. Mortgage Loans: Initial household mortgage data
Each loan category contains: - Principal amounts - Interest rates - Installment schedules - Bank-borrower relationships
Note
This is a data container class. The actual credit market behavior (lending decisions, interest rate setting, etc.) is implemented in the simulation package, which uses this preprocessed data for initialization.
Attributes:
| Name | Type | Description |
|---|---|---|
country_name |
str
|
Country identifier for data collection |
year |
int
|
Reference year for preprocessing |
longterm_loans |
LongtermLoans
|
Preprocessed firm long-term loan data |
shortterm_loans |
ShorttermLoans
|
Preprocessed firm short-term loan data |
consumption_expansion_loans |
ConsumptionExpansionLoans
|
Preprocessed consumer loan data |
payday_loans |
PaydayLoans
|
Preprocessed payday loan data |
mortgage_loans |
MortgageLoans
|
Preprocessed mortgage loan data |
country_name: str
instance-attribute
¶
year: int
instance-attribute
¶
longterm_loans: LongtermLoans
instance-attribute
¶
shortterm_loans: ShorttermLoans
instance-attribute
¶
consumption_expansion_loans: ConsumptionExpansionLoans
instance-attribute
¶
payday_loans: PaydayLoans
instance-attribute
¶
mortgage_loans: MortgageLoans
instance-attribute
¶
__init__(country_name: str, year: int, longterm_loans: LongtermLoans, shortterm_loans: ShorttermLoans, consumption_expansion_loans: ConsumptionExpansionLoans, payday_loans: PaydayLoans, mortgage_loans: MortgageLoans) -> None
¶
create_from_agents(firms: SyntheticFirms, population: SyntheticPopulation, banks: SyntheticBanks, zero_firm_debt: bool, firm_loan_maturity: int, hh_consumption_maturity: int, mortgage_maturity: int) -> SyntheticCreditMarket
classmethod
¶
Create a preprocessed credit market data container from agent data.
This method processes credit relationship data from various economic agents to prepare: 1. Firm loan data (long and short term) 2. Household loan data (consumer and payday) 3. Mortgage loan data
The preprocessing steps: 1. Extract loan data from firms and households 2. Match with corresponding bank data 3. Calculate initial loan parameters 4. Organize into loan type categories
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
firms
|
SyntheticFirms
|
Firm data container |
required |
population
|
SyntheticPopulation
|
Population data container |
required |
banks
|
SyntheticBanks
|
Bank data container |
required |
zero_firm_debt
|
bool
|
Whether to initialize with zero firm debt |
required |
firm_loan_maturity
|
int
|
Initial maturity for firm loans |
required |
hh_consumption_maturity
|
int
|
Initial maturity for consumer loans |
required |
mortgage_maturity
|
int
|
Initial maturity for mortgages |
required |
Returns:
| Name | Type | Description |
|---|---|---|
SyntheticCreditMarket |
SyntheticCreditMarket
|
Container with preprocessed credit relationship data |
Loan Data Classes¶
The credit market module includes several specialized classes for different types of loans:
LoanData¶
Base class for preprocessing loan-specific credit data. It provides:
- Principal amounts by bank-borrower pair
- Interest amounts by bank-borrower pair
- Installment amounts by bank-borrower pair
LongtermLoans¶
Container for preprocessed long-term firm loan data:
- Principal amounts from firm debt data
- Interest amounts using bank long-term rates
- Installment amounts based on maturity
ShorttermLoans¶
Container for preprocessed short-term firm loan data:
- Principal amounts from firm debt data
- Interest amounts using bank short-term rates
- Installment amounts based on maturity
ConsumptionExpansionLoans¶
Container for preprocessed consumer loan data:
- Principal amounts from household debt data
- Interest amounts using bank consumer rates
- Installment amounts based on maturity
PaydayLoans¶
Container for preprocessed payday loan data:
- Principal amounts from household data
- Interest amounts using bank payday rates
- Installment amounts based on maturity
MortgageLoans¶
Container for preprocessed mortgage loan data:
- Principal amounts from household mortgage data
- Interest amounts using bank mortgage rates
- Installment amounts based on maturity
Implementation¶
Module for preprocessing loan-specific credit relationship data.
This module provides dataclasses for organizing different types of loan data that will be used to initialize behavioral models. Key preprocessing includes:
- Loan Parameter Processing:
- Principal amount calculations
- Interest rate applications
-
Installment computations
-
Bank-Borrower Relationships:
- Firm-bank loan mappings
- Household-bank loan mappings
-
Initial loan state organization
-
Loan Type Specialization:
- Long-term firm loans
- Short-term firm loans
- Consumer loans
- Payday loans
- Mortgages
Note
This module is NOT used for simulating loan behavior. It only handles the preprocessing and organization of loan-specific data that will later be used to initialize behavioral models in the simulation package.
LoanData
dataclass
¶
Base class for preprocessing loan-specific credit data.
This class provides a framework for organizing loan parameters that will be used to initialize behavioral models. It is NOT used for simulating loan behavior - it only handles data preprocessing.
The preprocessed data includes: - Principal amounts by bank-borrower pair - Interest amounts by bank-borrower pair - Installment amounts by bank-borrower pair
Note
This is a data container class. The actual loan behavior (repayment, default, etc.) is implemented in the simulation package, which uses this preprocessed data for initialization.
Attributes:
| Name | Type | Description |
|---|---|---|
principal |
ndarray
|
Initial loan principal amounts |
interest |
ndarray
|
Initial loan interest amounts |
installments |
ndarray
|
Initial loan installment amounts |
principal: np.ndarray
instance-attribute
¶
interest: np.ndarray
instance-attribute
¶
installments: np.ndarray
instance-attribute
¶
__init__(principal: np.ndarray, interest: np.ndarray, installments: np.ndarray) -> None
¶
stack()
¶
Stack loan parameters for preprocessing.
Returns:
| Type | Description |
|---|---|
|
np.ndarray: Stacked array of [principal, interest, installments] |
LongtermLoans
dataclass
¶
Container for preprocessed long-term firm loan data.
This class organizes initial state data for long-term loans to firms. It processes: - Principal amounts from firm debt data - Interest amounts using bank long-term rates - Installment amounts based on maturity
Note
This is a data container class. The actual loan behavior is implemented in the simulation package.
__init__(principal: np.ndarray, interest: np.ndarray, installments: np.ndarray) -> None
¶
from_agent_data(bank_data: pd.DataFrame, firm_data: pd.DataFrame, firm_loan_maturity: int = 60) -> LongtermLoans
classmethod
¶
Create a preprocessed long-term loan data container.
This method: 1. Extracts firm debt data 2. Matches with bank rate data 3. Calculates initial parameters
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
bank_data
|
DataFrame
|
Bank data with rates |
required |
firm_data
|
DataFrame
|
Firm data with debt |
required |
firm_loan_maturity
|
int
|
Initial maturity. Defaults to 60. |
60
|
Returns:
| Name | Type | Description |
|---|---|---|
LongtermLoans |
LongtermLoans
|
Container with preprocessed loan data |
ShorttermLoans
dataclass
¶
Container for preprocessed short-term firm loan data.
This class organizes initial state data for short-term loans to firms. It processes: - Principal amounts from firm debt data - Interest amounts using bank short-term rates - Installment amounts based on maturity
Note
This is a data container class. The actual loan behavior is implemented in the simulation package.
__init__(principal: np.ndarray, interest: np.ndarray, installments: np.ndarray) -> None
¶
from_agent_data(bank_data: pd.DataFrame, firm_data: pd.DataFrame, firm_loan_maturity: int = 60) -> ShorttermLoans
classmethod
¶
Create a preprocessed short-term loan data container.
This method: 1. Extracts firm debt data 2. Matches with bank rate data 3. Calculates initial parameters
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
bank_data
|
DataFrame
|
Bank data with rates |
required |
firm_data
|
DataFrame
|
Firm data with debt |
required |
firm_loan_maturity
|
int
|
Initial maturity. Defaults to 60. |
60
|
Returns:
| Name | Type | Description |
|---|---|---|
ShorttermLoans |
ShorttermLoans
|
Container with preprocessed loan data |
ConsumptionExpansionLoans
dataclass
¶
Container for preprocessed consumer loan data.
This class organizes initial state data for household consumption loans. It processes: - Principal amounts from household debt data - Interest amounts using bank consumer rates - Installment amounts based on maturity
Note
This is a data container class. The actual loan behavior is implemented in the simulation package.
__init__(principal: np.ndarray, interest: np.ndarray, installments: np.ndarray) -> None
¶
from_agent_data(bank_data: pd.DataFrame, household_data: pd.DataFrame, consumption_loan_maturity: int = 1) -> ConsumptionExpansionLoans
classmethod
¶
Create a preprocessed consumer loan data container.
This method: 1. Extracts household debt data 2. Matches with bank rate data 3. Calculates initial parameters
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
bank_data
|
DataFrame
|
Bank data with rates |
required |
household_data
|
DataFrame
|
Household data with debt |
required |
consumption_loan_maturity
|
int
|
Initial maturity. Defaults to 1. |
1
|
Returns:
| Name | Type | Description |
|---|---|---|
ConsumptionExpansionLoans |
ConsumptionExpansionLoans
|
Container with preprocessed loan data |
PaydayLoans
dataclass
¶
Container for preprocessed payday loan data.
This class organizes initial state data for household payday loans. It processes: - Principal amounts from household data - Interest amounts using bank payday rates - Installment amounts based on maturity
Note
This is a data container class. The actual loan behavior is implemented in the simulation package.
__init__(principal: np.ndarray, interest: np.ndarray, installments: np.ndarray) -> None
¶
from_agent_data(bank_data: pd.DataFrame, household_data: pd.DataFrame, payday_loan_maturity: int = 1) -> PaydayLoans
classmethod
¶
Create a preprocessed payday loan data container.
This method: 1. Extracts household data 2. Matches with bank rate data 3. Calculates initial parameters
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
bank_data
|
DataFrame
|
Bank data with rates |
required |
household_data
|
DataFrame
|
Household data |
required |
payday_loan_maturity
|
int
|
Initial maturity. Defaults to 1. |
1
|
Returns:
| Name | Type | Description |
|---|---|---|
PaydayLoans |
PaydayLoans
|
Container with preprocessed loan data |
MortgageLoans
dataclass
¶
Container for preprocessed mortgage loan data.
This class organizes initial state data for household mortgages. It processes: - Principal amounts from household mortgage data - Interest amounts using bank mortgage rates - Installment amounts based on maturity
Note
This is a data container class. The actual loan behavior is implemented in the simulation package.
__init__(principal: np.ndarray, interest: np.ndarray, installments: np.ndarray) -> None
¶
from_agent_data(bank_data: pd.DataFrame, household_data: pd.DataFrame, mortgage_maturity: int = 120)
classmethod
¶
Create a preprocessed mortgage loan data container.
This method: 1. Extracts household mortgage data 2. Matches with bank rate data 3. Calculates initial parameters
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
bank_data
|
DataFrame
|
Bank data with rates |
required |
household_data
|
DataFrame
|
Household data with mortgages |
required |
mortgage_maturity
|
int
|
Initial maturity. Defaults to 120. |
120
|
Returns:
| Name | Type | Description |
|---|---|---|
MortgageLoans |
Container with preprocessed loan data |