Skip to main content

quantwave_core/features/
instantaneous_trendline.rs

1//! Instantaneous Trendline feature extractor wrapper.
2//!
3//! Wraps the zero-lag trendline. For richer ML use we expose the trend value
4//! + a simple derived "trend strength" (placeholder for phase/power in future).
5//!
6//! Source: quantwave-core/src/indicators/instantaneous_trendline.rs (returns f64 trend)
7
8use crate::indicators::instantaneous_trendline::InstantaneousTrendline;
9use crate::traits::Next;
10
11#[derive(Debug, Clone, Copy, PartialEq)]
12pub struct InstantaneousTrendlineFeatures {
13    pub trend: f64,
14    /// Placeholder for future phase/power derived features (0.0 for now)
15    pub strength: f64,
16}
17
18#[derive(Debug, Clone)]
19pub struct InstantaneousTrendlineFeatureExtractor {
20    inner: InstantaneousTrendline,
21}
22
23impl InstantaneousTrendlineFeatureExtractor {
24    pub fn new() -> Self {
25        Self {
26            inner: InstantaneousTrendline::new(),
27        }
28    }
29}
30
31impl Next<f64> for InstantaneousTrendlineFeatureExtractor {
32    type Output = InstantaneousTrendlineFeatures;
33
34    fn next(&mut self, input: f64) -> Self::Output {
35        let trend = self.inner.next(input);
36        // For MVP, strength is 0.0. Real phase/power can be added later from the indicator internals if exposed.
37        InstantaneousTrendlineFeatures { trend, strength: 0.0 }
38    }
39}