quantwave_core/indicators/
talib_wrapper.rs1#![allow(non_camel_case_types)]
9
10#[macro_export]
12macro_rules! native_pointwise_1 {
13 ($name:ident, $op:expr) => {
14 #[derive(Debug, Clone, Default)]
15 pub struct $name;
16
17 impl $name {
18 pub fn new() -> Self {
19 Self
20 }
21 }
22
23 impl $crate::traits::Next<f64> for $name {
24 type Output = f64;
25
26 fn next(&mut self, input: f64) -> Self::Output {
27 ($op)(input)
28 }
29
30 fn next_batch(&mut self, inputs: &[f64]) -> Vec<Self::Output>
31 where
32 f64: Copy,
33 {
34 inputs.iter().map(|&x| ($op)(x)).collect()
35 }
36 }
37 };
38}
39
40#[macro_export]
42macro_rules! native_binary_2 {
43 ($name:ident, $op:expr) => {
44 #[derive(Debug, Clone, Default)]
45 pub struct $name;
46
47 impl $name {
48 pub fn new() -> Self {
49 Self
50 }
51 }
52
53 impl $crate::traits::Next<(f64, f64)> for $name {
54 type Output = f64;
55
56 fn next(&mut self, (a, b): (f64, f64)) -> Self::Output {
57 ($op)(a, b)
58 }
59
60 fn next_batch(&mut self, inputs: &[(f64, f64)]) -> Vec<Self::Output>
61 where
62 (f64, f64): Copy,
63 {
64 inputs.iter().map(|&(a, b)| ($op)(a, b)).collect()
65 }
66 }
67 };
68}