E15: add a runnable doctest to every indicator type
Only two doctests existed in wickra-core; none of the 25 indicator types carried a runnable rustdoc example. Add an "# Example" doctest to every public indicator type (all 26, including RollingVwap): construct the indicator and stream 80 inputs through update, asserting a value is produced. The candle-input indicators build valid OHLCV candles inline. cargo test --doc -p wickra-core now runs 28 doctests, all passing; fmt and clippy clean.
This commit is contained in:
@@ -8,6 +8,19 @@ use crate::traits::Indicator;
|
||||
/// where `EMA2 = EMA(EMA1)` and `EMA3 = EMA(EMA2)`.
|
||||
///
|
||||
/// Reduces lag further than DEMA at the cost of more responsiveness to noise.
|
||||
///
|
||||
/// # Example
|
||||
///
|
||||
/// ```
|
||||
/// use wickra_core::{Indicator, Tema};
|
||||
///
|
||||
/// let mut indicator = Tema::new(3).unwrap();
|
||||
/// let mut last = None;
|
||||
/// for i in 0..80 {
|
||||
/// last = indicator.update(100.0 + f64::from(i));
|
||||
/// }
|
||||
/// assert!(last.is_some());
|
||||
/// ```
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct Tema {
|
||||
ema1: Ema,
|
||||
|
||||
Reference in New Issue
Block a user