1// -------------------------------------------------------------------------------------------------
2// Copyright (C) 2015-2025 Nautech Systems Pty Ltd. All rights reserved.
3// https://nautechsystems.io
4//
5// Licensed under the GNU Lesser General Public License Version 3.0 (the "License");
6// You may not use this file except in compliance with the License.
7// You may obtain a copy of the License at https://www.gnu.org/licenses/lgpl-3.0.en.html
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14// -------------------------------------------------------------------------------------------------
1516use pyo3::prelude::*;
1718use crate::{
19 data::order::BookOrder,
20 orderbook::BookLevel,
21 types::{price::Price, quantity::QuantityRaw},
22};
2324#[pymethods]
25impl BookLevel {
26fn __repr__(&self) -> String {
27format!("{self:?}")
28 }
2930fn __str__(&self) -> String {
31// TODO: Return debug string for now
32format!("{self:?}")
33 }
3435#[getter]
36 #[pyo3(name = "price")]
37fn py_price(&self) -> Price {
38self.price.value
39 }
4041#[pyo3(name = "len")]
42fn py_len(&self) -> usize {
43self.len()
44 }
4546#[pyo3(name = "is_empty")]
47fn py_is_empty(&self) -> bool {
48self.is_empty()
49 }
5051#[pyo3(name = "size")]
52fn py_size(&self) -> f64 {
53self.size()
54 }
5556#[pyo3(name = "size_raw")]
57fn py_size_raw(&self) -> QuantityRaw {
58self.size_raw()
59 }
6061#[pyo3(name = "exposure")]
62fn py_exposure(&self) -> f64 {
63self.exposure()
64 }
6566#[pyo3(name = "exposure_raw")]
67fn py_exposure_raw(&self) -> QuantityRaw {
68self.exposure_raw()
69 }
7071#[pyo3(name = "first")]
72fn py_fist(&self) -> Option<BookOrder> {
73self.first().copied()
74 }
7576#[pyo3(name = "get_orders")]
77fn py_get_orders(&self) -> Vec<BookOrder> {
78self.get_orders()
79 }
80}