pub struct MatchingEngine<const N: usize = 8> { /* private fields */ }Expand description
L2 Matching Engine with const generic order queue sizing
§Type Parameters
N: Maximum number of orders per price level (default: 8) Optimized for typical HFT scenarios with multiple orders at each price level
Implementations§
Source§impl<const N: usize> MatchingEngine<N>
impl<const N: usize> MatchingEngine<N>
Sourcepub fn new(
book: Arc<OrderBook>,
queue_model: QueueModel,
allow_partial_fills: bool,
_self_trade_prevention: bool,
) -> Self
pub fn new( book: Arc<OrderBook>, queue_model: QueueModel, allow_partial_fills: bool, _self_trade_prevention: bool, ) -> Self
Create a new L2 matching engine
Sourcepub fn with_conservative_params(
book: Arc<OrderBook>,
queue_model: QueueModel,
allow_partial_fills: bool,
_self_trade_prevention: bool,
market_impact: MarketImpact,
conservative_params: ConservativeParams,
) -> Self
pub fn with_conservative_params( book: Arc<OrderBook>, queue_model: QueueModel, allow_partial_fills: bool, _self_trade_prevention: bool, market_impact: MarketImpact, conservative_params: ConservativeParams, ) -> Self
Create with custom conservative parameters
Sourcepub fn submit_order(&self, order: Order) -> SmallExecutionVec<Execution>
pub fn submit_order(&self, order: Order) -> SmallExecutionVec<Execution>
Submit a new order
Sourcepub fn cancel_order(&self, order_id: u64) -> bool
pub fn cancel_order(&self, order_id: u64) -> bool
Cancel an order
Sourcepub fn process_trade(
&self,
side: OrderSide,
price: Decimal,
quantity: Decimal,
timestamp_ns: u64,
) -> SmallExecutionVec<Execution>
pub fn process_trade( &self, side: OrderSide, price: Decimal, quantity: Decimal, timestamp_ns: u64, ) -> SmallExecutionVec<Execution>
Process a trade event and check for fills
Sourcepub fn get_orders_at_level(
&self,
side: OrderSide,
price: Decimal,
) -> SmallVec<[Order; N]>
pub fn get_orders_at_level( &self, side: OrderSide, price: Decimal, ) -> SmallVec<[Order; N]>
Get active orders at a price level
Auto Trait Implementations§
impl<const N: usize> Freeze for MatchingEngine<N>
impl<const N: usize = 8> !RefUnwindSafe for MatchingEngine<N>
impl<const N: usize> Send for MatchingEngine<N>
impl<const N: usize> Sync for MatchingEngine<N>
impl<const N: usize> Unpin for MatchingEngine<N>
impl<const N: usize = 8> !UnwindSafe for MatchingEngine<N>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more