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
impl L2
pub fn new() -> Self
pub fn bid_head(&self) -> Option<u64>
pub fn ask_head(&self) -> Option<u64>
pub fn public_bid_level(&self, price: u64) -> Option<u64>
pub fn public_ask_level(&self, price: u64) -> Option<u64>
pub fn current_bid_level(&self, price: u64) -> Option<u64>
pub fn current_ask_level(&self, price: u64) -> Option<u64>
pub fn bid_levels(&self, scale: u64) -> &Vec<Level>
pub fn ask_levels(&self, scale: u64) -> &Vec<Level>
pub fn scale_bid_levels(&self, scale: u64, n: u32) -> Vec<Level>
pub fn scale_ask_levels(&self, scale: u64, n: u32) -> Vec<Level>
pub fn set_current_bid_level( &mut self, price: u64, level: u64, ) -> Result<(), L2Error>
pub fn set_current_ask_level( &mut self, price: u64, level: u64, ) -> Result<(), L2Error>
pub fn set_public_bid_level( &mut self, price: u64, level: u64, ) -> Result<(), L2Error>
pub fn set_public_ask_level( &mut self, price: u64, level: u64, ) -> Result<(), L2Error>
pub fn set_bid_levels( &mut self, scale: u64, levels: Vec<Level>, ) -> Result<(), L2Error>
pub fn set_ask_levels( &mut self, scale: u64, levels: Vec<Level>, ) -> Result<(), L2Error>
pub fn clear_head(&mut self, is_bid: bool) -> Result<Option<u64>, L2Error>
pub fn price_exists(&self, is_bid: bool, price: u64) -> bool
pub fn insert_price(&mut self, is_bid: bool, price: u64) -> Result<(), L2Error>
pub fn remove_price(&mut self, is_bid: bool, price: u64) -> Result<(), L2Error>
Sourcepub fn collect_bid_prices(&self) -> Vec<u64>
pub fn collect_bid_prices(&self) -> Vec<u64>
Helper function to collect all bid prices in order (descending)
Sourcepub fn collect_ask_prices(&self) -> Vec<u64>
pub fn collect_ask_prices(&self) -> Vec<u64>
Helper function to collect all ask prices in order (ascending)
Sourcepub fn get_snapshot_raw(
&self,
is_bid: bool,
scale: u64,
step: u32,
) -> Result<Vec<Vec<u64>>, L2Error>
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
Sourcepub fn get_snapshot(
&self,
is_bid: bool,
scale: u64,
step: u32,
) -> Result<Vec<Vec<String>>, L2Error>
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