Precision & Tolerances
Core Precision Concepts
Automatic Tolerance Inference
- Derived per transaction individually
- Calculated separately for each currency
- Uses half of the last significant digit
- Example:
2013-04-03 * "Buy Fund"
Assets:Fund 10.22626 FUND {37.61 USD} ; Tolerance: 0.000005 FUND
Assets:Cash -384.61 USD ; Tolerance: 0.005 USD
Transaction Weight Rules
- Simple Amount: Uses exact amount
- Price Posting: Amount × Price
- Cost Posting: Amount × Cost
- Cost+Price: Uses cost only, price ignored for balancing
Precision Inference Rules
-
Number Format
- Integer amounts do not contribute to precision
- Maximum automatic precision is 0.05 units
- Costs and prices are excluded from tolerance inference
- Multiple precisions use the coarsest (largest) value
-
Default Handling
; Global default
option "inferred_tolerance_default" "*:0.001"
; Currency-specific
option "inferred_tolerance_default" "USD:0.003"
- Tolerance Multiplier
option "inferred_tolerance_multiplier" "1.2"
- Cost-Based Inference
option "infer_tolerance_from_cost" "TRUE"
Balance Assertions
Basic Format
2015-05-08 balance Assets:Fund 4.271 RGAGX ; Tolerance: ±0.001
2015-05-08 balance Assets:Fund 4.27 RGAGX ; Tolerance: ±0.01
Explicit Tolerances
2015-05-08 balance Assets:Fund 4.271 ~ 0.01 RGAGX
Rounding Management
Rounding Error Tracking
option "account_rounding" "Equity:RoundingError"
2000-01-01 open Equity:RoundingError
2013-02-23 * "Purchase"
Assets:Invest 1.245 RGAGX {43.23 USD}
Assets:Cash -53.82 USD
Equity:RoundingError -0.00135 USD
Inferred Number Precision
-
No Tolerance Specified
- Uses full precision
- No rounding occurs
-
With Default Tolerance
option "default_tolerance" "USD:0.001"
; Number quantized to 0.001 before insertion