Page History
...
Prices and Quantities
Overview
Prices and Quantities are represented by PriceNULL and DecimalQtyNULL composites which comprise an int64 mantissa, and an int8 exponent.
| Warning |
|---|
These datatypes differ from the equivalents defined in The Whisperer Classic SBE3 Schema, which defines fixed scalings for each. |
Whisperer honours the implied precision of all prices and quantities passed between Client and Venue.This is achieved , and Clients should match the decimal precision provided by the Venue for both, by setting mantissa and exponent values for the relevant SBE datatypes (DecimalQtyNULL and PriceNULL) such that the original value representation is preserved exactly.
| Note | ||
|---|---|---|
| ||
A feature of FIX protocol interfaces (vs binary APIs) is that they involve an integer to string conversion when constructing the message. The way this is performed varies not only across venues, but also across individual fields or message types. The net result is that trailing zeros for a fractional component may not always be published, so that a price could move between "1.1999" and "1.2", vs the "1.2000") that would be most consistent. | ||
| Info | ||
| ||
Scaling Considerations
The maximum mantissa value is 2^63 - 1 = 9,223,372,036,854,775,807
This is because a 64-bit signed integer uses one bit for the sign (positive or negative) and the remaining 63 bits for the value.
When decimal arithmetic is performed, the new mantissa value is first calculated, and then scaled according to the combined exponents. Inappropriately set precisions may cause problems, especially when multiplications are performed (as is the case when ExecutionReport LegCalculatedCcyQty and LegAllocCalculatedCcyQty values are calculated). For example:
LegAllocQty= 1,000,000.000000000 = 1,000,000,000,000,000 * 10-9LastPx= 1.047400 = 1,047,400 * 10-6LegCalculatedCcyQty= (1,000,000,000,000,000 * 1,047,400) * 10-9-6 = 1,047,400,000,000,000,000,000 * 10-15 = 1047400.000000000000000- 1,047,400,000,000,000,000,000 > 9,223,372,036,854,775,807 and is thus not representable.
Such problems are easily avoided by ensuring that Quantities in particular are always scaled appropriately.
Negative Values
DecimalQtyNULL and PriceNULL may both be used to represent negative values:
- Negative quantities are used in pre-trade allocations to denote the opposite allocation direction vs the net direction for the leg as a whole.
- Negative prices are used to represent negative Forward Points, where appropriate.
Examples
Examples below:
| Value | Mantissa | Exponent |
|---|---|---|
| 1.2345 | 12345 | -4 |
| 1.23 | 123 | -2 |
| 1.2300 | 12300 | -4 |
| 123.00 | 12300 | -2 |
| 0.0001234 | 1234 | -7 |
| 1000000 | 1000000 | 0 |
| 1567234.56 | 156723456 | -2 |
| -0.01 | -1 | -2 |
| -500000 | -500000 | 0 |
| 0 | 0 | 0 |
| 0.0000 | 0 | -4 |
...
Taker Considerations - Orders
...