pub struct BookLevel {
pub price: BookPrice,
pub orders: BTreeMap<OrderId, BookOrder>,
/* private fields */
}
Expand description
Represents a discrete price level in an order book.
The level maintains a collection of orders as well as tracking insertion order to preserve FIFO queue dynamics.
Fields§
§price: BookPrice
§orders: BTreeMap<OrderId, BookOrder>
Implementations§
Source§impl BookLevel
impl BookLevel
Sourcepub fn from_order(order: BookOrder) -> Self
pub fn from_order(order: BookOrder) -> Self
Creates a new price level from an order, using the order’s price and side.
Sourcepub fn first(&self) -> Option<&BookOrder>
pub fn first(&self) -> Option<&BookOrder>
Returns a reference to the first order at this price level in FIFO order.
Sourcepub fn get_orders(&self) -> Vec<BookOrder>
pub fn get_orders(&self) -> Vec<BookOrder>
Returns all orders at this price level in FIFO insertion order.
Sourcepub fn size_raw(&self) -> u64
pub fn size_raw(&self) -> u64
Returns the total size of all orders at this price level as raw integer units.
Sourcepub fn size_decimal(&self) -> Decimal
pub fn size_decimal(&self) -> Decimal
Returns the total size of all orders at this price level as a decimal.
Sourcepub fn exposure(&self) -> f64
pub fn exposure(&self) -> f64
Returns the total exposure (price * size) of all orders at this price level as a float.
Sourcepub fn exposure_raw(&self) -> u64
pub fn exposure_raw(&self) -> u64
Returns the total exposure (price * size) of all orders at this price level as raw integer units.
Sourcepub fn add_bulk(&mut self, orders: Vec<BookOrder>)
pub fn add_bulk(&mut self, orders: Vec<BookOrder>)
Adds multiple orders to this price level in FIFO order. Orders must match the level’s price.
Sourcepub fn add(&mut self, order: BookOrder)
pub fn add(&mut self, order: BookOrder)
Adds an order to this price level. Order must match the level’s price.
Sourcepub fn update(&mut self, order: BookOrder)
pub fn update(&mut self, order: BookOrder)
Updates an existing order at this price level. Updated order must match the level’s price. Removes the order if size becomes zero.
Sourcepub fn remove_by_id(
&mut self,
order_id: OrderId,
sequence: u64,
ts_event: UnixNanos,
)
pub fn remove_by_id( &mut self, order_id: OrderId, sequence: u64, ts_event: UnixNanos, )
Removes an order by its ID. Panics if the order doesn’t exist.
Trait Implementations§
Source§impl Ord for BookLevel
impl Ord for BookLevel
Source§impl PartialOrd for BookLevel
impl PartialOrd for BookLevel
Source§impl PyClassImpl for BookLevel
impl PyClassImpl for BookLevel
Source§const IS_BASETYPE: bool = false
const IS_BASETYPE: bool = false
Source§const IS_SUBCLASS: bool = false
const IS_SUBCLASS: bool = false
Source§const IS_MAPPING: bool = false
const IS_MAPPING: bool = false
Source§const IS_SEQUENCE: bool = false
const IS_SEQUENCE: bool = false
Source§type ThreadChecker = SendablePyClass<BookLevel>
type ThreadChecker = SendablePyClass<BookLevel>
Source§type PyClassMutability = <<PyAny as PyClassBaseType>::PyClassMutability as PyClassMutability>::MutableChild
type PyClassMutability = <<PyAny as PyClassBaseType>::PyClassMutability as PyClassMutability>::MutableChild
Source§type BaseNativeType = PyAny
type BaseNativeType = PyAny
PyAny
by default, and when you declare
#[pyclass(extends=PyDict)]
, it’s PyDict
.fn items_iter() -> PyClassItemsIter
fn lazy_type_object() -> &'static LazyTypeObject<Self>
fn dict_offset() -> Option<isize>
fn weaklist_offset() -> Option<isize>
Source§impl PyMethods<BookLevel> for PyClassImplCollector<BookLevel>
impl PyMethods<BookLevel> for PyClassImplCollector<BookLevel>
fn py_methods(self) -> &'static PyClassItems
Source§impl PyTypeInfo for BookLevel
impl PyTypeInfo for BookLevel
Source§fn type_object_raw(py: Python<'_>) -> *mut PyTypeObject
fn type_object_raw(py: Python<'_>) -> *mut PyTypeObject
§fn type_object_bound(py: Python<'_>) -> Bound<'_, PyType>
fn type_object_bound(py: Python<'_>) -> Bound<'_, PyType>
§fn is_type_of_bound(object: &Bound<'_, PyAny>) -> bool
fn is_type_of_bound(object: &Bound<'_, PyAny>) -> bool
object
is an instance of this type or a subclass of this type.§fn is_exact_type_of_bound(object: &Bound<'_, PyAny>) -> bool
fn is_exact_type_of_bound(object: &Bound<'_, PyAny>) -> bool
object
is an instance of this type.impl DerefToPyAny for BookLevel
impl Eq for BookLevel
Auto Trait Implementations§
impl Freeze for BookLevel
impl RefUnwindSafe for BookLevel
impl Send for BookLevel
impl Sync for BookLevel
impl Unpin for BookLevel
impl UnwindSafe for BookLevel
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,
§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.