Expand description
Const fn utility functions for compile-time evaluation
This module contains simple, pure functions that can be evaluated at compile time. These utilities provide performance benefits by computing values during compilation rather than at runtime.
Functionsยง
- array_
len - Array and slice utilities Get the length of a static array at compile time
- bps_
to_ percent - Calculate percentage from basis points
- buffer_
size_ power_ of_ two - Buffer sizing utilities Calculate buffer size rounded up to next power of 2
- bytes_
to_ kb - Type conversions Convert bytes to kilobytes (1024 bytes = 1 KB)
- bytes_
to_ mb - Convert bytes to megabytes (1024 * 1024 bytes = 1 MB)
- cache_
aligned_ size - Calculate cache-line aligned size (64 bytes)
- const_
max_ i64 - Calculate the maximum of two i64 values at compile time
- const_
max_ u64 - Mathematical constants and operations Calculate the maximum of two u64 values at compile time
- const_
min_ i64 - Calculate the minimum of two i64 values at compile time
- const_
min_ u64 - Calculate the minimum of two u64 values at compile time
- exchange_
default_ websocket_ port - Get default WebSocket port for exchange
- exchange_
max_ api_ key_ length - Calculate maximum API key length for exchange
- exchange_
max_ signature_ length - Authentication and security utilities Calculate maximum signature length for exchange authentication
- exchange_
max_ websocket_ message_ size - Calculate maximum WebSocket message size for exchange
- exchange_
optimal_ batch_ size - Performance and optimization utilities Calculate optimal batch size for exchange message processing
- exchange_
reconnection_ delay_ ms - Calculate reconnection delay for exchange (exponential backoff)
- exchange_
requires_ custom_ ping - Check if exchange requires custom ping message format
- exchange_
requires_ passphrase - Check if exchange requires passphrase for authentication
- exchange_
supports_ websocket_ compression - WebSocket and networking utilities Check if an exchange supports WebSocket compression at compile time
- exchange_
websocket_ ping_ interval_ ms - Calculate WebSocket ping interval in milliseconds for exchange
- is_
power_ of_ two - Check if a u64 value is a power of 2 at compile time
- is_
valid_ index - Check if an index is valid for a given length at compile time
- is_
valid_ tick_ price - Check if price is within tick size boundaries
- kb_
to_ bytes - Convert kilobytes to bytes
- mb_
to_ bytes - Convert megabytes to bytes
- micros_
to_ nanos - Network and latency utilities Convert microseconds to nanoseconds
- mid_
price - Calculate mid price from bid and ask
- millis_
to_ nanos - Convert milliseconds to nanoseconds
- nanos_
to_ micros - Convert nanoseconds to microseconds
- nanos_
to_ millis - Convert nanoseconds to milliseconds
- nanos_
to_ seconds - Convert nanoseconds to seconds
- next_
power_ of_ two - Calculate the next power of 2 for a u64 value at compile time
- optimal_
simd_ chunks - Calculate optimal SIMD chunk size for given element count and max chunks
- orderbook_
depth_ for_ memory - HFT-specific utilities Calculate order book depth for given memory budget (bytes)
- percent_
to_ bps - Trading-specific utilities Calculate basis points (bps) from a percentage (1% = 100 bps)
- pool_
capacity_ for_ throughput - Calculate pool capacity based on expected throughput
- price_
diff_ bps - HFT-specific financial calculations Calculate basis points difference between two prices
- round_
to_ tick - Round price to nearest tick
- seconds_
to_ nanos - Convert seconds to nanoseconds
- simd_
aligned_ size - Calculate SIMD-aligned buffer size (multiple of 4 for f64x4)
- simd_
f64x4_ buffer_ size - Calculate total SIMD buffer size for f64x4 operations
- simd_
f64x4_ chunks - SIMD and vectorization utilities Calculate number of SIMD chunks needed for f64x4 operations
- spread_
bps - Calculate spread in basis points
- tick_
count - Calculate tick count between two prices
- tick_
size_ to_ decimals - Calculate the number of decimal places for a given tick size For example, tick size 0.01 has 2 decimal places
- websocket_
max_ message_ size - Calculate maximum message size for WebSocket buffer