Skip to main content

nautilus_indicators/python/momentum/
ichimoku.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;
17use pyo3::prelude::*;
18
19use crate::{indicator::Indicator, momentum::ichimoku::IchimokuCloud};
20
21#[pymethods]
22impl IchimokuCloud {
23    #[new]
24    #[pyo3(signature = (tenkan_period=9, kijun_period=26, senkou_period=52, displacement=26))]
25    #[must_use]
26    pub fn py_new(
27        tenkan_period: usize,
28        kijun_period: usize,
29        senkou_period: usize,
30        displacement: usize,
31    ) -> Self {
32        Self::new(tenkan_period, kijun_period, senkou_period, displacement)
33    }
34
35    fn __repr__(&self) -> String {
36        format!("{self}")
37    }
38
39    #[getter]
40    #[pyo3(name = "name")]
41    fn py_name(&self) -> String {
42        self.name()
43    }
44
45    #[getter]
46    #[pyo3(name = "tenkan_period")]
47    const fn py_tenkan_period(&self) -> usize {
48        self.tenkan_period
49    }
50
51    #[getter]
52    #[pyo3(name = "kijun_period")]
53    const fn py_kijun_period(&self) -> usize {
54        self.kijun_period
55    }
56
57    #[getter]
58    #[pyo3(name = "senkou_period")]
59    const fn py_senkou_period(&self) -> usize {
60        self.senkou_period
61    }
62
63    #[getter]
64    #[pyo3(name = "displacement")]
65    const fn py_displacement(&self) -> usize {
66        self.displacement
67    }
68
69    #[getter]
70    #[pyo3(name = "has_inputs")]
71    fn py_has_inputs(&self) -> bool {
72        self.has_inputs()
73    }
74
75    #[getter]
76    #[pyo3(name = "tenkan_sen")]
77    const fn py_tenkan_sen(&self) -> f64 {
78        self.tenkan_sen
79    }
80
81    #[getter]
82    #[pyo3(name = "kijun_sen")]
83    const fn py_kijun_sen(&self) -> f64 {
84        self.kijun_sen
85    }
86
87    #[getter]
88    #[pyo3(name = "senkou_span_a")]
89    const fn py_senkou_span_a(&self) -> f64 {
90        self.senkou_span_a
91    }
92
93    #[getter]
94    #[pyo3(name = "senkou_span_b")]
95    const fn py_senkou_span_b(&self) -> f64 {
96        self.senkou_span_b
97    }
98
99    #[getter]
100    #[pyo3(name = "chikou_span")]
101    const fn py_chikou_span(&self) -> f64 {
102        self.chikou_span
103    }
104
105    #[getter]
106    #[pyo3(name = "initialized")]
107    const fn py_initialized(&self) -> bool {
108        self.initialized
109    }
110
111    #[pyo3(name = "update_raw")]
112    fn py_update_raw(&mut self, high: f64, low: f64, close: f64) {
113        self.update_raw(high, low, close);
114    }
115
116    #[pyo3(name = "handle_bar")]
117    fn py_handle_bar(&mut self, bar: &Bar) {
118        self.handle_bar(bar);
119    }
120
121    #[pyo3(name = "reset")]
122    fn py_reset(&mut self) {
123        self.reset();
124    }
125}