Skip to main content

Exchange rates

Quantaprice supports pricing in multiple currencies, with exchange rates updated automatically. The rates convert prices between currencies when prices are calculated. For how currencies, quantity breaks and customer prices combine in one price query, see Multi-currency pricing and price breaks.

How it works​

Exchange rates come from the daily feed of the European Central Bank (ECB). Rates are stored against EUR, and a conversion between any two supported currencies is calculated automatically through EUR.

For example, to convert USD to SEK:

text
Given: 1 EUR = 1.20 USD, 1 EUR = 12.00 SEK
Result: 1 USD = (1/1.20) x 12.00 = 10.00 SEK

Where conversion fits in the calculation​

Prices are calculated in this order:

Rules → Currency conversion → VAT → Rounding → Sales price

Currency conversion applies when a price query asks for a currency other than the pricelist's own.

Automatic rate updates​

When automatic updates are on, which is the default, the latest ECB rates are fetched once every 24 hours. The fetch has no fixed time of day; to fetch immediately, call POST /fx/fetch.

While a tenant has no rates, as is the case for a new tenant, the fetch retrieves the ECB's rates for the last 90 days, each in force from the day it was published. A price query for a moment within those 90 days converts with the rate in force at that moment.

To turn off automatic updates:

text
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 look up a rate, Quantaprice uses:

  1. The most recent rate on or before the requested date, if there is one.
  2. Otherwise, the earliest rate after the requested date.

As a result:

  • You always get a rate, even when there is none for the exact date (for example, at weekends and on holidays).
  • The response includes the publication date of the rate used, so you can see which rate was applied.

Example​

Rates exist for 2 and 3 January (1 January is a holiday):

Requested dateRate returnedWhy
31 Dec2 Jan rateNo earlier rate exists, so the first available rate is used
2 Jan, 11:002 Jan rateMost recent rate on or before the date
4 Jan3 Jan rateMost recent rate on or before the date

Supported currencies​

Every currency in the ECB's daily feed (about 30), each of which also exists as a currency. They include:

USD, GBP, JPY, CHF, AUD, CAD, NZD, CNY, SEK, NOK, DKK, SGD, HKD, INR, BRL, TRY, ZAR, and more.

The ECB publishes every rate against EUR. Converting inherited prices starts from the tenant's base currency instead: EUR, unless fx.base.currency sets another.

To see the current list:

GET/fx/currencies

API reference​

Get an exchange rate​

GET/fx/rate?base=USD&quote=SEK&asOf=2025-01-15T00:00:00Z
ParameterRequiredDescription
baseYesBase currency code (three-letter ISO code)
quoteYesQuote currency code (three-letter ISO code)
asOfNoThe moment to look up the rate for (ISO 8601). Defaults to now.

Response (200):

json
{
"base": "USD",
"quote": "SEK",
"asOf": "2025-01-15T00:00:00Z",
"rate": 10.45
}

The asOf in the response is the publication date of the rate used, which can differ from the requested date. The rate is the ECB rate without your markup: the markup applies only when converting inherited prices.

Response (400): base or quote is missing, or asOf is not a valid timestamp.

Response (404): there is no rate for the pair. An unknown currency code also returns 404.

List every rate against EUR​

GET/fx/rates?asOf=2025-01-15T00:00:00Z

Returns each currency's rate against EUR at asOf (now, if you leave it out), and the day from which that rate applies. For a moment before a currency's first rate, the first rate applies, as in the lookup above.

Response (200):

json
{
"as_of": "2025-01-15T00:00:00Z",
"rates": [
{ "currency": "SEK", "rate": 11.2, "valid_from": "2025-01-15T00:00:00Z" },
{ "currency": "USD", "rate": 1.08, "valid_from": "2025-01-14T00:00:00Z" }
]
}

Fetch rates immediately​

POST/fx/fetch

Fetches the latest ECB rates immediately, whatever the automatic schedule. While no rate is stored, it fetches the rates for the last 90 days instead. Use it after the initial setup, or when you need the latest rates straight away.

Set rates manually​

text
POST /fx/daily
Content-Type: application/json

{
"date": "2025-01-15",
"rates": {
"USD": 1.08,
"GBP": 0.85,
"SEK": 11.2
}
}

Each rate is given against EUR: the number of units of the currency per 1 EUR. The rates apply from 00:00 UTC on date. An entry that is not a three-letter code with a number is skipped; if no entry is left, the response is 400.

Response: 202 Accepted

Note: If you set a rate for a day for which the ECB also publishes a rate, your rate is replaced when the ECB rates for that day are fetched, up to 24 hours later. To keep your own rates, turn off automatic updates.

Setting a rate does not create the currency. For a currency that the ECB does not publish, create the currency with POST /currency before you create pricelists in it.

List supported currencies​

GET/fx/currencies

Returns EUR and every currency that has a rate, whether fetched from the ECB or set by you: {"currencies": ["AUD", "BGN", ...]}.

Converting inherited prices​

A pricelist that inherits from a parent in another currency receives the parent's prices converted to its own currency; see Pricelist inheritance. The conversion uses each currency's own rate, which is kept separate from the daily ECB rates above:

text
rate = ECB rate from the base currency × (1 + markup)

Between two currencies that are not the base currency, the rate is calculated through EUR, with both ECB rates from the same day, and only the target currency's markup applies. No markup applies to a conversion into the base currency. At weekends and on holidays, the latest ECB rate is used.

The converted price is kept to four decimals, rounded half up, like every stored price. The rounding profile then rounds that price. For example, with EUR as the base currency, a markup of 4%, an ECB rate of 11.2345 SEK per EUR and rounding to the nearest 0.10:

text
99.95 EUR × 11.2345 × 1.04 = 1167.803806 SEK → 1167.8038 SEK → 1167.80 SEK
4.84 EUR × 11.2345 × 1.04 = 56.5499792 SEK → 56.5500 SEK → 56.60 SEK

When a rate is renewed​

A rate stays unchanged, without smoothing, until one of the following happens. It is then renewed from that moment.

  • The ECB rate has moved past a threshold since the last renewal. There are two thresholds: the weakening threshold, for more units per unit of the base currency, and the strengthening threshold, for fewer. A move exactly to the threshold does not renew the rate. For example, with an ECB rate of 10.00 at the last renewal, a weakening threshold of 1% and a strengthening threshold of 2%, rates of 10.10 and 9.80 change nothing, while 10.11 and 9.79 renew the rate.
  • A new markup changes the price by more than a threshold. A higher markup is compared with the weakening threshold, and a lower one with the strengthening threshold. A smaller change takes effect at the next renewal.
  • The base currency changes. Every rate is then renewed.

Rates are compared after every ECB fetch, and a new threshold applies from the next comparison. A renewed rate gives the converted prices new versions from that moment; earlier versions are never changed.

Markup and thresholds​

SettingDefaultAllowed
fx.base.currencyEURA currency with an ECB rate
fx.markup.percent0Above -100
fx.threshold.weakening.percent20 or more
fx.threshold.strengthening.percent20 or more

These settings apply to every currency. A currency can override any of the three percentages with its own value through PUT /fx/conversion/{currency}. A value out of range is refused with 400. If the markup is above 0 and the weakening threshold is equal to or greater than it, the value is stored with a warning: the currency can then weaken by the whole markup before its rate is renewed. The warning states how far below the ECB rate converted prices can fall: with a 1% markup and a 2% weakening threshold, up to 0.98%. The base currency is never converted, so it gets no warning.

fx.markup.percent and fx.base.currency take effect as soon as they are written: a write with an updated_at in the future is refused with 400.

text
PUT /settings/fx.markup.percent
Content-Type: application/json

{ "value": "4" }

List each currency's conversion values​

GET/fx/conversion

Response (200):

json
{
"currencies": [
{
"currency": "SEK",
"base_currency": "EUR",
"ecb_rate": 11.2345,
"ecb_valid_from": "2025-01-15T00:00:00Z",
"rate": 11.68388,
"rate_valid_from": "2025-01-15T16:05:12Z",
"markup_percent": 4,
"markup_source": "currency",
"weakening_threshold_percent": 2,
"weakening_threshold_source": "global",
"strengthening_threshold_percent": 2,
"strengthening_threshold_source": "global",
"warnings": [],
"unconverted_pricelists": []
}
]
}

ecb_rate is the current ECB rate against the base currency. rate is the rate at which inherited prices are converted, and rate_valid_from is when that rate took effect. Each *_source is global when the value follows the setting, and currency when the currency has its own value. unconverted_pricelists lists the pricelists in the currency that still inherit from another currency without conversion; they are converted once the currency has its own values.

Set a currency's own values​

text
PUT /fx/conversion/SEK
Content-Type: application/json

{ "markup_percent": 4, "weakening_threshold_percent": 1 }

A value that you leave out or set to null follows the setting again. The response is the currency's entry, in the same form as in the list above.

Response (400): a value is out of range or is not a number.

Response (404): the currency does not exist.

List a currency's rate changes​

GET/fx/conversion/SEK/changes

Returns every change to the currency's rate, oldest first, under changes: base_currency, ecb_rate and ecb_valid_from, markup_percent, rate, reason (first, ecb_moved, markup_changed, base_currency_changed) and valid_from. From these, you can recalculate any converted price afterwards.

Rate history​

Every historical rate is kept permanently; old rates never expire and are never removed. This means prices can be calculated accurately for any past date.

Manual rates and overrides​

Use POST /fx/daily to set your own rates for specific dates. Common uses:

  • Backtesting with known historical rates
  • Loading rates in advance, before the ECB publishes them
  • Your own exchange rates, such as internal or negotiated rates

Rates you set are stored in the same way as fetched rates, and the same date-based lookup applies to them.