Skip to content

Commit

Permalink
Add more specs for YIP-0001 (#120)
Browse files Browse the repository at this point in the history
  • Loading branch information
mnaichuk authored Nov 27, 2023
1 parent 6e5cddf commit 97aeb26
Showing 1 changed file with 25 additions and 8 deletions.
33 changes: 25 additions & 8 deletions docs/YIP/YIP-0001-price-precision.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## Status

In Work
Approved

## Context

Expand All @@ -14,16 +14,33 @@ In the context of YN, we must have a network global configuration to make member

## Decision

Significant figures, also known as the precision of a number in positional notation, are digits in the number that are reliable and necessary to indicate the quantity of something.
### Definitions

The precision level of all trading prices is calculated based on significant figures. Yellow members uses seven (7) significant digits for the prices of all pairs of the network.
**Price** - asset price in quote currency.

Some examples of five significant digits are 1.0234, 10.234, 120.34, 1234.5, 0.012345, and 0.00012340.
**Quantity** - in trading, usually refers to the number of units or shares
of a particular security or asset that is being bought or sold.
For instance, if an investor buys 100 shares of a company's stock, the quantity in this case is 100.

This is similar to how traditional global markets handle the precision of small, medium, and large values. The reasoning behind this is that the number of decimals becomes less important as the amount increases. The opposite is true for minimal amounts, where greater precision is more valuable.
| Number | Round to |
| ----------- | ----------- |
| Price | 18 |
| Quantity | 8 |

**Significant figures** (also known as the precision of a number in positional notation) - are digits in the number that are reliable and necessary to indicate the quantity of something.

The precision level of all trading prices is calculated based on significant figures. Yellow members shall use five (5) significant digits for the prices of all pairs of the network.
Alternative options for significant figures are in range of 5 - 8.

Some examples of _five significant digits_ are 1.0234, 10.234, 120.34, 1234.5, 0.012345, and 0.00012340.

This is similar to how traditional global markets handle the precision of small, medium, and large values. The reasoning behind this is that the number of decimals becomes less important as the quantity increases. The opposite is true for minimal amounts, where greater precision is more valuable.

Quantity precision allows up to 8 decimals. Anything exceeding this shall be rounded to the 8th decimal.

## Consequences

1. All API outputting prices should be truncated and formation using seven (7) significant figures
2. All API input must reject orders where prices are lower in precision
3. All frontend and UI clients should truncate order price input to seven (7) significant figures
1. All API outputting prices shall be truncated and formation using five (5) significant figures
2. All API input shall return an error for orders where prices or amounts exceed 18 and 8 precision respectfully
3. All frontend and UI clients shall truncate order price input to five (5) significant figures
4. Backend and UI pkgs shall support easy change of significant figures in range of 5 - 8.

0 comments on commit 97aeb26

Please sign in to comment.