# Structure of the file with export of trade currency rates

To organize the file structure, the JSON data format is used.

It all starts with such structure:

Spaces and indents in the examples are used solely for the convenience of their perception.

Then you need to specify a list of currencies that using in applications. The list should consist of pairs **currency number: currency code**. The currency number cannot be 0, and must consist of digits from 0 to 9, and/or letters from a to z. As a currency number, you can use its number from the database or the sequency number of its appearance in the file (for example: 1, 2, ..., 9, a, ..., z, 10, ..., 1a, ...). It should all look something like this:

As you can see from the example above, currencies are specified in **currencies**, three currencies are specified there: dollars, rubles and bitcoins.

Next, we proceed to specify the currency pairs. They are specified in a special way, which as shown in the following example.

As you can already see, all currency pairs are specified in the following sequence: **trade** -> **sale currency number** -> **for** -> **purchase currency number**.

Only such a sequence, no other should be.

Now, for each currency pair, specify the list of orders. Each order is specified in the following form: **[rate, amount]** (without a space).

The **rate** must be a multiple of 1, that is, either 1 = X or X = 1, while X must be a number greater than or equal to 1. How to make the rate a multiple of 1 is described here. The rate is taken from X, and if it is in the form 1 = X then, with a minus sign.

**Amount** is the amount of currency available for purchase/sale at this rate.

*
The number of decimal places in the rate should be no more than 6, with rounding down. The number of decimal places in the sums of cryptocurrencies should be no more than 8, and for all others not more than 2. *

The example below shows the following orders to buy/sell currency:

- dollar – ruble at the rate of 1 = 55.9690, in the amount of 9339.99 rubles;
- dollar – ruble at the rate of 1 = 55.8823, in the amount of 19870.26 rubles;
- dollar – bitcoin at the rate of 8712.9922 = 1, in the amount of 0.1065 bitcoins;
- dollar – bitcoin at the rate of 8830.23641 = 1, in the amount of 0.8 bitcoins;
- ruble – dollar at the rate of 59.56108 = 1, in the amount of 99.13 dollars;
- ruble – dollar at the rate of 59.61286 = 1, in the amount of 50.47 dollars;
- ruble – bitcoin at the rate of 566500.90958 = 1, in the amount of 1.3452 bitcoins;
- ruble – bitcoin at the rate of 569378.662418 = 1, in the amount of 5.5746 bitcoins;
- bitcoin – dollar at the rate of 1 = 8544.39197 in the amount of 942.98 dollars;
- bitcoin – dollar at the rate of 1 = 8541.743498, in the amount of 2938 dollars.

## How to make rate a multiple?

Take the smaller of two numbers and divide each number of the rate into it. For instance:

- Such rate of 20 = 1254.1286, will become so 1 = 62.70643 (both numbers divided by 20).
- Such rate of 8.7435 = 0.3712, will become so 23.554687 = 1 (both numbers divided by 0.3712).