Table of Contents

ExchangeRateEnumerableExtensions Class

Definition

Namespace
Bodu.Financial.Extensions
Assembly
Bodu.Financial.dll
Package
Bodu.Financial 1.0.0
Source
ExchangeRateEnumerableExtensions.ToBook.cs

Provides extension methods that materialize sequences of ExchangeRate observations into the immutable RateBook store.

public static class ExchangeRateEnumerableExtensions
Inheritance
ExchangeRateEnumerableExtensions
Inherited Members

Methods

ToBook(IEnumerable<ExchangeRate>)

Materializes a sequence of exchange-rate observations into an immutable RateBook, one series per (pair, provider) combination.

public static RateBook ToBook(this IEnumerable<ExchangeRate> rates)

Parameters

rates IEnumerable<ExchangeRate>

The observations to store, in any order.

Returns

RateBook

An immutable book holding every distinct (pair, provider, date) observation.

Remarks

Unlike FixedDatedRateProvider(IEnumerable<ExchangeRate>), this materializer accepts rates for the same pair from multiple providers - each (pair, provider) combination becomes its own series - so the results of aggregated or multi-source range lookups round-trip without error. When two observations share the same pair, provider, and date, the later element wins (upsert semantics, matching Upsert(CurrencyPair, string, DateOnly, decimal, DateTimeOffset?)), so re-materializing overlapping fetches is resilient rather than throwing.

A rate resolved through inverse fallback (IsInverted) is stored under its natively quoted pair with the originally observed rate, rather than baking the derived reciprocal into the book; a lookup on the resulting book still resolves the derived direction through the same inverse fallback. Each series' FetchedAtUtc is set to the latest fetch instant seen among its rows, so provenance survives the round trip deterministically regardless of input order.

Exceptions

ArgumentNullException

Thrown when rates is null.

ArgumentException

Thrown when an element carries an invalid (default) currency pair.

Applies to

ProductVersions
.NET8, 10