#[non_exhaustive]pub struct L2Diff {
pub coin: String,
pub time: u64,
pub bids: Vec<L2Level>,
pub asks: Vec<L2Level>,
pub removed_bids: Vec<usize>,
pub removed_asks: Vec<usize>,
pub spread: Option<Dec>,
}Expand description
What changed in an l2 book since the frame before. To apply it, the levels at the indexes in
removed_bids and removed_asks (positions in the book before) go first, then each level in
bids and asks is added or replaced by price; L2Diff::apply does both.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.coin: Stringc: the coin.
time: u64Milliseconds.
bids: Vec<L2Level>Bid levels added or changed.
asks: Vec<L2Level>Ask levels added or changed.
removed_bids: Vec<usize>Positions of the bids removed, in the book before this diff.
removed_asks: Vec<usize>Positions of the asks removed, in the book before this diff.
spread: Option<Dec>Sent with a bucketed book (s on the subscription), as l2Book’s spread is.
Implementations§
Source§impl L2Diff
impl L2Diff
Sourcepub fn apply(&self, book: &mut Book) -> Result<(), BadDiff>
pub fn apply(&self, book: &mut Book) -> Result<(), BadDiff>
Applies the diff to book, the book as of the frame before: the removed levels go, then
each level in the diff replaces the one at its price or is added in place, each side kept
best first. A level the diff adds or changes has n 0, since diffs carry no order count.
The time and spread become the diff’s. A diff for another coin, or one that removes a level
the book does not have, is refused and the book is left as it was.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for L2Diff
impl<'de> Deserialize<'de> for L2Diff
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for L2Diff
impl StructuralPartialEq for L2Diff
Auto Trait Implementations§
impl Forget for L2Diff
impl Freeze for L2Diff
impl Move for L2Diff
impl RefUnwindSafe for L2Diff
impl Send for L2Diff
impl Sync for L2Diff
impl Unpin for L2Diff
impl UnsafeUnpin for L2Diff
impl UnwindSafe for L2Diff
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
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
key and return true if they are equal.