GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - dev-belly/NetworkClear: Exact debt clearing and counterparty contagion: rational arithmetic, clearing certificates, independent default-set checks, and reproducible stress reports.

BranchesTags
Open more actions menu

Latest commit

 

History

22 Commits
22 Commits

Folders and files

NameName
Last commit message
Last commit date
.github
.github
 
 
docs
docs
 
 
examples/demo
examples/demo
 
 
scripts
scripts
 
 
src/networkclear
src/networkclear
 
 
tests
tests
 
 
.gitattributes
.gitattributes
 
 
.gitignore
.gitignore
 
 
CONTRIBUTING.md
CONTRIBUTING.md
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
SECURITY.md
SECURITY.md
 
 
SUPPORT.md
SUPPORT.md
 
 
pyproject.toml
pyproject.toml
 
 

Repository files navigation

NetworkClear

CI Python Arithmetic

Counterparty contagion and debt clearing with exact payment certificates and an independent small-network oracle.

If an institution loses external assets, which debts remain unpaid after the network clears? NetworkClear implements pro-rata Eisenberg–Noe clearing, records the computational default sequence and separates gross unpaid debt from outside creditor shortfall.

Open the clearing explorer

Choose a shock scenario and a reference to compare defaults, outside shortfall, and gross unpaid debt. Filter by institution and scan payment recovery bars next to the exact ratios. The evidence downloads contain each scenario's clearing payments, flows, and active-set steps.

Synthetic demo · eight institutions

50% external-asset shock to A.

Measure Result
Defaulting institutions 4
Additional cascade defaults 3
Outside creditor shortfall USD 3,380
Gross unpaid nominal debt USD 12,020
Fixed-point residual 0

Direct default: A; cascade additions: B, C and D. Outside losses are counted separately.

15 scenarios · exact rational payments · exhaustive independent clearing checks.

Clearing workbench

Explore 15 stress cases, see which debts drive cascades, and inspect exact rational payments.

Workbench files

Open docs/workbench/index.html from a checkout to filter, drill into a record, and export CSV or JSON offline. Run python docs/workbench/build_data.py --check to verify the browser snapshot.

Quick start

On macOS or Linux:

git clone https://github.com/dev-belly/NetworkClear.git
cd NetworkClear
python -m venv .venv
source .venv/bin/activate
python -m pip install -e .
networkclear demo --out output/demo
networkclear verify output/demo
python -m http.server 8000 --directory output/demo

On Windows, use PowerShell. These commands do not require activating the environment:

git clone https://github.com/dev-belly/NetworkClear.git
cd NetworkClear
python -m venv .venv
.\.venv\Scripts\python.exe -m pip install -e .
.\.venv\Scripts\networkclear.exe demo --out output/demo
.\.venv\Scripts\networkclear.exe verify output/demo
.\.venv\Scripts\python.exe -m http.server 8000 --directory output/demo

Open http://localhost:8000 to switch stress scenarios, inspect recoveries and view the liability matrix. Saved evidence is in examples/demo; download or serve the HTML locally.

Model contracts

Component Behavior
Inputs Nonnegative integer USD cents; directed nominal debts between named institutions
Clearing Limited liability, pro-rata repayment and debt priority over equity
Outside creditors Every debtor owes a positive outside amount; closed nonregular cycles are rejected
Arithmetic Exact rational payments; rounded dollars are display only
Solver Monotone fictitious-default sets and exact active-system solves
Certificate Bounded payments satisfy the fixed-point equation with exactly zero residual
Conservation External assets = outside payments + final network equity
Independent oracle Exhaustive default-regime enumeration for at most eight institutions
Replay Source network, shocks, payments, flows, rounds, HTML and semantic verification

Rounds are computation steps, not real-world contagion time. Payments may be fractional cents: this is a continuous-money mathematical model, not a cent-quantized settlement engine. Larger reports disclose that exhaustive checking was not performed.

Synthetic demo

Eight institutions combine a debt chain and a feedback cycle. Fifteen scenarios cover an anchor shock grid, broad stress, cycle stress and two allocations of the same USD 2,000 injection budget. These are illustrative allocations, not a global optimization result.

At a 50% external-asset shock to A:

  • A defaults directly; B, C and D default through the network.
  • Final chain payments are USD 5,000 → 4,500 → 4,100 → 3,780.
  • Gross unpaid nominal debt is USD 12,020, including internal exposures.
  • Outside creditor shortfall is USD 3,380. Treating gross internal unpaid debt as a social loss would double-count propagation.

All fifteen scenarios are checked against all 256 candidate default regimes. Tests also compare 100 seeded small networks with the independent oracle, check permutation invariance and monotone shock effects, and reconcile every debt flow.

Custom runs and validation

networkclear run --network src/networkclear/data/network.json \
  --scenarios src/networkclear/data/scenarios.json --out output/custom
python -m pip install -e '.[dev]'
python -m unittest discover -s tests -v
ruff check src tests scripts
ruff format --check src tests scripts
networkclear verify examples/demo

No runtime dependencies, credentials or downloads are needed. CI runs tests, committed report replay and installed-wheel smoke tests on Linux with Python 3.11–3.13 and Windows with Python 3.12. Text files retain LF endings even when Git's core.autocrlf is enabled, preserving report hashes and preview bytes. The verifier rejects rehashed output tampering; it does not authenticate inputs or detect a complete coordinated rewrite.

CSV review exports mark formula-shaped scenario names as text and quote embedded carriage returns. Original IDs remain in JSON; exact payments and certificates are unchanged. See the spreadsheet export contract.

中文说明

银行网络风险与交易对手分析项目,重点是 债务方向、比例清偿、直接违约与新增传染违约、精确方程证书、外部资金勾稽、内部债务重复计算,与贷款违约预测项目互补。

  • 方法、输入结构与边界
  • 可复算演示
  • Eisenberg & Noe (2001), Systemic Risk in Financial Systems, Management Science 47(2), 236–249; paper copy.

Code and synthetic fixtures: MIT. Data do not represent real banks. No collateral, seniority, fire sales, bankruptcy costs or dynamic liquidity are modeled; no regulatory or actual-business benefit is claimed.

About

Exact debt clearing and counterparty contagion: rational arithmetic, clearing certificates, independent default-set checks, and reproducible stress reports.

dev-belly.github.io/NetworkClear/

Topics

counterparty-riskfinancial-networkspythonreproducible-researchstress-testingsystemic-risk

Resources

Readme
MIT license

Contributing

Contributing

Security policy

Security policy
Activity

Stars

1 star

Watchers

0 watching

Forks

0 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.