nautilus_indicators/python/ratio/efficiency_ratio.rs
1// -------------------------------------------------------------------------------------------------
2// Copyright (C) 2015-2026 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::enums::PriceType;
17use pyo3::prelude::*;
18
19use crate::{indicator::Indicator, ratio::efficiency_ratio::EfficiencyRatio};
20
21#[pymethods]
22#[pyo3_stub_gen::derive::gen_stub_pymethods]
23impl EfficiencyRatio {
24 /// An indicator which calculates the efficiency ratio across a rolling window.
25 ///
26 /// The Kaufman Efficiency measures the ratio of the relative market speed in
27 /// relation to the volatility, this could be thought of as a proxy for noise.
28 #[new]
29 #[pyo3(signature = (period, price_type=None))]
30 fn py_new(period: usize, price_type: Option<PriceType>) -> Self {
31 Self::new(period, price_type)
32 }
33
34 fn __repr__(&self) -> String {
35 format!("EfficiencyRatio({})", self.period)
36 }
37
38 #[getter]
39 #[pyo3(name = "name")]
40 fn py_name(&self) -> String {
41 self.name()
42 }
43
44 #[getter]
45 #[pyo3(name = "period")]
46 const fn py_period(&self) -> usize {
47 self.period
48 }
49
50 #[getter]
51 #[pyo3(name = "value")]
52 const fn py_value(&self) -> f64 {
53 self.value
54 }
55
56 #[getter]
57 #[pyo3(name = "initialized")]
58 const fn py_initialized(&self) -> bool {
59 self.initialized
60 }
61
62 #[getter]
63 #[pyo3(name = "has_inputs")]
64 fn py_has_inputs(&self) -> bool {
65 self.has_inputs()
66 }
67
68 #[pyo3(name = "update_raw")]
69 fn py_update_raw(&mut self, value: f64) {
70 self.update_raw(value);
71 }
72}