Bodu.Financial.ExchangeRates
1.0.0
dotnet add package Bodu.Financial.ExchangeRates --version 1.0.0
NuGet\Install-Package Bodu.Financial.ExchangeRates -Version 1.0.0
<PackageReference Include="Bodu.Financial.ExchangeRates" Version="1.0.0" />
<PackageVersion Include="Bodu.Financial.ExchangeRates" Version="1.0.0" />
<PackageReference Include="Bodu.Financial.ExchangeRates" />
paket add Bodu.Financial.ExchangeRates --version 1.0.0
#r "nuget: Bodu.Financial.ExchangeRates, 1.0.0"
#:package Bodu.Financial.ExchangeRates@1.0.0
#addin nuget:?package=Bodu.Financial.ExchangeRates&version=1.0.0
#tool nuget:?package=Bodu.Financial.ExchangeRates&version=1.0.0
Bodu.Financial.ExchangeRates
API stability — Stable. The public API surface is committed; breaking changes are reserved for a major-version bump per SemVer.
The web exchange-rate provider infrastructure for the Bodu.Financial
FX stack. It hosts the abstract WebRateProvider and PairWebRateProvider<TSeries> base
classes that every per-source provider package — BoE, ECB, RBA, Yahoo, OFX, XE, OANDA, Fixer, exchangerate.host, FRED, IMF —
builds on, plus the shared fetch machinery they have in common. Factoring this layer out
keeps the core Bodu.Financial package free of HTTP machinery (and of any logging
dependency); reference this package only when you consume one of the web providers or
write your own.
All types live in the same flattened Bodu.Financial.ExchangeRates namespace as the core
FX types (ExchangeRate, IRateProvider / IDatedRateProvider, RateSeries, …) shipped
by Bodu.Financial, so a single using Bodu.Financial.ExchangeRates; covers both.
using Bodu.Financial.ExchangeRates;
// A minimal pair-serving provider over the shared base: supply a source that
// fetches one currency pair's observations for a date range, and the base adds
// accumulation, snapshotting, lookup resolution, and request coalescing.
public sealed class AcmeRateProvider : PairWebRateProvider<AcmeSeriesInfo>
{
public AcmeRateProvider(AcmeRateProviderOptions options)
: base(new AcmeSource(options), options, logger: null, ownedHttpClient: null, timeProvider: null) { }
}
What the base classes provide
WebRateProvider— the abstract HTTP-backed dated-provider base. It accumulates fetched observations into an immutable book / snapshot, serves the fullIDatedRateProvider/IRateProviderlookup matrix over that snapshot, coalesces concurrent loads of the same window, and either builds and owns itsHttpClientfrom the options or borrows a caller-supplied one. Each provider advertises how far back it serves rates throughHistoryAvailability(aRateHistoryAvailability— unbounded, a fixed earliest date, or a rolling window).PairWebRateProvider<TSeries>— the specialisation for sources that fetch a distinct series per currency pair (the shape of the Yahoo, OFX, XE, OANDA, Fixer, exchangerate.host, FRED, and IMF feeds), driven by anIPairRateSource<TSeries>.WebRateProviderOptions— the abstract options base carryingBaseAddress,HttpTimeout,UserAgent,DefaultLookback,CurrencyAliases, and the per-stage log levels every derived options type inherits.
Shared fetch machinery
IPairRateLoader/IPairRateSource<TSeries>,CurrencyPairRequest(from the core package), andPairRateData<TSeries>— the pair-based fetch contract (GetPairAsync), the request struct (pair + inclusive date range), and the result record (pair, observations, source-specific series metadata).SingleFlightCoordinator<TKey>— keyed single-flight coordination that coalesces concurrent loads of the same key onto one in-flight operation (RunAsync/RunAsync<TResult>), used by the base to deduplicate endpoint fetches.FileSystemByteCache<TKey>— the abstract base for the file-feed providers' on-disk raw-response caches (best-effortTryGetCore/StoreCorekeyed by a download unit); a derived cache supplies only the file name and, optionally, a freshness rule.RateProviderHttpClientFactory— builds the ownedHttpClient(user agent, timeout) for the options-only constructor form.ExchangeRateFormatException— theFormatExceptiona provider raises when a feed's payload cannot be parsed.
HTTP client and lifetime
Providers built on the base are IDisposable and offer two construction styles:
new XProvider(options, ...)— the provider builds, owns, and disposes its ownHttpClient, created viaRateProviderHttpClientFactory.Createfrom the configured user agent and timeout. Dispose the provider (for example withusing) to release it.new XProvider(httpClient, options, ...)— you supply the client and own its lifetime; the provider never disposes a client it did not create. This is the form theBodu.Financial.ExchangeRates.DependencyInjectionpackage uses, backed byIHttpClientFactory; its genericAddWebRateProvider<TProvider, TOptions>registration handles options binding and a named, resilientHttpClientfor every provider package.
Logging
The base logs through Microsoft.Extensions.Logging.Abstractions — the package's only
non-Bodu dependency. Pass an ILogger to the constructor, or let the DI package wire one
for you. When no logger is supplied it defaults to NullLogger.Instance, so logging is
entirely opt-in and free when unused. Download-starting / download-completed /
observation-ingested / download-failed levels are individually configurable on
WebRateProviderOptions.
Dependencies
Depends on Bodu.Financial, Bodu.Core, and Microsoft.Extensions.Logging.Abstractions.
Part of the Bodu utility library.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Bodu.Core (>= 1.0.0)
- Bodu.Financial (>= 1.0.0)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.12)
-
net8.0
- Bodu.Core (>= 1.0.0)
- Bodu.Financial (>= 1.0.0)
- Microsoft.Extensions.Logging.Abstractions (>= 8.0.2)
NuGet packages (10)
Showing the top 5 NuGet packages that depend on Bodu.Financial.ExchangeRates:
| Package | Downloads |
|---|---|
|
Bodu.Financial.ExchangeRates.DependencyInjection
Shared dependency-injection machinery for Bodu.Financial web-based exchange-rate providers. Exposes AddWebRateProvider on IFinancialServiceBuilder, handling HttpClient configuration with Polly resilience, options binding, and singleton registration so each provider package delegates its registration plumbing here. |
|
|
Bodu.Financial.ExchangeRates.Rba
Reserve Bank of Australia (RBA) historical exchange-rate provider for Bodu.Financial. Downloads and parses the RBA's published daily .xls files and serves them as Bodu.Financial.ExchangeRates.ExchangeRate values through IDatedRateProvider and IRateProvider, with an async range API and in-memory plus on-disk caching. Includes the dependency-injection registration extensions (AddRbaExchangeRates) that register the provider as a singleton backed by a configured HttpClient and bind RbaRateProviderOptions through Microsoft.Extensions.Options. |
|
|
Bodu.Financial.ExchangeRates.Ofx
OFX (ofx.com) exchange-rate provider for Bodu.Financial. Fetches and parses the OFX public spot-rate-history JSON service and serves the results as Bodu.Financial.ExchangeRates.ExchangeRate values through IDatedRateProvider and IRateProvider, with an async range API over arbitrary currency pairs. Includes the dependency-injection registration extensions (AddOfxExchangeRates) that bind OfxRateProviderOptions and configure a resilient named HttpClient. |
|
|
Bodu.Financial.ExchangeRates.Fixer
Fixer (fixer.io) exchange-rate provider for Bodu.Financial. Fetches and parses the Fixer time-series and historical JSON endpoints and serves the results as Bodu.Financial.ExchangeRates.ExchangeRate values through IDatedRateProvider and IRateProvider, with an async range API over currency pairs. Includes the dependency-injection registration extensions (AddFixerExchangeRates) for IServiceCollection and IFinancialServiceBuilder. |
|
|
Bodu.Financial.ExchangeRates.Ecb
European Central Bank (ECB) euro foreign-exchange reference-rate provider for Bodu.Financial. Downloads and parses the ECB's published eurofxref XML feeds and serves them as Bodu.Financial.ExchangeRates.ExchangeRate values through IDatedRateProvider and IRateProvider, with an async range API and in-memory plus on-disk caching. Includes the dependency-injection registration extensions (AddEcbExchangeRates) for Microsoft.Extensions.DependencyInjection, with options binding and a resilient named HttpClient. |
GitHub repositories
This package is not used by any popular GitHub repositories.