aeat.adapters.outbound.fx._ecb_provider module

ECB euro reference-rate exchange-rate provider.

Implements the domain.currency.ExchangeRateProvider protocol over a bundled snapshot of the European Central Bank euro foreign-exchange reference rates (eurofxref XML). The ECB rates are the official exchange rate of Spanish law (Ley 46/1998 art. 36) accepted for IRPF, IVA, and PGC conversion — see the ledger-fx-conversion ADR.

The ECB publishes EUR-base quotes (1 EUR = rate CCY). The domain.currency.CurrencyNormalizationService expects get_eur_rate to return CCY->EUR (so eur = amount * rate), so this provider returns 1 / ecb_rate. The ECB publishes only on TARGET working days, so a lookup for a non-publication date falls back to the most-recent prior published date.

class EcbReferenceRateProvider(*, rates_path=None)[source]

Bases: object

EUR reference-rate provider backed by a bundled ECB eurofxref snapshot.

Parameters:

rates_path (Path | None)

get_eur_rate(currency, rate_date)[source]

Return the CCY->EUR rate for rate_date (or most-recent prior).

Returns None for EUR (handled natively upstream) or an unknown currency / a date earlier than the snapshot’s first published date.

Return type:

Decimal | None

Parameters:
default_ecb_rate_provider()[source]

Return the process-wide EcbReferenceRateProvider over the bundled ECB snapshot (cached).

Return type:

EcbReferenceRateProvider