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 nautilus_model::{data::QuoteTick, identifiers::InstrumentId};
17use pyo3::prelude::*;
1819use crate::{indicator::Indicator, ratio::spread_analyzer::SpreadAnalyzer};
2021#[pymethods]
22impl SpreadAnalyzer {
23#[new]
24fn py_new(instrument_id: InstrumentId, capacity: usize) -> Self {
25Self::new(capacity, instrument_id)
26 }
2728fn __repr__(&self) -> String {
29format!("SpreadAnalyzer({})", self.capacity)
30 }
3132#[getter]
33 #[pyo3(name = "name")]
34fn py_name(&self) -> String {
35self.name()
36 }
3738#[getter]
39 #[pyo3(name = "capacity")]
40const fn py_capacity(&self) -> usize {
41self.capacity
42 }
4344#[getter]
45 #[pyo3(name = "current")]
46const fn py_current(&self) -> f64 {
47self.current
48 }
4950#[getter]
51 #[pyo3(name = "average")]
52const fn py_average(&self) -> f64 {
53self.average
54 }
5556#[getter]
57 #[pyo3(name = "initialized")]
58const fn py_initialized(&self) -> bool {
59self.initialized
60 }
6162#[pyo3(name = "has_inputs")]
63fn py_has_inputs(&self) -> bool {
64self.has_inputs()
65 }
6667#[pyo3(name = "handle_quote_tick")]
68fn py_handle_quote_tick(&mut self, quote: &QuoteTick) {
69self.handle_quote(quote);
70 }
7172#[pyo3(name = "reset")]
73fn py_reset(&mut self) {
74self.reset();
75 }
76}