Skip to main content

Module price

Module price 

Source
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

OperationResultNotes
Price + PricePricePrecision is max of both operands.
Price - PricePricePrecision is max of both operands.
Price + DecimalDecimal
Price - DecimalDecimal
Price * DecimalDecimal
Price / DecimalDecimal
Price + f64f64
Price - f64f64
Price * f64f64
Price / f64f64
-PricePrice

§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 Price representing 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 value is positive.
decode_raw_price_i64
The raw i64 price has already been scaled by 10^9. Further scale it by the difference to FIXED_PRECISION to make it high/defi-precision raw price.

Type Aliases§

PriceRaw