Exchange Rates
Quantaprice supports multi-currency pricing with automatic exchange rate updates. Rates are used in the price calculation pipeline to convert between currencies.
How It Works
Exchange rates are sourced from the European Central Bank (ECB) daily feed. EUR-based rates are stored, and conversions between any two supported currencies are computed automatically via cross-rates.
For example, to convert USD to SEK:
Given: 1 EUR = 1.20 USD, 1 EUR = 12.00 SEK
Result: 1 USD = (1/1.20) x 12.00 = 10.00 SEK
Where FX fits in the price pipeline
Prices are calculated in this order:
Rules → FX Conversion → VAT → Rounding → Sales Price
FX conversion is applied when a price query requests a different currency than the pricelist's base currency.
Automatic Rate Updates
When enabled (default), the system automatically fetches the latest ECB rates:
- First fetch: ~1 second after startup
- Subsequent fetches: Every 24 hours after the previous fetch completes
- Runs on the master node only — replicas receive rate data through replication
Note: The schedule is interval-based (every 24 hours), not clock-based. There is no fixed time of day. The cycle is anchored by when the service starts.
To disable automatic updates:
PUT /settings/fx.rate.auto.update
Content-Type: application/json
{ "value": "false" }
Date-Based Rate Lookup
Every rate is stored with its publication date. When you query a rate, the system finds the best match:
- Most recent rate on or before the requested date (preferred)
- Earliest rate after the requested date (fallback, used only when no earlier rate exists)
This means:
- You always get a rate, even if the exact date isn't available (e.g. weekends, holidays)
- The response includes the actual publication date of the rate used, so you can see which rate was applied
Example
Rates exist for Jan 2 and Jan 3 (Jan 1 is a holiday):
| Requested date | Rate returned | Why |
|---|---|---|
| Dec 31 | Jan 2 rate | No earlier rate exists, uses first available |
| Jan 2, 11:00 | Jan 2 rate | Most recent on or before |
| Jan 4 | Jan 3 rate | Most recent on or before |
Supported Currencies
All currencies published in the ECB daily feed (~32 major currencies), including:
USD, GBP, JPY, CHF, AUD, CAD, NZD, CNY, SEK, NOK, DKK, SGD, HKD, INR, BRL, TRY, ZAR, and more.
EUR is always available as the base currency.
To see the current list:
GET /fx/currencies
API Reference
Get an exchange rate
GET /fx/rate?base=USD"e=SEK&as_of=2025-01-15T00:00:00Z
Response (200):
{
"base": "USD",
"quote": "SEK",
"as_of": "2025-01-15T00:00:00Z",
"rate": 10.45
}
The as_of in the response reflects the publication date of the rate that was actually used, which may differ from the requested date.
Response (404): No rate available for the requested pair.
Trigger an immediate rate fetch
POST /fx/fetch
Fetches the latest ECB rates immediately, regardless of the automatic schedule. Useful after initial setup or when you need the latest rates right away.
Manually set rates
POST /fx/daily
Content-Type: application/json
{
"date": "2025-01-15",
"rates": {
"USD": 1.08,
"GBP": 0.85,
"SEK": 11.2
}
}
Rates are specified as EUR→X (how many units of currency X per 1 EUR).
Response: 202 Accepted
Note: Manually set rates for today's date will be overwritten by the next automatic ECB fetch. To preserve manual rates, either disable auto-update or set rates for dates that won't be fetched.
List supported currencies
GET /fx/currencies
Returns the set of currency codes available from the latest ECB feed.
Rate History
All historical rates are permanently retained. There is no automatic expiration or cleanup of old rates. This allows accurate price recalculation for any past date.
Manual Rates & Overrides
Use POST /fx/daily to set custom rates for specific dates. Common use cases:
- Historical backtesting with known rates
- Pre-loading rates before ECB publishes them
- Custom exchange rates for internal or negotiated rates
Manual rates are stored identically to automatically fetched rates and participate in the same date-based lookup logic.
Related Settings
fx.base.currency— The reference currency for all rate storage and cross-rate computationfx.rate.auto.update— Enable automatic rate fetching from the ECBrequire.homogeneous.currency— Enforce same currency across pricelists in a query (disables implicit FX conversion)