risk-kernel
The risk model liquidation kernels as a standalone package — pure compute
(numpy + stdlib), zero DB access, no write path. This package is the source of
truth for kernel logic: both core and core-api install it and run the
kernels in-process.
Three model namespaces:
risk_kernel.v2— the v2 liquidation-simulation kernel. Operates on in-memoryPricePaths/SellOrderbook/BorrowerPositionstructures (risk_kernel.v2.liquidator.types).risk_kernel.v3— the v3 market-clearing kernel: clearing kernel, impact law, CRR stats, liquidation-wall curve math, FHS residuals/simulator. Entry pointsrisk_kernel.v3.kernel.run_clearing_kernel/run_multi_asset_kernelonKernelInputs/MultiAssetKernelInputs.risk_kernel.concentration— the Laniakea correlation-framework concentration engine: position classification, L(category, scenario) loss matrix, Method A/B exposure caps (classify.classify_positions→loss.build_loss_matrix→caps.method_a/caps.method_b).calibration.pyholds the generated factor shocks / static losses; number changes land as ordinary constants PRs referencing the analysis-repo run. Needs theconcentrationextra (balabs-risk-kernel[concentration]— pandas + cvxpy); the base install stays numpy-only, so importing the namespace without the extra fails at import time.
Loading inputs from a database is the consumer's job, never this package's.
Consumers
Both install balabs-risk-kernel from PyPI and run the kernels in-process:
- core — the production risk model. Consumes the pure kernel here and keeps
only the impure orchestration in-tree (
src/risk_model_v2/,src/risk_model_v3/: datasources, pipelines, tasks, models, persistence, calibration). The pure compute modules were removed from core in office #553 — they live here now. - core-api — runs the kernels for the on-demand LTV↔CRR estimator endpoint (office #490 / #537).
Both currently pin balabs-risk-kernel==0.2.1.
Change flow
Kernel logic changes land here first. Release, then bump consumers:
- Make the change in
src/risk_kernel/v2/orsrc/risk_kernel/v3/. - Merge with a conventional-commit message —
release.ymlrunspython-semantic-release, which bumps the version and publishes to PyPI. - Bump the pin in consumers (
core,core-apipyproject.toml).
There is no per-model commit pin and no diff-against-core sync step: this repo no longer mirrors core. core is a consumer, not the origin.
What the package deliberately excludes
The kernels here are pure compute only — the impure layers that live in core (datasources, pipelines, persistence, tasks, calibration, forecasters, wall fetchers/sources) are intentionally not vendored.
The one non-obvious exclusion, carried over from when this repo was seeded from
core: the v2 persistence path is stripped from
v2/liquidator/pipeline/processors/liquidator.py
(the _persist_market_crr / _persist_scenario_paths /
_rewrite_market_crr_tiers / _prune_market_crr_snapshot24 methods, their
sync() call sites, and the risk_model_v2.models import block). sync()
computes and returns CRRSummary objects, nothing else. pipeline/scenario_paths.py
is unused after the strip but kept verbatim.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file balabs_risk_kernel-0.3.0.tar.gz.
File metadata
- Download URL: balabs_risk_kernel-0.3.0.tar.gz
- Upload date:
- Size: 74.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
77a7cc1d088e1ea6e2607e6141766ac699d536a2337697e108f169436e1743f9
|
|
| MD5 |
17608bb075d89d62e129b6d687bde8c4
|
|
| BLAKE2b-256 |
edcb94f0ebcc1ef85088f80faef4ea57d365cdf36dae37202b843748d3851022
|
Provenance
The following attestation bundles were made for balabs_risk_kernel-0.3.0.tar.gz:
Publisher:
release.yml on blockanalitica/risk-kernel
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
balabs_risk_kernel-0.3.0.tar.gz -
Subject digest:
77a7cc1d088e1ea6e2607e6141766ac699d536a2337697e108f169436e1743f9 - Sigstore transparency entry: 2257016447
- Sigstore integration time:
-
Permalink:
blockanalitica/risk-kernel@ebdc5cc7707c433dabbcd1a7e3c3edd99b6b8e55 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/blockanalitica
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@ebdc5cc7707c433dabbcd1a7e3c3edd99b6b8e55 -
Trigger Event:
push
-
Statement type:
File details
Details for the file balabs_risk_kernel-0.3.0-py3-none-any.whl.
File metadata
- Download URL: balabs_risk_kernel-0.3.0-py3-none-any.whl
- Upload date:
- Size: 88.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8fec8e141ec4fbeaaf94222896bec0410d5f6ac363b311fb4c8f589e85d673ed
|
|
| MD5 |
b7474956107a29e66553aa4cfb2f5325
|
|
| BLAKE2b-256 |
ad8cc0f1d97d890444a38b7ceddacb538dd6f2790133c7dd7072c5a24caa51bc
|
Provenance
The following attestation bundles were made for balabs_risk_kernel-0.3.0-py3-none-any.whl:
Publisher:
release.yml on blockanalitica/risk-kernel
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
balabs_risk_kernel-0.3.0-py3-none-any.whl -
Subject digest:
8fec8e141ec4fbeaaf94222896bec0410d5f6ac363b311fb4c8f589e85d673ed - Sigstore transparency entry: 2257016457
- Sigstore integration time:
-
Permalink:
blockanalitica/risk-kernel@ebdc5cc7707c433dabbcd1a7e3c3edd99b6b8e55 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/blockanalitica
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@ebdc5cc7707c433dabbcd1a7e3c3edd99b6b8e55 -
Trigger Event:
push
-
Statement type: