Expand description
Common utilities and types for the rusty trading system
This crate provides shared functionality used across multiple components:
- Common enums and types used throughout the system
- Authentication utilities for various exchanges
- HTTP/WebSocket client utilities
- Common error types
- Memory pools for zero-allocation operations
- Rate limiting utilities
- Time and timestamp utilities
§Performance Optimizations
This crate enforces several mandatory performance optimizations:
§Collections (via collections module)
FxHashMap/FxHashSet: 2-4x faster than std HashMap for HFT use casesSmallVec: Stack-allocated vectors with zero heap allocation for small sizes- Type aliases for common collection patterns (orders, price levels, etc.)
§Strings (via SmartString)
- Stack-allocated strings up to 23 bytes (covers most order IDs, symbols)
- Transparent heap fallback for longer strings
- ~30% faster than String for typical HFT string operations
§Benchmarks
Run cargo bench to see performance comparisons between:
- String vs SmartString
- Vec vs SmallVec
- HashMap vs FxHashMap
Re-exports§
pub use collections::SmallFeatureVec;pub use collections::SmallOrderVec;pub use collections::SmallPriceLevelVec;pub use collections::SmallSymbolVec;pub use collections::SmallTradeVec;pub use error::CommonError;pub use error::Result;pub use error_utils::AnyhowErrorExt;pub use error_utils::ErrorMessages;pub use memory::HftBufferHandle;pub use memory::HftBufferPool;pub use memory::HftPoolManager;pub use memory::OrderHandle;pub use memory::OrderPool;pub use memory::PooledOrder;pub use memory::PooledTrade;pub use memory::TradeHandle;pub use memory::TradePool;pub use memory::TradingPoolManager;pub use memory::get_global_trading_pools;pub use memory::global_hft_pools;pub use memory::with_hft_pools;pub use memory::with_thread_local_pools;pub use pools::GenericPool;pub use pools::OrderPoolFactory;pub use pools::OrderPoolTemplate;pub use pools::PoolFactory;pub use pools::PoolStats;pub use pools::borrow_from_global_pool;pub use pools::global_pool_stats;pub use pools::return_to_global_pool;pub use pools::set_global_order_pool;pub use pools::with_global_order_pool;pub use simd_price_ops::SimdPriceCalculator;pub use simd_price_ops::simd_price_impact;pub use simd_price_ops::simd_spreads;pub use simd_price_ops::simd_vwap;pub use strings::ClientOrderId;pub use strings::CurrencyCode;pub use strings::ExchangeName;pub use strings::OrderId;pub use strings::TradeId;pub use time::get_timestamp_ms;pub use time::get_timestamp_ns_result;pub use types::Exchange;pub use types::Symbol;pub use utils::id_generation;pub use vectorized::AlignedBuffer32;pub use vectorized::AlignedBuffer64;pub use vectorized::LegacyAlignedBuffer;pub use zero_alloc_message::MessageType;pub use zero_alloc_message::ZeroAllocMarketData;pub use zero_alloc_message::ZeroAllocMessageProcessor;pub use zero_alloc_message::ZeroAllocOrderUpdate;pub use zerocopy::BorrowedValueExt;pub use zerocopy::BufferedStringOps;pub use zerocopy::ExchangeJsonZeroCopy;pub use zerocopy::JsonBufferManager;pub use zerocopy::UnifiedBufferManager;pub use zerocopy::UnifiedBufferStats;pub use zerocopy::UnifiedStringUtils;pub use zerocopy::WebSocketJsonZeroCopy;pub use zerocopy::ZeroCopyBufferManager;pub use zerocopy::ZeroCopyCollections;pub use zerocopy::ZeroCopyJson;pub use zerocopy::ZeroCopyMessage;pub use zerocopy::ZeroCopySlice;pub use zerocopy::ZeroCopyStringUtils;pub use zerocopy::with_buffer_manager;pub use zerocopy::with_json_buffer_manager;pub use zerocopy::with_unified_buffer_manager;
Modules§
- auth
- Authentication utilities for various exchanges
- collections
- Common collection type aliases for consistent usage across the codebase
- const_
fn_ candidates - Const fn utility functions for compile-time evaluation
- constants
- Common constants used across the rusty trading system
- decimal_
utils - Decimal conversion utilities for safe f64 conversions with precision validation
- error
- Unified error and result types for the trading system.
- error_
utils - Error handling utilities for consistent error management across exchanges
- http
- HTTP client utilities
- json
- JSON parsing utilities with performance optimizations
- memory
- Memory management utilities for high-frequency trading
- pools
- High-performance memory pools for HFT applications
- simd_
macros - SIMD operation macros for reducing code duplication
- simd_
price_ ops - SIMD-optimized price calculations for high-frequency trading
- strings
- SmartString type aliases for memory efficiency
- time
- Time and timestamp utilities
- types
- Common types used across exchanges
- utils
- Common utility functions
- vectorized
- Vectorization-friendly utilities for HFT calculations
- websocket
- Consolidated WebSocket implementation for all exchanges
- zero_
alloc_ message - Zero-allocation message processing for WebSocket exchanges
- zerocopy
- Unified zero-copy utilities for high-performance operations
Macros§
- extract_
max_ f64x4 - Helper macro to extract max from a f64x4 vector
- extract_
min_ f64x4 - Helper macro to extract min from a f64x4 vector
- extract_
sum_ f64x4 - Helper macro to extract and sum all elements from a f64x4 vector
- log_
parse_ error - Macro for consistent JSON parsing error logging
- log_
websocket_ error - Macro for consistent WebSocket error logging
- safe_
format - Safe formatting macro that returns a SmartString
- simd_
chunk_ process - Generate SIMD chunk processing with custom logic per chunk
- simd_
dual_ op - Generate SIMD dual-vector operations (dot product, correlation, etc.)
- simd_
reduce - Generate SIMD reduction operations with configurable accumulators and chunk sizes
Structs§
- Small
Vec - A
Vec-like container that can store a small number of elements inline.
Type Aliases§
- FxHash
Map - Type alias for a hash map that uses the Fx hashing algorithm.
- FxHash
Set - Type alias for a hash set that uses the Fx hashing algorithm.
- Smart
String - A convenience alias for a [
LazyCompact] layout [SmartString].