bankruptcy#
Bankruptcy events for insolvency detection and agent replacement.
This module defines the bankruptcy phase events that execute at the end of each period. Firms update net worth with retained earnings, insolvent agents are detected and removed, and replacement agents are spawned to maintain population.
Event Sequence#
The bankruptcy events execute in this order:
FirmsUpdateNetWorth - Add retained profits/losses to net worth
MarkBankruptFirms - Detect insolvent firms (A < 0 or Y = 0)
MarkBankruptBanks - Detect insolvent banks (E < 0)
SpawnReplacementFirms - Create new firms to replace bankrupt ones
SpawnReplacementBanks - Create new banks to replace bankrupt ones
Design Notes#
Bankruptcy criteria: firms (A < 0 or Y = 0), banks (E < 0)
Bankrupt firms: fire all workers, purge loans
Bankrupt banks: purge all loans
Replacement firms: inherit trimmed mean of survivors × scale factor
Replacement banks: clone random surviving bank equity
Population constant: n_firms, n_banks unchanged
Examples
Execute bankruptcy events:
>>> import bamengine as be
>>> sim = be.Simulation.init(n_firms=100, n_banks=10, seed=42)
>>> # Bankruptcy events run as part of default pipeline
>>> sim.step()
Check bankruptcies:
>>> sim.ec.n_firm_failures
2
>>> sim.ec.n_bank_failures
0
See also
bamengine.events._internal.bankruptcySystem function implementations
EconomyTracks bankruptcy counts
Event Classes#
Update firm net worth with retained profits/losses. |
|
Detect insolvent firms and remove them from the economy. |
|
Detect insolvent banks and remove them from the economy. |
|
Create new firms to replace bankrupt ones. |
|
Create new banks to replace bankrupt ones. |