Module utils
Expand description
Utility functions and constants.
Structs§
- Decimal
Conversion Error - Error type for decimal to f64 conversion failures.
- Parsed
Symbol - Parsed symbol components.
Enums§
- Expiry
Date Conversion Error - Error returned when converting a YYYYMMDD expiry code to a Unix timestamp.
- Instrument
Kind - High-level instrument family parsed from a venue symbol.
- Strike
Scale Error - Error returned when scaling a strike to exact 1e8 integer precision.
Constants§
- CONTRACT_
UNIT_ MULTIPLIER - Constant for contract unit conversion (6 decimal places).
- CONTRACT_
UNIT_ MULTIPLIER_ DECIMAL - Decimal constant for contract unit conversion (6 decimal places).
- MAX_
PRICE_ SIGNIFICANT_ FIGURES - Maximum significant figures allowed for prices.
- STRIKE_
SCALE_ 1E8 - Decimal scaling factor used by option strikes in on-chain contracts.
- STRIKE_
SCALE_ 1E8_ DECIMAL - Decimal representation of
STRIKE_SCALE_1E8.
Functions§
- classify_
instrument_ symbol - count_
significant_ figures - Count significant figures in a price string.
- decimal_
to_ f64_ checked - Convert Decimal to f64 for calculations, returning error on failure.
- expiry_
date_ to_ timestamp - Convert expiry date (YYYYMMDD format) to Unix timestamp.
- expiry_
date_ to_ timestamp_ at_ time_ checked - Convert a YYYYMMDD expiry code to a Unix timestamp at an explicit UTC time of day.
- expiry_
date_ to_ timestamp_ checked - Convert a YYYYMMDD expiry code to a Unix timestamp using the underlying’s configured expiry time of day (default 08:00 UTC).
- get_
timestamp_ millis - Get current timestamp in milliseconds.
- is_
option_ symbol - is_
perp_ symbol - round_
to_ sig_ figs - Round a value to a specified number of significant figures.
- strike_
to_ e8 - Convert a strike to an exact 1e8-scaled integer.
- to_
contract_ units - Convert human-readable size to contract units.
- to_
contract_ units_ decimal - Convert human-readable size (Decimal) to contract units (Decimal).
- to_
human_ readable - Convert contract units to human-readable size.
- to_
human_ readable_ decimal - Convert contract units (Decimal) to human-readable size (Decimal).
- validate_
price_ precision - Validate that a price has at most the specified number of significant figures.