Skip to main content

Module utils

Module utils 

Source
Expand description

Utility functions and constants.

Structs§

DecimalConversionError
Error type for decimal to f64 conversion failures.
ParsedSymbol
Parsed symbol components.

Enums§

ExpiryDateConversionError
Error returned when converting a YYYYMMDD expiry code to a Unix timestamp.
InstrumentKind
High-level instrument family parsed from a venue symbol.
StrikeScaleError
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.
MAX_YYYYMMDD 🔒
MIN_YYYYMMDD 🔒
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
parse_deribit_expiry 🔒
Parse Deribit-style expiry (e.g., “30AUG25” -> 20250830).
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.