Table of Contents

EcbRateFeed Class

Definition

Namespace
Bodu.Financial.ExchangeRates
Assembly
Bodu.Financial.ExchangeRates.Ecb.dll
Package
Bodu.Financial.ExchangeRates.Ecb 0.7.1
Source
EcbRateFeed.cs

Identifies one of the eurofxref XML files in which the European Central Bank publishes its euro foreign-exchange reference rates.

public sealed class EcbRateFeed
Inheritance
EcbRateFeed
Inherited Members
Extension Methods

Remarks

Unlike a calendar-partitioned archive, the ECB publishes a small set of overlapping feeds that each end at the most recent business day and reach back a different distance: a latest-day file, a rolling ninety-day file, and the full history since 1999. A feed is therefore characterized by its look-back window rather than a fixed date range, exposed through LookbackDays, and the earliest date it is expected to contain is computed relative to a reference date via EarliestDate(DateOnly).

The default catalogue is exposed through Default. The named singletons Daily, Last90Days, and Full let callers compose a custom catalogue, and the file names can be overridden through the provider options if the ECB changes them.

Constructors

EcbRateFeed(string, string, int?)

Initializes a new instance of the EcbRateFeed class.

public EcbRateFeed(string name, string fileName, int? lookbackDays)

Parameters

name string

The feed label.

fileName string

The feed file name, relative to the provider's base URL.

lookbackDays int?

The number of days back from a reference date the feed is expected to cover, or null when the feed carries the full history since Epoch.

Exceptions

ArgumentNullException

Thrown when name or fileName is null.

ArgumentOutOfRangeException

Thrown when lookbackDays is negative.

Properties

Daily

Gets the latest-day feed (eurofxref-daily.xml), containing only the most recent published rates.

public static EcbRateFeed Daily { get; }

Property Value

EcbRateFeed

The latest-day feed, with a four-day look-back to tolerate weekends and holidays.

Default

Gets the default catalogue of ECB feeds, ordered from the narrowest look-back to the widest.

public static IReadOnlyList<EcbRateFeed> Default { get; }

Property Value

IReadOnlyList<EcbRateFeed>

The ordered, immutable default feed catalogue: the ninety-day feed followed by the full-history feed.

Remarks

The latest-day feed is omitted from the default catalogue because the ninety-day feed already contains the most recent day; include Daily explicitly when a minimal latest-only download is preferred.

Epoch

Gets the first date for which the ECB publishes euro reference rates.

public static DateOnly Epoch { get; }

Property Value

DateOnly

4 January 1999, the start of the euro reference-rate series.

FileName

Gets the file name of the feed, relative to the provider's base URL.

public string FileName { get; }

Property Value

string

The feed file name (for example, eurofxref-hist.xml).

Full

Gets the full-history feed (eurofxref-hist.xml), containing every published day since Epoch.

public static EcbRateFeed Full { get; }

Property Value

EcbRateFeed

The full-history feed.

IsFullHistory

Gets a value indicating whether the feed carries the full history rather than a bounded look-back window.

public bool IsFullHistory { get; }

Property Value

bool

true when LookbackDays is null; otherwise false.

Last90Days

Gets the rolling ninety-day feed (eurofxref-hist-90d.xml).

public static EcbRateFeed Last90Days { get; }

Property Value

EcbRateFeed

The ninety-day feed.

LookbackDays

Gets the number of days back from a reference date the feed is expected to cover.

public int? LookbackDays { get; }

Property Value

int?

The look-back window in days, or null for the full-history feed.

Name

Gets the feed label (for example, hist-90d).

public string Name { get; }

Property Value

string

The feed label.

Methods

Covers(DateOnly, DateOnly)

Determines whether the feed is expected to cover the specified date relative to a reference date.

public bool Covers(DateOnly date, DateOnly asOf)

Parameters

date DateOnly

The date to test.

asOf DateOnly

The reference date, typically the current date.

Returns

bool

true when date is on or after the feed's earliest expected date; otherwise false.

EarliestDate(DateOnly)

Computes the earliest date the feed is expected to contain relative to a reference date.

public DateOnly EarliestDate(DateOnly asOf)

Parameters

asOf DateOnly

The reference date, typically the current date.

Returns

DateOnly

Epoch for the full-history feed; otherwise asOf shifted back by LookbackDays days.

ForDate(DateOnly, IReadOnlyList<EcbRateFeed>, DateOnly)

Finds the narrowest feed in feeds expected to cover the specified date.

public static EcbRateFeed? ForDate(DateOnly date, IReadOnlyList<EcbRateFeed> feeds, DateOnly asOf)

Parameters

date DateOnly

The date to resolve.

feeds IReadOnlyList<EcbRateFeed>

The feed catalogue to search, ordered from narrowest to widest look-back.

asOf DateOnly

The reference date, typically the current date.

Returns

EcbRateFeed

The covering feed, or null when no feed covers date.

Exceptions

ArgumentNullException

Thrown when feeds is null.

Applies to

ProductVersions
.NET8, 10