DatedRateProviderExtensions Class
Definition
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
providerIDatedRateProviderThe provider to fetch from.
pairsIEnumerable<CurrencyPair>The currency pairs to materialize; duplicates are fetched once.
startDateDateOnlyThe inclusive first date of the window.
endDateDateOnlyThe inclusive last date of the window.
cancellationTokenCancellationTokenA 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
providerorpairsis null.- ArgumentException
Thrown when
pairsis empty or contains an invalid (default) pair, or whenendDateis earlier thanstartDate.
Applies to
| Product | Versions |
|---|---|
| .NET | 8, 10 |