Bodu.Financial
Bodu.Financial is the financial-primitives library that pairs with
Bodu.Numerics. It ships the money, currency, and foreign-exchange
types that an enterprise / accounting workload needs - kept separate
from the generic numeric primitives so consumers of Fraction<T>
don't pull in the 184-currency catalogue and the FX provider stack
they don't need.
The package references Bodu.Numerics so Money<TCurrency> can
hand off to Fraction<BigInteger> for exact-arithmetic chains via
ToFraction() / FromFraction(…) / MultiplyExact(…).
What's included
Money<TCurrency>- an immutable monetary amount whose currency is encoded at the type level via anICurrencytag, so cross-currency arithmetic fails the build rather than running with the wrong unit at runtime.Money- the runtime-tagged sister type for "currency unknown until deserialisation" scenarios.MoneyBag- immutable mixed-currency portfolio with aggregate-then-round and round-each-then-sum policies.CurrencyRegistry- runtime ISO-to-metadata lookup, populated from the source-generated catalogue.- FX provider stack:
IRateProviderfor timeless rates plusIDatedRateProviderfor dated lookups with full audit metadata (ExchangeRate,RateSeries,FixedDatedRateProvider; grouping viaAggregatingRateProvider). - FX editing surface:
RateSeriesBuilderas the mutable companion toRateSeries, plusRateTableBuilderfor multi-pair / multi-provider import workflows that produce immutable snapshots. Live providers export those snapshots back out - see Snapshotting and exporting rates.
Guides
Working with Money<TCurrency>
Type-parameter currency, allocation, conversion, exact-arithmetic chains, formatting and parsing, cash rounding, and the runtime-tagged Money / MoneyBag companions.
Monetary precision & unit pricing
Sub-minor-unit prices - a 6-dp share price in 2-dp USD - via explicit-scale Money and unrounded CalculatedMoney, with the scale preserved through arithmetic and every JSON wire shape.
Working with exchange rates
The FX provider stack - timeless vs. dated contracts, the audit-grade RateLookupResult, provider grouping via the aggregator, and the RateSeriesBuilder + RateTableBuilder editing surface.
Exchange-rate types - a usage-scenario catalogue
Every FX type mapped to the scenario it was defined for, with a one-line "reach for this when…" map and a decision walk-through.
Exchange-rate lookups on a known dataset
One fixed dataset run through every RateDateResolution policy, tolerance window, and the inverse / identity switches, with a results matrix.
Built-in exchange-rate providers
The eleven live-feed packages - BoE, ECB, RBA, Yahoo, OFX, XE, OANDA, Fixer, exchangerate.host, FRED, IMF - with construction, warming, the shared lookup surface, dependency injection, and snapshot export.
Caching and aggregating exchange rates
Read-through caching one provider per cache (CachingRateProvider, TOML or in-memory, per-provider expiry), and grouping many providers with AggregatingRateProvider - priority fallback, averaging, and per-FX-pair routing.
Dependency injection
Register the financial stack with AddFinancialService(...) - currency lookups, named monetary contexts, FX providers, and options binding - plus the keyed JSON options via AddFinancialJson(...) from the JSON companion.
Testing your own provider
FixedDatedRateProvider as the deterministic test double for provider consumers, and the in-repository contract-test bases the built-in providers pass.
Reading path
- Working with
Money<TCurrency>- the monetary core; everything else builds on it. - Monetary precision & unit pricing - when a price is finer than the currency settles at: explicit scale, deferred rounding, and precision-preserving JSON.
- Working with exchange rates - the provider contracts and editing surface for crossing currencies.
- Exchange-rate types and lookups on a known dataset - reference material; dip in when choosing a type or tuning a lookup policy.
- Caching exchange rates - add a TOML disk cache in front of any provider, with per-provider expiry.
- JSON serialization - the
Bodu.Financial.Serialization.Jsoncompanion: the converters, the three wire shapes, and theAddFinancialJsonConverters()/AddFinancialJson()registrations. - Configuring providers from
appsettingsand configuring rate caching - the options each provider and cache backend binds, with worked configuration files. - Writing your own web provider - subclass
WebRateProviderorPairWebRateProvider<TSeries>when no built-in feed fits. - Dependency injection - last, once you know which services your application composes.
- Testing your own provider and runnable samples - the contract-test bases for consumer-written providers, and the offline sample projects under
samples/Financial/that compose everything above end to end.
See also
Bodu.Financial introduction - namespaces, headline types, scenarios.
Bodu.Financial getting started - install + minimal samples.
Numerics & Financial topic guides - the topic map; the complete financial guide list is this page, and the numerics one is its index.
Numerics & Financial topic overview - package boundaries and the decision table.
Bodu.Numericsoverview - for the underlyingFraction<T>escape hatch.