nautilus_indicators/python/ratio/
spread_analyzer.rs

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// -------------------------------------------------------------------------------------------------
15
16use nautilus_model::{data::QuoteTick, identifiers::InstrumentId};
17use pyo3::prelude::*;
18
19use crate::{indicator::Indicator, ratio::spread_analyzer::SpreadAnalyzer};
20
21#[pymethods]
22impl SpreadAnalyzer {
23    #[new]
24    fn py_new(instrument_id: InstrumentId, capacity: usize) -> Self {
25        Self::new(capacity, instrument_id)
26    }
27
28    fn __repr__(&self) -> String {
29        format!("SpreadAnalyzer({})", self.capacity)
30    }
31
32    #[getter]
33    #[pyo3(name = "name")]
34    fn py_name(&self) -> String {
35        self.name()
36    }
37
38    #[getter]
39    #[pyo3(name = "capacity")]
40    const fn py_capacity(&self) -> usize {
41        self.capacity
42    }
43
44    #[getter]
45    #[pyo3(name = "current")]
46    const fn py_current(&self) -> f64 {
47        self.current
48    }
49
50    #[getter]
51    #[pyo3(name = "average")]
52    const fn py_average(&self) -> f64 {
53        self.average
54    }
55
56    #[getter]
57    #[pyo3(name = "initialized")]
58    const fn py_initialized(&self) -> bool {
59        self.initialized
60    }
61
62    #[pyo3(name = "has_inputs")]
63    fn py_has_inputs(&self) -> bool {
64        self.has_inputs()
65    }
66
67    #[pyo3(name = "handle_quote_tick")]
68    fn py_handle_quote_tick(&mut self, quote: &QuoteTick) {
69        self.handle_quote(quote);
70    }
71
72    #[pyo3(name = "reset")]
73    fn py_reset(&mut self) {
74        self.reset();
75    }
76}