pub struct FastOrderDelta {
pub token_id_hash: u64,
pub timestamp: DateTime<Utc>,
pub side: Side,
pub price: Price,
pub size: Qty,
pub sequence: u64,
}Expand description
Order book delta for streaming updates - INTERNAL HOT PATH VERSION
This is what we use internally for processing order book updates. Converting to this format on ingress gives us massive performance gains.
Why the performance matters:
- We might process 10,000+ deltas per second in active markets
- Each delta triggers multiple calculations (spread, impact, etc.)
- Using integers instead of Decimal can make the difference between keeping up with the market feed vs falling behind
Fields§
§token_id_hash: u64§timestamp: DateTime<Utc>§side: Side§price: Price§size: Qty§sequence: u64Implementations§
Source§impl FastOrderDelta
impl FastOrderDelta
Sourcepub fn from_order_delta(
delta: &OrderDelta,
tick_size: Option<Decimal>,
) -> Result<Self, &'static str>
pub fn from_order_delta( delta: &OrderDelta, tick_size: Option<Decimal>, ) -> Result<Self, &'static str>
Create from external OrderDelta with validation and tick alignment
This is where we enforce tick alignment - if the incoming price doesn’t align to valid ticks, we either reject it or round it. This prevents bad data from corrupting our order book.
Sourcepub fn to_order_delta(self, token_id: String) -> OrderDelta
pub fn to_order_delta(self, token_id: String) -> OrderDelta
Convert back to external OrderDelta (for API responses) We need the original token_id since we only store the hash
Sourcepub fn is_removal(self) -> bool
pub fn is_removal(self) -> bool
Check if this delta removes a level (size is zero)
Trait Implementations§
Source§impl Clone for FastOrderDelta
impl Clone for FastOrderDelta
Source§fn clone(&self) -> FastOrderDelta
fn clone(&self) -> FastOrderDelta
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for FastOrderDelta
impl Debug for FastOrderDelta
Source§impl PartialEq for FastOrderDelta
impl PartialEq for FastOrderDelta
impl Copy for FastOrderDelta
impl Eq for FastOrderDelta
impl StructuralPartialEq for FastOrderDelta
Auto Trait Implementations§
impl Freeze for FastOrderDelta
impl RefUnwindSafe for FastOrderDelta
impl Send for FastOrderDelta
impl Sync for FastOrderDelta
impl Unpin for FastOrderDelta
impl UnwindSafe for FastOrderDelta
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
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>
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