pub struct OrderBook { /* private fields */ }Expand description
L3 order book with intrusive linked lists.
Orders are stored in a HashMap keyed by OrderId, with each price level maintaining a doubly-linked list of orders in FIFO (time-priority) order. Provides both L2 (aggregated price levels) and L3 (individual orders) views.
Implementations§
Source§impl OrderBook
impl OrderBook
Sourcepub fn ask_impact(&self, want_size: UD64) -> Option<(UD64, UD64, UD64)>
pub fn ask_impact(&self, want_size: UD64) -> Option<(UD64, UD64, UD64)>
Ask impact price for the requested size, along with the fillable size and size-averaged price.
Sourcepub fn bid_impact(&self, want_size: UD64) -> Option<(UD64, UD64, UD64)>
pub fn bid_impact(&self, want_size: UD64) -> Option<(UD64, UD64, UD64)>
Bid impact price for the requested size, along with the fillable size and size-averaged price.
Sourcepub fn ask_impact_notional(
&self,
want_notional: UD128,
) -> Option<(UD64, UD64, UD64, UD128)>
pub fn ask_impact_notional( &self, want_notional: UD128, ) -> Option<(UD64, UD64, UD64, UD128)>
Ask impact price for the requested notional amount, along with the
fillable size, size-averaged price, and filled notional.
CAREFUL: See impact_notional for partial-fill
semantics.
Sourcepub fn bid_impact_notional(
&self,
want_notional: UD128,
) -> Option<(UD64, UD64, UD64, UD128)>
pub fn bid_impact_notional( &self, want_notional: UD128, ) -> Option<(UD64, UD64, UD64, UD128)>
Bid impact price for the requested notional amount, along with the
fillable size, size-averaged price, and filled notional.
CAREFUL: See impact_notional for partial-fill
semantics.
Sourcepub fn ask_level(&self, price: UD64) -> Option<&BookLevel>
pub fn ask_level(&self, price: UD64) -> Option<&BookLevel>
Get L3 level at a specific ask price.
Sourcepub fn bid_level(&self, price: UD64) -> Option<&BookLevel>
pub fn bid_level(&self, price: UD64) -> Option<&BookLevel>
Get L3 level at a specific bid price.
Sourcepub fn get_order(&self, order_id: OrderId) -> Option<&BookOrder>
pub fn get_order(&self, order_id: OrderId) -> Option<&BookOrder>
Get a specific order by ID (O(1) via HashMap lookup).
Sourcepub fn get_order_by_client_id(
&self,
account_id: AccountId,
client_id: RequestId,
) -> Option<&BookOrder>
pub fn get_order_by_client_id( &self, account_id: AccountId, client_id: RequestId, ) -> Option<&BookOrder>
Get a specific order by client order ID (O(1) via HashMap lookup).
Sourcepub fn ask_orders(&self) -> impl Iterator<Item = &BookOrder>
pub fn ask_orders(&self) -> impl Iterator<Item = &BookOrder>
Iterator over all L3 orders on the ask side in price-time priority.
Sourcepub fn bid_orders(&self) -> impl Iterator<Item = &BookOrder>
pub fn bid_orders(&self) -> impl Iterator<Item = &BookOrder>
Iterator over all L3 orders on the bid side in price-time priority.
Sourcepub fn total_orders(&self) -> usize
pub fn total_orders(&self) -> usize
Total number of orders in the book.
Sourcepub fn all_orders(&self) -> &HashMap<OrderId, BookOrder>
pub fn all_orders(&self) -> &HashMap<OrderId, BookOrder>
Access to all orders in the book keyed by order ID.
pub fn view<'a>( &'a self, depth: Option<usize>, orders_per_level: Option<usize>, show_expired: bool, ) -> OrderBookView<'a>
Trait Implementations§
Auto Trait Implementations§
impl Freeze for OrderBook
impl RefUnwindSafe for OrderBook
impl Send for OrderBook
impl Sync for OrderBook
impl Unpin for OrderBook
impl UnsafeUnpin for OrderBook
impl UnwindSafe for OrderBook
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§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> ⓘ
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> ⓘ
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 moreSource§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.