Developer Internal Modules¶
This page describes implementation modules that are not public API.
User code should import from the root package or from the first-layer public packages listed in API guide. The modules listed here support those public packages. They can move when the implementation changes.
Public Boundary¶
The public import story has two levels:
fuggers_pyexposes shared language used across the whole library.fuggers_py.<domain>exposes one domain package, such asbonds,rates,curves, orportfolio.
Everything below is internal:
Root packages whose names start with
_, such asfuggers_py._core.Helper files or folders inside a public package whose names start with
_, such asbonds/_spreads/.Generated support files such as
_version.py.
Do not document internal modules as user-facing imports. Do not add wrappers whose only job is to keep an old import path alive.
Ownership Rules¶
Use the smallest owner that matches the code:
Put shared fixed-income language in
_core. Examples:Date,Currency,Tenor,InstrumentId,Price,Yield,Spread, calendars, day-count rules, and the shared exception root.Put generic numerical routines in
_math. Examples: interpolation, extrapolation, root solvers, least-squares helpers, and small linear-system solvers.Put engine coordination and market-data runtime code in
_runtime. Examples: pricing requests, pricing-router outputs, schedulers, market snapshots, source interfaces, and market state containers.Put persistence, codecs, and transport helpers in
_storage. Examples: file-backed sources, JSON codecs, SQLite storage, portfolio stores, and transport/cache interfaces.Put product-specific helpers inside the public package that owns the product. Examples: bond cash-flow generation in
bonds, swap pricing inrates, CDS pricing incredit, repo analytics infunding, and CPI helpers ininflation.Put portfolio-only helpers inside
portfolio/. Examples: holdings, portfolio metrics, benchmark comparison, bucketing, ETF NAV, liquidity, stress, and attribution.
When a name becomes public, expose it through one public package only:
fuggers_pyfor shared language used across the whole library. Examples:Date,Currency,Price,Yield,Spread, andTenor.fuggers_py.curvesfor curve objects and curve fitting. Examples:CurveSpec,YieldCurve,CalibrationReport, andSTANDARD_KEY_RATE_TENORS.fuggers_py.vol_surfacesfor volatility surface records and sources. Examples: volatility points, surface snapshots, and in-memory surface sources.fuggers_py.bondsfor bond instruments, reference data, analytics, and risk. Examples:FixedBondBuilder,BondQuote,BondPricer, YAS helpers, spread helpers, and bond risk helpers.fuggers_py.ratesfor rates instruments, rates quotes, fixing data, pricing, and risk. Examples: swaps, FRAs, futures, rates options,SwapQuote, fixing stores, andswap_dv01.fuggers_py.inflationfor CPI data, inflation products, and inflation analytics. Examples: CPI history, reference CPI, index ratios, TIPS helpers, and inflation swaps.fuggers_py.creditfor CDS and bond-CDS analytics. Examples: CDS instruments, CDS quotes, CDS pricing, CDS risk, and basis helpers.fuggers_py.fundingfor repo, haircut, and financing analytics. Examples: repo trades, repo quotes, haircut quotes, carry, implied repo, and specialness helpers.fuggers_py.portfoliofor holdings, portfolio analytics, and portfolio workflows. Examples:Portfolio, holdings, benchmark comparison, contribution, bucketing, ETF, liquidity, and stress helpers.
Module Hardening Standard¶
Use fuggers_py.curves as the current model for public package shape.
A hardened domain package should have:
one small public root with the names users need most often
private or focused submodules for advanced records and implementation details
one obvious public workflow for the common task, such as
YieldCurve.fit(...)clear ownership of quotes, products, pricing, risk, reports, and errors
inheritance only where shared behavior is real and easy to follow
no compatibility wrappers whose only job is to keep an old path alive
no enum or type record unless it prevents unclear inputs or repeated checks
The next pre-1.x hardening pass should review bonds, rates, funding,
credit, inflation, and portfolio against this standard. These packages are
usable now, but they still carry broader public roots, older local type records,
and enum-heavy areas that should be simplified before the compatibility promise.
Import Rules¶
Internal code can import inward to shared helpers. Public package entry points should stay shallow.
Public docs should show imports from
fuggers_pyor one first-layer public package.Public package
__init__.pyfiles should re-export concrete public names directly. They should not use lazy import routing.Domain modules can import from
_coreand_math.Domain modules should not import from
_runtimeor_storageunless the domain explicitly owns an engine or IO workflow.portfoliomay combine objects from other public packages.Other public packages should not import from
portfolio.Internal helpers inside one public package should not become cross-package utility buckets. Move shared non-domain code to
_coreor_math.
Error Rules¶
Every library exception should inherit from the shared root exception in
_core/errors.py.
Shared primitive errors live in
_core/errors.py.Numerical errors live in
_math/errors.py.Engine errors live in
_runtime/errors.py.Package-specific errors live in that package’s
errors.py.Narrow subpackage errors can live in a focused
errors.py, such asbonds/options/errors.py.Feature modules should import exception classes from an error module. They should not define library exception classes inline.
Type And Value Rules¶
Use _core for values that appear across several public packages.
Dates, currencies, identifiers, prices, yields, spreads, tenors, calendars, day-counts, and shared quote helpers belong in
_core.Values tied to one product family belong in that product package.
A type that starts as bond-only should stay in
bonds/until another package needs the same concept.Do not duplicate shared value objects to avoid importing
_core.
Numerical Rules¶
Use _math for calculation machinery that has no product meaning by itself.
Interpolation and extrapolation routines belong in
_math.Solvers and optimizers belong in
_math.Curve objects, curve specs, calibration records, and curve reports belong in
curves, because those names are part of the public API.Product pricing logic belongs in the package that owns the product.
Runtime And Storage Rules¶
Use _runtime for work coordination and _storage for IO.
_runtimecan assemble engines, track dependencies, schedule work, keep market state, and route pricing requests._storagecan load files, encode JSON, save to SQLite, store portfolios, and describe transport interfaces.Public packages should expose domain records and workflows, not storage internals.
Keep file formats and persistence choices out of product constructors unless the product workflow needs them.
Testing And Docs Rules¶
Internal modules need tests, but the public API docs should stay clean.
Unit tests may import internal modules when they test internal behavior.
Contract tests should assert the public API shape through first-layer packages.
Public API docs live under
docs/api/.Internal implementation docs live under
docs/dev/.Source-tree inventory lives in
docs/SRC_STRUCTURE.md.If a private helper becomes public, update the package API docs, export tests, typecheck files, and changelog in the same change.
Internal Root Inventory¶
The four internal survivor roots are _core, _math, _runtime, and
_storage.
fuggers_py._core¶
_core stores shared fixed-income language and primitive support code.
Path |
Purpose |
|---|---|
|
Internal aggregate for shared primitive names. |
|
Calendar identifiers used by calendars and schedules. |
|
Business-day calendars and date adjustment. |
|
Shared compounding convention values. |
|
Day-count conventions and year fractions. |
|
Shared exception root and primitive errors. |
|
Ex-dividend convention values. |
|
Shared typed identifiers for instruments, curves, portfolios, and surfaces. |
|
Shared option-side values. |
|
Shared pay/receive direction values. |
|
Shared quote-side and quote-value helpers. |
|
Shared reference-data base records and source interfaces. |
|
Settlement lag and adjustment rules. |
|
Stub-period convention values. |
|
Tenor values and tenor parsing. |
|
Shared structural protocols used by domains. |
|
Dates, currencies, prices, yields, spreads, and cashflow records. |
|
Shared yield calculation rule records. |
|
Shared yield convention values. |
fuggers_py._math¶
_math stores numerical tools used by curves and product analytics.
Path |
Purpose |
|---|---|
|
Internal aggregate for numerical helpers. |
|
Numerical exception hierarchy. |
|
Small numerical guard functions and constants. |
|
Generic numerical utility helpers. |
|
Internal aggregate for extrapolation policies. |
|
Base extrapolation interface. |
|
Flat extrapolation policy. |
|
Linear extrapolation policy. |
|
Smith-Wilson extrapolation support. |
|
Internal aggregate for interpolation routines. |
|
Base interpolation interface. |
|
Cubic-spline interpolation. |
|
Flat-forward interpolation. |
|
Linear interpolation. |
|
Log-linear interpolation. |
|
Monotone-convex interpolation. |
|
Parametric curve-shape helpers. |
|
Internal aggregate for linear-algebra helpers. |
|
LU decomposition helpers. |
|
Small linear-system solve helpers. |
|
Tridiagonal-system helpers. |
|
Internal aggregate for optimizers. |
|
Gradient-descent optimizer. |
|
Least-squares optimizer. |
|
Optimizer input and result records. |
|
Internal aggregate for one-dimensional solvers. |
|
Bisection root solver. |
|
Brent root solver. |
|
Hybrid root solver. |
|
Newton root solver. |
|
Secant root solver. |
|
Solver input and result records. |
fuggers_py._runtime¶
_runtime stores pricing-engine coordination code.
Path |
Purpose |
|---|---|
|
Internal aggregate for runtime helpers. |
|
Runtime-only shared helper records. |
|
Engine assembly helpers. |
|
Dependency graph for calculated values. |
|
Runtime configuration records. |
|
Service coordination helpers. |
|
Runtime exception hierarchy. |
|
Market-data listener interfaces. |
|
Runtime output records and publishers. |
|
Routing from pricing requests to pricing functions. |
|
Typed pricing request records. |
|
Runtime quote records. |
|
Reactive update propagation. |
|
Scheduling helpers. |
|
Market snapshot records. |
|
Runtime market-data source interfaces. |
|
Runtime market state containers. |
fuggers_py._storage¶
_storage stores persistence, file, codec, and transport helpers.
Path |
Purpose |
|---|---|
|
Internal aggregate for storage helpers. |
|
File-backed loaders, sources, and output publishers. |
|
JSON encoding and decoding helpers. |
|
Portfolio persistence helpers. |
|
SQLite-backed storage implementation. |
|
Storage protocols and shared storage records. |
|
Transport and cache interfaces for remote or deferred IO. |
Private Helpers Inside Public Packages¶
These helpers are private because the package exports the public names from its first-layer package. Use paths in developer docs and tests. Do not tell users to import these modules directly.
Bonds helpers¶
Path |
Purpose |
|---|---|
|
Shared implementation for bond instrument classes. |
|
Bond pricing implementation behind |
|
Bond risk implementation behind |
|
Bond yield engine implementation. |
|
Balance-sheet spread adjustments. |
|
Capital spread adjustments. |
|
Haircut spread adjustments. |
|
Shadow-cost spread adjustments. |
|
Par-par asset-swap implementation. |
|
Proceeds asset-swap implementation. |
|
Benchmark selection for spread calculations. |
|
Compounding and convexity spread adjustments. |
|
Discount-margin calculations. |
|
Government benchmark curve helpers. |
|
G-spread calculations. |
|
I-spread calculations. |
|
Option-adjusted spread calculations. |
|
Reference-rate decomposition helpers. |
|
Secured versus unsecured basis helpers. |
|
Sovereign benchmark helpers. |
|
Z-spread calculations. |
|
Legacy-local amortization type support behind public bond exports. |
|
Legacy-local asset-swap type support behind public bond exports. |
|
Legacy-local compounding type support behind public bond exports. |
|
Legacy-local ex-dividend type support behind public bond exports. |
|
Legacy-local identifier type support behind public bond exports. |
|
Legacy-local inflation-linked bond type support behind public bond exports. |
|
Legacy-local option type support behind public bond exports. |
|
Legacy-local price quote type support behind public bond exports. |
|
Legacy-local rate-index type support behind public bond exports. |
|
Legacy-local rating type support behind public bond exports. |
|
Legacy-local sector type support behind public bond exports. |
|
Legacy-local seniority type support behind public bond exports. |
|
Legacy-local settlement-rule support behind public bond exports. |
|
Legacy-local SOFR convention support behind public bond exports. |
|
Legacy-local stub-rule support behind public bond exports. |
|
Legacy-local tenor support behind public bond exports. |
|
Legacy-local yield convention support behind public bond exports. |
|
Legacy-local yield-rule support behind public bond exports. |
|
YAS-style analysis implementation. |
|
YAS-style calculator implementation. |
|
YAS-style settlement invoice implementation. |
|
Bond yield helpers. |
|
Current-yield helpers. |
|
Yield engine helpers. |
|
Money-market yield helpers. |
|
Short-date yield helpers. |
|
Simple-yield helpers. |
|
Yield solver helpers. |
|
Street-convention yield helpers. |
|
True-yield helpers. |
|
Private fit result used by bond relative-value workflows. |
Curves helpers¶
Path |
Purpose |
|---|---|
|
Day-count lookup helper used by curve fitting and bond quote normalization. |
|
Quote normalization helpers used by curve calibrators. |
Portfolio helpers¶
Path |
Purpose |
|---|---|
|
Shared helpers used by portfolio analytics modules. |
Rates helpers¶
Path |
Purpose |
|---|---|
|
Curve lookup and fallback logic used by rates pricing. |
|
Shared option pricing helpers. |
|
Shared option product helpers. |
Generated And Packaging Support¶
Path |
Purpose |
|---|---|
|
Generated package version metadata. Do not edit by hand. |
|
Marker file that tells type checkers this package ships type hints. |
Change Checklist¶
Use this checklist before adding or moving internal code:
The module has one clear owner.
Public users can still import from the root package or one first-layer public package.
No compatibility wrapper keeps an old path alive.
Exceptions live in the right
errors.pyfile.Shared value objects are not duplicated across packages.
Product-specific code stays with the product package.
Numerical machinery without product meaning stays in
_math.Runtime coordination stays in
_runtime.Persistence and IO helpers stay in
_storage.Public docs, dev docs, contracts, typecheck files, and changelog stay aligned.