Expand description
Represents a price in a market with a specified precision.
Price is an immutable value type for representing market prices, bid/ask quotes,
and price levels. Unlike Quantity, prices can be negative (useful for spreads,
basis trades, or certain derivative instruments).
§Arithmetic behavior
| Operation | Result | Notes |
|---|---|---|
Price + Price | Price | Precision is max of both operands. |
Price - Price | Price | Precision is max of both operands. |
Price + Decimal | Decimal | |
Price - Decimal | Decimal | |
Price * Decimal | Decimal | |
Price / Decimal | Decimal | |
Price + f64 | f64 | |
Price - f64 | f64 | |
Price * f64 | f64 | |
Price / f64 | f64 | |
-Price | Price |
§Immutability
Price is immutable. All arithmetic operations return new instances.
Structs§
- Price
- Represents a price in a market with a specified precision.
Constants§
- ERROR_
PRICE - The sentinel
Pricerepresenting errors (this will be removed when Cython is gone). - PRICE_
ERROR - The sentinel value for an error or invalid price.
- PRICE_
MAX - The maximum valid price value that can be represented.
- PRICE_
MIN - The minimum valid price value that can be represented.
- PRICE_
UNDEF - The sentinel value for an unset or null price.
Statics§
- PRICE_
RAW_ MAX - The maximum raw price integer value.
- PRICE_
RAW_ MIN - The minimum raw price integer value.
Functions§
- check_
positive_ price - Checks the price
valueis positive. - decode_
raw_ price_ i64 - The raw i64 price has already been scaled by 10^9. Further scale it by the difference to
FIXED_PRECISIONto make it high/defi-precision raw price.