Skip to main content

L2

Struct L2 

Source
pub struct L2 {
    pub bid_price_head: Option<u64>,
    pub ask_price_head: Option<u64>,
    pub bid_price_tail: Option<u64>,
    pub ask_price_tail: Option<u64>,
    pub bid_price_nodes: BTreeMap<u64, PriceNode>,
    pub ask_price_nodes: BTreeMap<u64, PriceNode>,
    pub public_bid_level_map: BTreeMap<u64, u64>,
    pub public_ask_level_map: BTreeMap<u64, u64>,
    pub current_bid_level_map: BTreeMap<u64, u64>,
    pub current_ask_level_map: BTreeMap<u64, u64>,
    pub bid_level_list: BTreeMap<u64, Vec<Level>>,
    pub ask_level_list: BTreeMap<u64, Vec<Level>>,
}

Fields§

§bid_price_head: Option<u64>

Head of the bid price linked list

§ask_price_head: Option<u64>

Head of the ask price linked list

§bid_price_tail: Option<u64>

Tail of the bid price linked list

§ask_price_tail: Option<u64>

Tail of the ask price linked list

§bid_price_nodes: BTreeMap<u64, PriceNode>

Mapping price -> node of the bid price linked list

§ask_price_nodes: BTreeMap<u64, PriceNode>

Mapping price -> node of the ask price linked list

§public_bid_level_map: BTreeMap<u64, u64>

Public bid levels sorted by price descending

§public_ask_level_map: BTreeMap<u64, u64>

Public ask levels sorted by price ascending

§current_bid_level_map: BTreeMap<u64, u64>

Current bid levels sorted by price descending

§current_ask_level_map: BTreeMap<u64, u64>

Current ask levels sorted by price ascending

§bid_level_list: BTreeMap<u64, Vec<Level>>

Bid levels sorted by price descending for snapshot display key is scale in 8 decimals integer (e.g. 100000000 for 1.00000000, 1000000000 for 10.00000000) value is a vector of levels in the quantized price space

§ask_level_list: BTreeMap<u64, Vec<Level>>

Ask levels sorted by price ascending for snapshot display key is scale in 8 decimals integer (e.g. 100000000 for 1.00000000, 1000000000 for 10.00000000) value is a vector of levels in the quantized price space

Implementations§

Source§

impl L2

Source

pub fn new() -> Self

Source

pub fn bid_head(&self) -> Option<u64>

Source

pub fn ask_head(&self) -> Option<u64>

Source

pub fn public_bid_level(&self, price: u64) -> Option<u64>

Source

pub fn public_ask_level(&self, price: u64) -> Option<u64>

Source

pub fn current_bid_level(&self, price: u64) -> Option<u64>

Source

pub fn current_ask_level(&self, price: u64) -> Option<u64>

Source

pub fn bid_levels(&self, scale: u64) -> &Vec<Level>

Source

pub fn ask_levels(&self, scale: u64) -> &Vec<Level>

Source

pub fn scale_bid_levels(&self, scale: u64, n: u32) -> Vec<Level>

Source

pub fn scale_ask_levels(&self, scale: u64, n: u32) -> Vec<Level>

Source

pub fn set_current_bid_level( &mut self, price: u64, level: u64, ) -> Result<(), L2Error>

Source

pub fn set_current_ask_level( &mut self, price: u64, level: u64, ) -> Result<(), L2Error>

Source

pub fn set_public_bid_level( &mut self, price: u64, level: u64, ) -> Result<(), L2Error>

Source

pub fn set_public_ask_level( &mut self, price: u64, level: u64, ) -> Result<(), L2Error>

Source

pub fn set_bid_levels( &mut self, scale: u64, levels: Vec<Level>, ) -> Result<(), L2Error>

Source

pub fn set_ask_levels( &mut self, scale: u64, levels: Vec<Level>, ) -> Result<(), L2Error>

Source

pub fn clear_head(&mut self, is_bid: bool) -> Result<Option<u64>, L2Error>

Source

pub fn price_exists(&self, is_bid: bool, price: u64) -> bool

Source

pub fn insert_price(&mut self, is_bid: bool, price: u64) -> Result<(), L2Error>

Source

pub fn remove_price(&mut self, is_bid: bool, price: u64) -> Result<(), L2Error>

Source

pub fn collect_bid_prices(&self) -> Vec<u64>

Helper function to collect all bid prices in order (descending)

Source

pub fn collect_ask_prices(&self) -> Vec<u64>

Helper function to collect all ask prices in order (ascending)

Source

pub fn get_snapshot_raw( &self, is_bid: bool, scale: u64, step: u32, ) -> Result<Vec<Vec<u64>>, L2Error>

get L2 snapshot (raw numbers) Returns an array of arrays where each inner array is [price in 8 decimals, base amount in 8 decimals] The outer array has step length

Source

pub fn get_snapshot( &self, is_bid: bool, scale: u64, step: u32, ) -> Result<Vec<Vec<String>>, L2Error>

get L2 snapshot (formatted strings) Returns an array of arrays where each inner array is [price as string with 8 decimals, base amount as string with 8 decimals] The outer array has step length Numbers are formatted from raw 8-decimal integers to strings with 8 decimal places

Trait Implementations§

Source§

impl Clone for L2

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for L2

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for L2

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for L2

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Eq for L2

Source§

impl PartialEq for L2

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for L2

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for L2

Auto Trait Implementations§

§

impl Forget for L2

§

impl Freeze for L2

§

impl RefUnwindSafe for L2

§

impl Send for L2

§

impl Sync for L2

§

impl Unpin for L2

§

impl UnsafeUnpin for L2

§

impl UnwindSafe for L2

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V