nautilus_indicators/python/book/
imbalance.rs1use nautilus_model::{orderbook::OrderBook, types::Quantity};
17use pyo3::prelude::*;
18
19use crate::{book::imbalance::BookImbalanceRatio, indicator::Indicator};
20
21#[pymethods]
22#[pyo3_stub_gen::derive::gen_stub_pymethods]
23impl BookImbalanceRatio {
24 #[new]
26 const fn py_new() -> Self {
27 Self::new()
28 }
29
30 fn __repr__(&self) -> String {
31 self.to_string()
32 }
33
34 #[getter]
35 #[pyo3(name = "name")]
36 fn py_name(&self) -> String {
37 self.name()
38 }
39
40 #[getter]
41 #[pyo3(name = "count")]
42 const fn py_count(&self) -> usize {
43 self.count
44 }
45
46 #[getter]
47 #[pyo3(name = "value")]
48 const fn py_value(&self) -> f64 {
49 self.value
50 }
51
52 #[getter]
53 #[pyo3(name = "has_inputs")]
54 fn py_has_inputs(&self) -> bool {
55 self.has_inputs()
56 }
57
58 #[getter]
59 #[pyo3(name = "initialized")]
60 const fn py_initialized(&self) -> bool {
61 self.initialized
62 }
63
64 #[pyo3(name = "handle_book")]
65 fn py_handle_book(&mut self, book: &OrderBook) {
66 self.handle_book(book);
67 }
68
69 #[pyo3(name = "update")]
70 #[pyo3(signature = (best_bid=None, best_ask=None))]
71 fn py_update(&mut self, best_bid: Option<Quantity>, best_ask: Option<Quantity>) {
72 self.update(best_bid, best_ask);
73 }
74
75 #[pyo3(name = "reset")]
76 fn py_reset(&mut self) {
77 self.reset();
78 }
79}