Precision, Rounding and Significant Figures
Overview
When trading digital assets, precision is critical. You may sometimes notice minor discrepancies between your own calculations and the data returned by the Trade API. These are typically due to differences in how numerical precision, rounding, and significant figures are handled.
Technical Implementation
To handle high-precision cryptocurrency values, BitGo uses specific libraries and rules.
Flooring (Truncation): Digital Asset values are always floored according to the currency's precision.
Price Rounding Logic
The convention for price rounding is standard half-up, regardless of order side.
Rule: 1.234 → 1.23, 1.235 → 1.24.
Minimum Accountable Unit (MAU)
The Minimum Accountable Unit (MAU) is the smallest tradable unit of a currency. Any calculated trade amount that is smaller than the MAU is rounded up to the MAU. This ensures that all transactions correspond to real-world currency divisions.
For example, the MAU for US Dollars (USD) is $0.01 (one cent). It's not possible to charge or pay a fraction of a cent.
MAU Example (SOL-USD)
Consider a buy order for SOL-USD where the intent is to spend a specific amount of the quote currency (USD).
- Calculated Quote Quantity: 0.0045395934 USD
- Price: 125.89 USD/SOL
- Base Quantity: 0.00003606 SOL
Because the calculated cost (0.0045... USD) is less than the MAU for USD ($0.01), it must be rounded up.
Actual Charged Quote Quantity: 0.01 USD
The same logic applies to sell orders. If the calculated proceeds were 0.0045... USD, you would receive 0.01 USD.
Significant Figures (Reconciliation)
When reconciling trade updates, values may appear mismatched if you ignore Significant Figures (sig figs). The precision of a result is limited to the operand with the least number of sig figs.
Math Concept: If A = 111.111 (6 sig figs) and B = 3.45 (3 sig figs): The result, 383.33295, must be rounded to 383 (matching B's 3 sig figs).
Reconciliation Example (SOL-USD)
You receive the following fill data:
- Base Quantity: 3.024283 SOL (raw value)
- Quote Quantity: 414.30 USD
- Price: 136.99 USD
Verifying Quote Quantity:
Clients expect Base * Price = Quote. 3.024283 * 136.99 = 414.296528... Since Price has 5 significant figures (136.99), we round the result to 5 sig figs. Result: 414.30 (matches API data).
Verifying Base Quantity:
Clients expect Quote / Price = Base. 414.30 / 136.99 = 3.02430834... The raw Base Quantity is 3.024283. Correction: Round your calculation to 5 sig figs (dictated by Price/Quote). Calculation Rounded: 3.0243. API Value Rounded: 3.0243. Result: Match.
Updated about 2 hours ago