pub struct SimdPriceCalculator<const N: usize = 32> { /* private fields */ }Expand description
SIMD-aligned price calculation engine with const generic buffer sizing
Uses 64-byte aligned memory for optimal SIMD performance. All calculations are NaN-safe with proper error handling.
§Type Parameters
N: Maximum number of elements in result buffers (default: 32) Optimized for typical HFT scenarios with 10-50 price levels
Implementations§
Source§impl<const N: usize> SimdPriceCalculator<N>
impl<const N: usize> SimdPriceCalculator<N>
Sourcepub fn new(max_elements: usize) -> Self
pub fn new(max_elements: usize) -> Self
Create a new SIMD price calculator with const generic buffer sizing
§Arguments
max_elements- Maximum number of f64 elements to allocate, capped at const generic N
Sourcepub fn calculate_vwap(
&mut self,
prices: &[Decimal],
quantities: &[Decimal],
) -> Result<Decimal, &'static str>
pub fn calculate_vwap( &mut self, prices: &[Decimal], quantities: &[Decimal], ) -> Result<Decimal, &'static str>
Calculate weighted average price using SIMD operations
Returns the volume-weighted average price across all levels. Uses SIMD for maximum performance with proper NaN handling.
§Errors
Returns an error if the input data exceeds the const generic N capacity.
Sourcepub fn calculate_spreads(
&mut self,
bid_prices: &[Decimal],
ask_prices: &[Decimal],
) -> Result<SmallVec<[Decimal; N]>, &'static str>
pub fn calculate_spreads( &mut self, bid_prices: &[Decimal], ask_prices: &[Decimal], ) -> Result<SmallVec<[Decimal; N]>, &'static str>
Calculate bid-ask spread for multiple price levels using SIMD
Returns the spread (ask - bid) for each level pair.
§Errors
Returns an error if the input data exceeds the const generic N capacity.
Sourcepub fn calculate_price_impact(
&mut self,
prices: &[Decimal],
quantities: &[Decimal],
trade_quantity: Decimal,
) -> Result<Decimal, &'static str>
pub fn calculate_price_impact( &mut self, prices: &[Decimal], quantities: &[Decimal], trade_quantity: Decimal, ) -> Result<Decimal, &'static str>
Calculate price impact using SIMD vectorization
Estimates the price impact of trading a given quantity across levels.
§Errors
Returns an error if the input data exceeds the const generic N capacity.