Skip to main content

nautilus_indicators/python/momentum/
amat.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::data::{Bar, QuoteTick, TradeTick};
17use pyo3::prelude::*;
18
19use crate::{
20    average::MovingAverageType, indicator::Indicator, momentum::amat::ArcherMovingAveragesTrends,
21};
22
23#[pymethods]
24#[pyo3_stub_gen::derive::gen_stub_pymethods]
25impl ArcherMovingAveragesTrends {
26    /// Creates a new `ArcherMovingAveragesTrends` instance.
27    #[new]
28    #[pyo3(signature = (fast_period, slow_period, signal_period, ma_type=None))]
29    #[must_use]
30    pub fn py_new(
31        fast_period: usize,
32        slow_period: usize,
33        signal_period: usize,
34        ma_type: Option<MovingAverageType>,
35    ) -> Self {
36        Self::new(fast_period, slow_period, signal_period, ma_type)
37    }
38
39    fn __repr__(&self) -> String {
40        format!(
41            "ArcherMovingAveragesTrends({},{},{},{})",
42            self.fast_period, self.slow_period, self.signal_period, self.ma_type
43        )
44    }
45
46    #[getter]
47    #[pyo3(name = "name")]
48    fn py_name(&self) -> String {
49        self.name()
50    }
51
52    #[getter]
53    #[pyo3(name = "fast_period")]
54    const fn py_fast_period(&self) -> usize {
55        self.fast_period
56    }
57
58    #[getter]
59    #[pyo3(name = "slow_period")]
60    const fn py_slow_period(&self) -> usize {
61        self.slow_period
62    }
63
64    #[getter]
65    #[pyo3(name = "signal_period")]
66    const fn py_signal_period(&self) -> usize {
67        self.signal_period
68    }
69
70    #[getter]
71    #[pyo3(name = "has_inputs")]
72    fn py_has_inputs(&self) -> bool {
73        self.has_inputs()
74    }
75
76    #[getter]
77    #[pyo3(name = "long_run")]
78    const fn py_long_run(&self) -> bool {
79        self.long_run
80    }
81
82    #[getter]
83    #[pyo3(name = "short_run")]
84    const fn py_short_run(&self) -> bool {
85        self.short_run
86    }
87
88    #[getter]
89    #[pyo3(name = "initialized")]
90    const fn py_initialized(&self) -> bool {
91        self.initialized
92    }
93
94    /// Updates the indicator with a new raw price value.
95    #[pyo3(name = "update_raw")]
96    fn py_update_raw(&mut self, close: f64) {
97        self.update_raw(close);
98    }
99
100    #[pyo3(name = "handle_quote_tick")]
101    const fn py_handle_quote_tick(&mut self, _quote: &QuoteTick) {
102        // Function body intentionally left blank.
103    }
104
105    #[pyo3(name = "handle_trade_tick")]
106    const fn py_handle_trade_tick(&mut self, _trade: &TradeTick) {
107        // Function body intentionally left blank.
108    }
109
110    #[pyo3(name = "handle_bar")]
111    fn py_handle_bar(&mut self, bar: &Bar) {
112        self.handle_bar(bar);
113    }
114
115    #[pyo3(name = "reset")]
116    fn py_reset(&mut self) {
117        self.reset();
118    }
119}