# How a composite rate is calculated

When CryptFolio needs to convert one currency value to another on a given date – for example, when calculating your historical values, or your inventory reports – there are many different techniques that the rate can be calculated or selected.

## Existing valuation

If a transaction has a valuation defined manually, then that value in that valuation currency will be used (and converted through a composite rate if necessary). Otherwise, the value is calculated using a composite rate, as defined below.

## What pairs are used?

By default, we use the following priority, to calculate a composite rate for any two given currencies.

1. Identical currencies
• If we are looking to convert BTC to BTC, then we assert that the exchange rate is identity (1.0).
2. A direct currency to currency rate
• If we are looking to convert BTC to NZD, and we have an exchange rate on that date for that currency pair (for any exchange), we will prefer to use that exchange rate, rather than going through a third party currency. We first select exchanges that are not currently deprecated (to encourage consistency), and then we select the exchange that has the longest available data.
3. A direct currency to currency (inverse) rate
• If we are looking to convert BTC to NZD, and we have an exchange that provides NZD to BTC, we calculate the BTC/NZD exchange rate as the inverse of the NZD/BTC rate. We first select exchanges that are not currently deprecated (to encourage consistency), and then we select the exchange that has the longest available data.
4. Through intermediary currencies (fiat-to-fiat)
• If we do not have a direct exchange rate, then we calculate the exchange rate by composing different exchange rates together, using the shortest route that we can find, using steps 1-3 above.
• If both exchange currencies are fiat currencies, then we will only use US Dollar (USD) or Euro (EUR) as an intermediary currency (in order). This is to reduce volatility incurred when going through cryptocurrency exchanges.
5. Through intermediary currencies (cryptocurrencies)
6. Gaps in data
• Finally, if we are missing exchange data for a given date, but we usually have exchange rate data for that pair, then we will use the next available rate in date descending order.
• For example, if we are looking for EUR/NZD on 26 May, but we do not have data for that date, then we will use the the exchange rate on 25 May, or 24 May, etc.
7. No data
1. If we have gone through all of these steps and still cannot find a composite exchange rate, we will declare the currencies can not be converted.

## What time is used for a rate?

For latest conversions, CryptFolio will use the last rate for that exchange pair.

For conversions at a given time, we can calculate composite rates on an hourly basis, if all of the exchanges involved in that composition support that resolution. If one of the exchanges does not support an hourly resolution, then per #6 (Gaps in Data) we fall back to the earlier data for that day.

To calculate the value as at 01:50 UTC, we use the closing rate (close) for that day as at 01:59:59 UTC. For daily conversions, we use the closing rate (close) for that date as at 23:59:59 UTC.

For our inventory reports, we calculate balances as at 00:00 UTC for each day, as most existing financial software and processes expect exchange rates to be calculated only once per day.

In the future, CryptFolio will provide paid users with options for accessing higher-resolution conversions.

### Do conversions consider the depth of the order book?

No, only the raw closing price is used, and the available volume is not considered. If you need to consider the depth of order books for example, your portfolio value is extremely high, and you have regulatory or financial requirements for this additional resolution please get in touch.

## Examples

To illustrate this behaviour, consider a date 2017-01-01 which has the following exchange rates available:

 Exchange Exchange pair Exchange rate Data available Bitstamp BTC/USD 200.00 5 years Bitstamp BTC/LTC 0.01 3 years BTC-e BTC/LTC 0.02 2 years Fixer.io EUR/USD 1.16 5 years Fixer.io EUR/NZD 1.67 5 years Ethplorer.io BTC/ETH 0.05 2 years Ethplorer.io ETH/ABC 12.34 1 years Ethplorer.io DEF/ABC 1000.00 1 years

We would calculate the following composite rates, according to the rules above:

 Exchange pair requested Exchanges used Currencies used Calculated composite rate Per rules USD/USD none n/a 1.00 #1, currencies are identical BTC/USD Bitstamp BTC -> USD 200.00 #2, using direct USD/BTC Bitstamp USD -> BTC 0.005 #3, using direct inverse = 1/200.0 BTC/LTC Bitstamp BTC -> LTC 0.01 #2, prefer exchange pair with more data LTC/BTC Bitstamp LTC -> BTC 100.00 #3, prefer exchange pair with more data, using direct inverse = 1/100.0 USD/NZD Fixer.io, Fixer.io USD -> EUR -> NZD 1.43 #4, fiat intermediary currencies = (1/1.16) * 1.67 ABC/BTC Ethplorer.io, Ethplorer.io ABC -> ETH -> BTC 1.62 #5, crypto intermediary currencies = (1/12.34) * (1/0.05) ABC/NZD Ethplorer.io, Ethplorer.io, Bitstamp, Fixer.io, Fixer.io ABC -> ETH -> BTC -> USD -> NZD 466.66 #5, crypto and fiat intermediary currencies = (1/12.34) * (1/0.05) * 200.00 * (1/1.16) * 1.67 DEF/NZD none n/a n/a #7, could not calculate a composite rate using the available intermediary currencies

## Configuring this behaviour

For any composite rate used on CryptFolio, you can view which exchanges were used to calculate the rate, by clicking on the (?) next to the rate:

In the future, all of this behaviour will become configurable on an account level for premium users if necessary – if you need this functionality immediately, please get in touch.