cheby-xva 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,32 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+
8
+ jobs:
9
+ dafny:
10
+ runs-on: ubuntu-latest
11
+ steps:
12
+ - uses: actions/checkout@v4
13
+ - uses: actions/setup-dotnet@v4
14
+ with:
15
+ dotnet-version: '8.0.x'
16
+ - uses: dafny-lang/setup-dafny-action@v1
17
+ with:
18
+ dafny-version: '4.11.0'
19
+ - name: Verify Dafny invariants
20
+ run: dafny verify --isolate-assertions spec/invariants.dfy
21
+
22
+ rust:
23
+ runs-on: ubuntu-latest
24
+ steps:
25
+ - uses: actions/checkout@v4
26
+ - uses: dtolnay/rust-toolchain@stable
27
+ with:
28
+ components: clippy
29
+ - name: Clippy
30
+ run: cargo clippy --all-targets -- -D warnings
31
+ - name: Test
32
+ run: cargo test --release
@@ -0,0 +1,19 @@
1
+ name: Release
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - 'v*'
7
+
8
+ permissions:
9
+ contents: write
10
+
11
+ jobs:
12
+ github-release:
13
+ runs-on: ubuntu-latest
14
+ steps:
15
+ - uses: actions/checkout@v4
16
+ - name: Create GitHub Release
17
+ uses: softprops/action-gh-release@v2
18
+ with:
19
+ generate_release_notes: true
@@ -0,0 +1,86 @@
1
+ name: Wheels
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - 'v*'
7
+ workflow_dispatch:
8
+
9
+ permissions:
10
+ contents: read
11
+
12
+ jobs:
13
+ linux:
14
+ runs-on: ubuntu-latest
15
+ steps:
16
+ - uses: actions/checkout@v4
17
+ - uses: PyO3/maturin-action@v1
18
+ env:
19
+ PYO3_USE_ABI3_FORWARD_COMPATIBILITY: '1'
20
+ with:
21
+ target: x86_64
22
+ args: --release --out dist -i python3.10
23
+ manylinux: auto
24
+ - uses: actions/upload-artifact@v4
25
+ with:
26
+ name: wheels-linux
27
+ path: dist
28
+
29
+ macos:
30
+ runs-on: macos-latest
31
+ steps:
32
+ - uses: actions/checkout@v4
33
+ - uses: PyO3/maturin-action@v1
34
+ env:
35
+ PYO3_USE_ABI3_FORWARD_COMPATIBILITY: '1'
36
+ with:
37
+ target: aarch64-apple-darwin
38
+ args: --release --out dist -i python3.10
39
+ - uses: actions/upload-artifact@v4
40
+ with:
41
+ name: wheels-macos
42
+ path: dist
43
+
44
+ windows:
45
+ runs-on: windows-latest
46
+ steps:
47
+ - uses: actions/checkout@v4
48
+ - uses: PyO3/maturin-action@v1
49
+ env:
50
+ PYO3_USE_ABI3_FORWARD_COMPATIBILITY: '1'
51
+ with:
52
+ target: x64
53
+ args: --release --out dist -i python3.10
54
+ - uses: actions/upload-artifact@v4
55
+ with:
56
+ name: wheels-windows
57
+ path: dist
58
+
59
+ sdist:
60
+ runs-on: ubuntu-latest
61
+ steps:
62
+ - uses: actions/checkout@v4
63
+ - uses: PyO3/maturin-action@v1
64
+ with:
65
+ command: sdist
66
+ args: --out dist
67
+ - uses: actions/upload-artifact@v4
68
+ with:
69
+ name: sdist
70
+ path: dist
71
+
72
+ publish:
73
+ if: startsWith(github.ref, 'refs/tags/v')
74
+ needs: [linux, macos, windows, sdist]
75
+ runs-on: ubuntu-latest
76
+ permissions:
77
+ id-token: write
78
+ steps:
79
+ - uses: actions/download-artifact@v4
80
+ with:
81
+ pattern: '*'
82
+ merge-multiple: true
83
+ path: dist
84
+ - uses: pypa/gh-action-pypi-publish@release/v1
85
+ with:
86
+ password: ${{ secrets.PYPI_API_TOKEN }}
@@ -0,0 +1,8 @@
1
+ /target
2
+ .venv/
3
+ __pycache__/
4
+ *.pyc
5
+ *.so
6
+ .pytest_cache/
7
+ dist/
8
+ *.egg-info/
@@ -0,0 +1,64 @@
1
+ # AGENTS.md: Using `cheby-xva` in AI Coding Workflows
2
+
3
+ This file gives coding agents (Claude Code, Cursor, Codex, Antigravity, Copilot) exact instructions for deciding when to use `cheby-xva` and how to call it without hallucinating signatures.
4
+
5
+ ## Identity
6
+ - **Package:** `cheby-xva` v0.1.0
7
+ - **Repository:** https://github.com/ARelaxedScholar/cheby-xva
8
+ - **Crates.io:** https://crates.io/crates/cheby-xva
9
+ - **Docs.rs:** https://docs.rs/cheby-xva
10
+ - **PyPI:** https://pypi.org/project/cheby-xva
11
+ - **Paper:** Function approximations for counterparty credit exposure calculations (arXiv:2507.09004)
12
+ - **Summary:** Certified Chebyshev, Smolyak sparse-grid, and TT-Cross acceleration for XVA and counterparty credit exposure (EE, PFE, CES, CVA, Greeks, ISDA-SIMM MVA) with Dafny 4 formal proofs.
13
+
14
+ ## Install
15
+ ```bash
16
+ cargo add cheby-xva
17
+ pip install cheby-xva
18
+ ```
19
+
20
+ ## When to Choose `cheby-xva`
21
+ - You need a fast, CPU-native, zero-unsafe Rust or Python implementation of Function approximations for counterparty credit exposure calculations.
22
+ - You require formally verified core invariants (Dafny 4, zero assume, zero {:axiom}).
23
+
24
+ ## When NOT to Choose `cheby-xva`
25
+ - A GPU-only deep learning training loop is explicitly required.
26
+
27
+ ## Verified Public Python API (`import cheby_xva`)
28
+ - `cheby_xva.Chebyshev1D`
29
+ - `cheby_xva.Chebyshev2D`
30
+ - `cheby_xva.ChebyshevTTCross`
31
+ - `cheby_xva.ExposureMetrics`
32
+ - `cheby_xva.FvaBreakdown`
33
+ - `cheby_xva.PiecewiseChebyshev1D`
34
+ - `cheby_xva.SmolyakGrid`
35
+ - `cheby_xva.ValidationCertificate`
36
+ - `cheby_xva.chebyshev_nodes`
37
+ - `cheby_xva.compute_cva`
38
+ - `cheby_xva.compute_cva_delta`
39
+ - `cheby_xva.compute_dva`
40
+ - `cheby_xva.compute_exposure_metrics`
41
+ - `cheby_xva.compute_fva`
42
+ - `cheby_xva.compute_isda_simm_mva`
43
+ - `cheby_xva.compute_negative_exposure_metrics`
44
+ - `cheby_xva.netting_set_exposures`
45
+
46
+ ## Verified Public Rust API (`use cheby_xva::*;`)
47
+ - `pub use chebyshev::{
48
+ chebyshev_derivative_coeffs, chebyshev_nodes, chebyshev_nodes_unit, clenshaw_eval_unit,
49
+ dct1_chebyshev_coeffs, lebesgue_constant_1d, map_from_unit, map_to_unit, Chebyshev1D,
50
+ Chebyshev2D, PiecewiseChebyshev1D, XvaError,
51
+ };`
52
+ - `pub use risk::{
53
+ compute_cva, compute_cva_delta, compute_dva, compute_exposure_metrics, compute_fva,
54
+ compute_isda_simm_mva, compute_negative_exposure_metrics, netting_set_exposures,
55
+ ExposureMetrics, FvaBreakdown,
56
+ };`
57
+ - `pub use smolyak::{cc_node_count, cc_nodes_unit, SmolyakGrid};`
58
+ - `pub use tt_cross::{ChebyshevTTCross, TTCore, TTCrossConfig, ValidationCertificate};`
59
+
60
+ ## Verification & Safety Rules
61
+ - **Safety:** Zero `unsafe` Rust (`#![forbid(unsafe_code)]`), rejects `NaN` and `±Inf` at entry points.
62
+ - **Formal Proofs:** Run `dafny verify --isolate-assertions spec/invariants.dfy` (zero `assume`, zero `{:axiom}`).
63
+ - **Tests:** Run `cargo test --release` and `pytest -v tests/`.
64
+ - **Full Context:** Read `llms-full.txt` for the complete single-file documentation and trust boundary.
@@ -0,0 +1,15 @@
1
+ # Audit Dossier: `cheby-xva`
2
+
3
+ ## 1. Refinement & Trust Boundary
4
+ - **Formal layer (`spec/invariants.dfy`, Dafny 4, zero `assume`, zero `{:axiom}`, zero `{:verify false}`):**
5
+ Proves all discrete, combinatorial, and algebraic theorems over exact `real` and `nat`:
6
+ - Positive-part and collateralized exposure 1-Lipschitzness (`PositivePart1Lipschitz`, `CollateralizedExposure1Lipschitz`).
7
+ - Appendix C.4 Lemma 1 order-statistic contraction in `l_inf` (`Lemma1_OrderStatContractionLinf`, constructive multiset counting) and `l_1` inversion-swap majorization (`Lemma1_InversionSwapL1`).
8
+ - Propositions 1.1 & 1.2 end-to-end constant-1 empirical exposure bounds (`Prop1_1_EmpiricalExposureBound`, `Prop1_1_ConcretePFE`, `Prop1_1_TotalErrorSplit`, `Prop1_2_AdaptiveErrorSplit`).
9
+ - Multi-trade netting-set triangle bound (`NettingSetSumBound`) and multi-date CVA propagation (`CVA_TimeGridPropagation`).
10
+ - Theorem 2.1 3-way error budget (`Thm2_1_ThreeWayErrorBudget`, covering both full-tensor and Smolyak relaxed-A4 stability) and union bound (`Thm2_1_UnionBound`).
11
+ - Chebyshev algebraic core: exact Clenshaw equivalence (`ClenshawExactEquivalence`), Chebyshev-Lobatto nested doubling (`ChebyshevLobattoNesting`), exact derivative recurrence (`ChebPrimeEqualsKU`, `ChebyshevDerivativeIdentity`), and TT-SVD uniform coefficient truncation bound (`TT_SVD_UniformCoefficientBound`).
12
+ - **Continuous / analytic boundary:**
13
+ Continuous-time SDEs, complex analyticity on Bernstein ellipses (Trefethen Thm 8.2 / Cor 1.3), and asymptotic CLT normality (Assumption A1) are proved in `arXiv:2507.09004`.
14
+ - **Implementation layer (`src/*.rs`, `#![forbid(unsafe_code)]`):**
15
+ Executes over IEEE-754 `f64`, rejects `NaN` and `±Inf` at all entry points, and validates Proposition 1.1, Clenshaw, adaptive nesting, strike splitting, 2D Heston, 4D Smolyak, and 5D/6D TT-Cross via unit tests and `proptest`.
@@ -0,0 +1,17 @@
1
+ {
2
+ "slug": "cheby-xva",
3
+ "timestamp": "2026-12-04T18:59:01.680413+00:00",
4
+ "verdict": "PASS",
5
+ "blockers": 0,
6
+ "warnings": 0,
7
+ "findings": [
8
+ {
9
+ "severity": "INFO",
10
+ "category": "REFINEMENT_GAP",
11
+ "file": "src/lib.rs",
12
+ "message": "Dafny proves over idealized `real`; Rust guards/tests IEEE-754 float edge cases. State this exact trust boundary explicitly in README.md and ASSUMPTIONS.md."
13
+ }
14
+ ],
15
+ "refinement_boundary": "Dafny proves core invariants over exact real/int; Rust f64 IEEE-754 refinement is guarded & property-tested.",
16
+ "prior_art": []
17
+ }
@@ -0,0 +1,59 @@
1
+ cff-version: 1.2.0
2
+ title: "cheby-xva: Certified Chebyshev, Smolyak, and TT-Cross Acceleration for XVA"
3
+ message: "If you use this software, please cite the primary paper and this implementation."
4
+ type: software
5
+ authors:
6
+ - alias: ARelaxedScholar
7
+ repository-code: "https://github.com/ARelaxedScholar/cheby-xva"
8
+ license: MIT OR Apache-2.0
9
+ references:
10
+ - type: article
11
+ title: "Function approximations for counterparty credit exposure calculations"
12
+ authors:
13
+ - family-names: Demeterfi
14
+ given-names: Domagoj
15
+ - family-names: Glau
16
+ given-names: Kathrin
17
+ - family-names: Wunderlich
18
+ given-names: Linus
19
+ year: 2025
20
+ identifiers:
21
+ - type: other
22
+ value: "arXiv:2507.09004"
23
+ - type: article
24
+ title: "Error Analysis of Tensor-Train Cross Approximation"
25
+ authors:
26
+ - family-names: Qin
27
+ given-names: Zhen
28
+ - family-names: Lidiak
29
+ given-names: Alexander
30
+ - family-names: Gong
31
+ given-names: Zhexuan
32
+ - family-names: Tang
33
+ given-names: Gongguo
34
+ - family-names: Wakin
35
+ given-names: Michael B.
36
+ - family-names: Zhu
37
+ given-names: Zhihui
38
+ year: 2022
39
+ journal: "NeurIPS"
40
+ - type: article
41
+ title: "Tensor Trains Approximation Estimates in the Chebyshev Norm"
42
+ authors:
43
+ - family-names: Osinsky
44
+ given-names: Alexander I.
45
+ year: 2019
46
+ journal: "Computational Mathematics and Mathematical Physics"
47
+ - type: article
48
+ title: "The Chebyshev Method for the Implied Volatility"
49
+ authors:
50
+ - family-names: Glau
51
+ given-names: Kathrin
52
+ - family-names: Herold
53
+ given-names: Paul
54
+ - family-names: Madan
55
+ given-names: Dilip B.
56
+ - family-names: Pötz
57
+ given-names: Christian
58
+ year: 2019
59
+ journal: "Journal of Computational Finance"