pub struct BookLevel {
pub price: BookPrice,
/* private fields */
}
Expand description
Represents a discrete price level in an order book.
Orders are stored in an [IndexMap
] which preserves FIFO (insertion) order.
Fields§
§price: BookPrice
Implementations§
Source§impl BookLevel
impl BookLevel
Sourcepub fn from_order(order: BookOrder) -> Self
pub fn from_order(order: BookOrder) -> Self
Creates a new BookLevel
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 iter(&self) -> impl Iterator<Item = &BookOrder>
pub fn iter(&self) -> impl Iterator<Item = &BookOrder>
Returns an iterator over the orders 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) -> QuantityRaw
pub fn size_raw(&self) -> QuantityRaw
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) -> QuantityRaw
pub fn exposure_raw(&self) -> QuantityRaw
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<'py> IntoPyObject<'py> for BookLevel
impl<'py> IntoPyObject<'py> for BookLevel
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(py: Python<'_>) -> Bound<'_, PyType>
fn type_object(py: Python<'_>) -> Bound<'_, PyType>
§fn type_object_bound(py: Python<'_>) -> Bound<'_, PyType>
fn type_object_bound(py: Python<'_>) -> Bound<'_, PyType>
PyTypeInfo::type_object
PyTypeInfo::type_object
].§fn is_type_of(object: &Bound<'_, PyAny>) -> bool
fn is_type_of(object: &Bound<'_, PyAny>) -> bool
object
is an instance of this type or a subclass of this type.§fn is_type_of_bound(object: &Bound<'_, PyAny>) -> bool
fn is_type_of_bound(object: &Bound<'_, PyAny>) -> bool
PyTypeInfo::is_type_of
PyTypeInfo::is_type_of
].§fn is_exact_type_of(object: &Bound<'_, PyAny>) -> bool
fn is_exact_type_of(object: &Bound<'_, PyAny>) -> bool
object
is an instance of this type.§fn is_exact_type_of_bound(object: &Bound<'_, PyAny>) -> bool
fn is_exact_type_of_bound(object: &Bound<'_, PyAny>) -> bool
PyTypeInfo::is_exact_type_of
PyTypeInfo::is_exact_type_of
].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
key
and return true
if they are equal.§impl<T> FromPyObject<'_> for Twhere
T: PyClass + Clone,
impl<T> FromPyObject<'_> for Twhere
T: PyClass + Clone,
§fn extract_bound(obj: &Bound<'_, PyAny>) -> Result<T, PyErr>
fn extract_bound(obj: &Bound<'_, PyAny>) -> Result<T, PyErr>
§impl<'py, T> FromPyObjectBound<'_, 'py> for Twhere
T: FromPyObject<'py>,
impl<'py, T> FromPyObjectBound<'_, 'py> for Twhere
T: FromPyObject<'py>,
§fn from_py_object_bound(ob: Borrowed<'_, 'py, PyAny>) -> Result<T, PyErr>
fn from_py_object_bound(ob: Borrowed<'_, 'py, PyAny>) -> Result<T, PyErr>
§impl<'py, T> IntoPyObjectExt<'py> for Twhere
T: IntoPyObject<'py>,
impl<'py, T> IntoPyObjectExt<'py> for Twhere
T: IntoPyObject<'py>,
§fn into_bound_py_any(self, py: Python<'py>) -> Result<Bound<'py, PyAny>, PyErr>
fn into_bound_py_any(self, py: Python<'py>) -> Result<Bound<'py, PyAny>, PyErr>
self
into an owned Python object, dropping type information.§fn into_py_any(self, py: Python<'py>) -> Result<Py<PyAny>, PyErr>
fn into_py_any(self, py: Python<'py>) -> Result<Py<PyAny>, PyErr>
self
into an owned Python object, dropping type information and unbinding it
from the 'py
lifetime.§fn into_pyobject_or_pyerr(self, py: Python<'py>) -> Result<Self::Output, PyErr>
fn into_pyobject_or_pyerr(self, py: Python<'py>) -> Result<Self::Output, PyErr>
self
into a Python object. Read more