Bodu.Financial.ExchangeRates.Imf
0.7.1
dotnet add package Bodu.Financial.ExchangeRates.Imf --version 0.7.1
NuGet\Install-Package Bodu.Financial.ExchangeRates.Imf -Version 0.7.1
<PackageReference Include="Bodu.Financial.ExchangeRates.Imf" Version="0.7.1" />
<PackageVersion Include="Bodu.Financial.ExchangeRates.Imf" Version="0.7.1" />
<PackageReference Include="Bodu.Financial.ExchangeRates.Imf" />
paket add Bodu.Financial.ExchangeRates.Imf --version 0.7.1
#r "nuget: Bodu.Financial.ExchangeRates.Imf, 0.7.1"
#:package Bodu.Financial.ExchangeRates.Imf@0.7.1
#addin nuget:?package=Bodu.Financial.ExchangeRates.Imf&version=0.7.1
#tool nuget:?package=Bodu.Financial.ExchangeRates.Imf&version=0.7.1
Bodu.Financial.ExchangeRates.Imf
API stability — Preview. The public API surface is largely settled but is still being finalized ahead of the 1.0 release and may change; breaking changes can land in a minor version until then.
A Bodu.Financial exchange-rate provider backed by the IMF (International Monetary Fund) Representative Exchange Rates — the daily rates each issuing central bank reports to the Fund, published as a monthly report.
It downloads the IMF's monthly tab-separated report (every reported currency across each
business day of the month), parses it, and serves the results as
Bodu.Financial.ExchangeRates.ExchangeRate values through the standard IDatedRateProvider
and IRateProvider contracts — so it composes with Money.ConvertTo, the caching and
aggregating providers, and the rest of the Bodu.Financial FX stack. The same interfaces and
DI shape as every other provider, a different data source.
using Bodu.Financial.ExchangeRates;
// The provider builds and owns its HttpClient from the options; dispose it to release the client.
// The IMF report is keyless — no API key is required.
using var provider = new ImfRateProvider(new ImfRateProviderOptions());
// Warm the in-memory store for a range (recommended), then look rates up synchronously.
await provider.LoadRangeAsync(new DateOnly(2026, 4, 1), new DateOnly(2026, 4, 30));
RateLookupResult jpy = provider.GetRate("USD", "JPY", new DateOnly(2026, 4, 1));
// jpy.Rate.Rate is the number of Japanese yen per US dollar on that date.
RateLookupResult usd = provider.GetRate("JPY", "USD", new DateOnly(2026, 4, 1)); // inverted
// Discover what pairs the loaded data supports.
foreach (ImfSeriesInfo info in provider.GetAvailablePairs())
Console.WriteLine($"{info.Pair.From}/{info.Pair.To}");
Behaviour and limitations
- USD-anchored. Every rate the report publishes quotes a currency against the US
dollar, so only
USD→XandX→USDlookups are serviceable; a cross-currency pair (for exampleGBP/EUR) is rejected withRateSeriesNotFoundException. The reverse (X→USD) direction is served by the inverse-lookup fallback. - Bulk, month-based loading. One download covers every reported currency for every
business day of a month, so a request for any date in a month loads the whole month at
once.
LoadRangeAsync,LoadMonthAsync, andPreloadAsync(current month) warm the store; a range spanning several months downloads each covering month. - Direction auto-normalized. The report quotes most currencies as units per US dollar,
but marks a few (labelled
(1), for exampleEuro(1),U.K. pound(1)) as US dollars per unit. Both are normalized on ingest, so the stored rate is always units of the quote currency per one US dollar. - Keyless. The report requires no API key; there is no
ApiKeyoption. - Currency-name mapping. The report labels currencies by name (
Japanese yen,Chinese yuan, …).CurrencyNamesmaps each label to its ISO 4217 code; a label absent from the map is resolved directly against the ISO catalogue, and one that resolves neither way is skipped. ExtendCurrencyNamesto add labels not seeded by default. - Monthly cache. Downloaded reports are cached on disk (configurable). A closed
month's report is immutable and is served from cache indefinitely; only the current,
still-growing month is refreshed on a TTL (
RefreshInterval). For a durable, cross-provider cache, compose withAddCachedRateProvider<…>from theBodu.Financial.ExchangeRates.Cachingpackage.
Endpoint configuration
ImfRateProviderOptions carries working defaults and binds through
Microsoft.Extensions.Options.
| Option | Default | Purpose |
|---|---|---|
BaseAddress |
https://www.imf.org/external/np/fin/data/ |
The IMF report host. |
ReportPath |
rms_mth.aspx |
The monthly report resource path. |
ReportType |
REP |
The report-type selector (representative rates). |
EnableDiskCache |
true |
Persist downloaded reports to an on-disk cache. |
CacheDirectory |
null (temp bodu-imf) |
The on-disk cache directory. |
RefreshInterval |
12 h | How long the current month's cached report stays fresh (closed months never expire). |
CurrencyNames |
seeded | Maps IMF currency labels to ISO 4217 codes; extend to add labels. |
HttpTimeout |
30 s | Applied to the HttpClient the provider creates, or by the DI registration. |
AllowSynchronousNetworkAccess |
false |
Opt in to blocking on-demand fetches from synchronous lookups. |
HTTP client and lifetime
The provider is IDisposable and offers two construction styles:
new ImfRateProvider(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 the client.new ImfRateProvider(httpClient, options, ...)— you supply the client and own its lifetime; the provider never disposes a client it did not create. This is the form the DI registration uses, backed byIHttpClientFactory.
Dependency injection
The package ships its own AddImfExchangeRates registration in the
Bodu.Financial.ExchangeRates namespace — there is no separate *.DependencyInjection
package.
services
.AddFinancialService(configuration)
.AddImfExchangeRates(configuration);
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)
- Bodu.Financial.DependencyInjection (>= 1.0.0)
- Bodu.Financial.ExchangeRates (>= 1.0.0)
- Bodu.Financial.ExchangeRates.DependencyInjection (>= 1.0.0)
- Bodu.Text.Delimited (>= 1.0.0)
- Microsoft.Extensions.Configuration.Abstractions (>= 10.0.12)
- Microsoft.Extensions.Configuration.Binder (>= 10.0.12)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.12)
- Microsoft.Extensions.Http (>= 10.0.12)
- Microsoft.Extensions.Http.Resilience (>= 10.0.0)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.12)
- Microsoft.Extensions.Options (>= 10.0.12)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 10.0.12)
-
net8.0
- Bodu.Core (>= 1.0.0)
- Bodu.Financial (>= 1.0.0)
- Bodu.Financial.DependencyInjection (>= 1.0.0)
- Bodu.Financial.ExchangeRates (>= 1.0.0)
- Bodu.Financial.ExchangeRates.DependencyInjection (>= 1.0.0)
- Bodu.Text.Delimited (>= 1.0.0)
- Microsoft.Extensions.Configuration.Abstractions (>= 8.0.0)
- Microsoft.Extensions.Configuration.Binder (>= 8.0.2)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 8.0.2)
- Microsoft.Extensions.Http (>= 8.0.1)
- Microsoft.Extensions.Http.Resilience (>= 8.10.0)
- Microsoft.Extensions.Logging.Abstractions (>= 8.0.2)
- Microsoft.Extensions.Options (>= 8.0.2)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 8.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.