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:

  1. FirmsUpdateNetWorth - Add retained profits/losses to net worth

  2. MarkBankruptFirms - Detect insolvent firms (A < 0 or Y = 0)

  3. MarkBankruptBanks - Detect insolvent banks (E < 0)

  4. SpawnReplacementFirms - Create new firms to replace bankrupt ones

  5. 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.bankruptcy

System function implementations

Economy

Tracks bankruptcy counts

Event Classes#

FirmsUpdateNetWorth

Update firm net worth with retained profits/losses.

MarkBankruptFirms

Detect insolvent firms and remove them from the economy.

MarkBankruptBanks

Detect insolvent banks and remove them from the economy.

SpawnReplacementFirms

Create new firms to replace bankrupt ones.

SpawnReplacementBanks

Create new banks to replace bankrupt ones.