quantwave_core/features/
trendflex.rs1use crate::indicators::trendflex::Trendflex;
9use crate::traits::Next;
10
11#[derive(Debug, Clone, Copy, PartialEq)]
12pub struct TrendflexFeatures {
13 pub trendflex: f64,
14}
15
16#[derive(Debug, Clone)]
17pub struct TrendflexFeatureExtractor {
18 inner: Trendflex,
19}
20
21impl TrendflexFeatureExtractor {
22 pub fn new(length: usize) -> Self {
23 Self {
24 inner: Trendflex::new(length),
25 }
26 }
27}
28
29impl Next<f64> for TrendflexFeatureExtractor {
30 type Output = TrendflexFeatures;
31
32 fn next(&mut self, input: f64) -> Self::Output {
33 let val = self.inner.next(input);
34 TrendflexFeatures { trendflex: val }
35 }
36}
37
38#[cfg(test)]
39mod tests {
40 use super::*;
41
42 #[test]
43 fn test_trendflex_wrapper_basic() {
44 let mut ext = TrendflexFeatureExtractor::new(20);
45 for i in 0..50 {
46 let val = 100.0 + (i as f64) * 0.1;
47 let f = ext.next(val);
48 }
50 }
51}