nautilus_indicators/python/momentum/
obv.rs1use nautilus_model::data::Bar;
17use pyo3::prelude::*;
18
19use crate::{indicator::Indicator, momentum::obv::OnBalanceVolume};
20
21#[pymethods]
22#[pyo3_stub_gen::derive::gen_stub_pymethods]
23impl OnBalanceVolume {
24 #[new]
26 #[must_use]
27 pub fn py_new(period: usize) -> Self {
28 Self::new(period)
29 }
30
31 fn __repr__(&self) -> String {
32 format!("OnBalanceVolume({})", self.period)
33 }
34
35 #[getter]
36 #[pyo3(name = "name")]
37 fn py_name(&self) -> String {
38 self.name()
39 }
40
41 #[getter]
42 #[pyo3(name = "period")]
43 const fn py_period(&self) -> usize {
44 self.period
45 }
46
47 #[getter]
48 #[pyo3(name = "has_inputs")]
49 fn py_has_inputs(&self) -> bool {
50 self.has_inputs()
51 }
52
53 #[getter]
54 #[pyo3(name = "value")]
55 const fn py_value(&self) -> f64 {
56 self.value
57 }
58
59 #[getter]
60 #[pyo3(name = "initialized")]
61 const fn py_initialized(&self) -> bool {
62 self.initialized
63 }
64
65 #[pyo3(name = "update_raw")]
66 fn py_update_raw(&mut self, open: f64, close: f64, volume: f64) {
67 self.update_raw(open, close, volume);
68 }
69
70 #[pyo3(name = "handle_bar")]
71 fn py_handle_bar(&mut self, bar: &Bar) {
72 self.handle_bar(bar);
73 }
74
75 #[pyo3(name = "reset")]
76 fn py_reset(&mut self) {
77 self.reset();
78 }
79}