Table of Contents

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

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

  1. Working with Money<TCurrency> - the monetary core; everything else builds on it.
  2. Monetary precision & unit pricing - when a price is finer than the currency settles at: explicit scale, deferred rounding, and precision-preserving JSON.
  3. Working with exchange rates - the provider contracts and editing surface for crossing currencies.
  4. Exchange-rate types and lookups on a known dataset - reference material; dip in when choosing a type or tuning a lookup policy.
  5. Caching exchange rates - add a TOML disk cache in front of any provider, with per-provider expiry.
  6. JSON serialization - the Bodu.Financial.Serialization.Json companion: the converters, the three wire shapes, and the AddFinancialJsonConverters() / AddFinancialJson() registrations.
  7. Configuring providers from appsettings and configuring rate caching - the options each provider and cache backend binds, with worked configuration files.
  8. Writing your own web provider - subclass WebRateProvider or PairWebRateProvider<TSeries> when no built-in feed fits.
  9. Dependency injection - last, once you know which services your application composes.
  10. 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