Table of Contents

DatedRateProviderExtensions Class

Definition

Namespace
Bodu.Financial.Extensions
Assembly
Bodu.Financial.dll
Package
Bodu.Financial 1.0.0
Source
DatedRateProviderExtensions.ToFixedProviderAsync.cs

Provides extension methods that materialize the historical rates any IDatedRateProvider serves into immutable, offline-queryable snapshots.

public static class DatedRateProviderExtensions
Inheritance
DatedRateProviderExtensions
Inherited Members

Methods

ToFixedProviderAsync(IDatedRateProvider, IEnumerable<CurrencyPair>, DateOnly, DateOnly, CancellationToken)

Fetches the inclusive date window for each requested pair and materializes the results into an immutable FixedDatedRateProvider.

public static Task<FixedDatedRateProvider> ToFixedProviderAsync(this IDatedRateProvider provider, IEnumerable<CurrencyPair> pairs, DateOnly startDate, DateOnly endDate, CancellationToken cancellationToken = default)

Parameters

provider IDatedRateProvider

The provider to fetch from.

pairs IEnumerable<CurrencyPair>

The currency pairs to materialize; duplicates are fetched once.

startDate DateOnly

The inclusive first date of the window.

endDate DateOnly

The inclusive last date of the window.

cancellationToken CancellationToken

A token to observe while fetching.

Returns

Task<FixedDatedRateProvider>

A task producing an immutable provider over every rate the source returned for the requested pairs and window. A pair the source has no data for simply contributes no rows.

Remarks

Pairs are fetched sequentially through GetRatesAsync(string, string, DateOnly, DateOnly, CancellationToken) - the shipped web providers already coalesce and rate-limit their downloads, so parallel fan-out buys little and risks hammering a feed. Exceptions a source raises for an unserved pair propagate unchanged.

The result is fully decoupled from provider: later fetches, cache expiry, or disposal of the source never affect it. Rows are materialized through ToBook(IEnumerable<ExchangeRate>), so rates for the same pair from multiple sources are kept as separate series (the returned provider consults them in first-seen order), inverse-resolved rows are stored under their natively quoted direction, and each series preserves its latest fetch instant. Callers needing a specific provider-selection policy can rewrap via result.Book.ToFixedProvider(priority).

Exceptions

ArgumentNullException

Thrown when provider or pairs is null.

ArgumentException

Thrown when pairs is empty or contains an invalid (default) pair, or when endDate is earlier than startDate.

Applies to

ProductVersions
.NET8, 10