pub struct TsfOscillator { /* private fields */ }Expand description
Time Series Forecast Oscillator — the percentage gap between the close and the one-bar-ahead time-series forecast of the close.
TSFOsc_t = 100 · (close_t − TSF(close, period)_t) / close_twhere Tsf projects the rolling least-squares line one bar
past the window (a + b·period). It is the close-relative companion to
Cfo, which measures the same percentage gap against the
regression value at the current bar (a + b·(period − 1)). Because TSF
advances one bar further than LinearRegression, the two differ by exactly
the slope term 100·b/close: on a trending series TSFOsc reads more
negative in an uptrend (the forecast has already stepped above price) and
more positive in a downtrend.
Positive readings mean the close sits above its forward forecast (price
has overshot the projected trend); negative readings mean it sits below.
Wraps the existing Tsf so the warmup matches.
§Example
use wickra_core::{Indicator, TsfOscillator};
let mut indicator = TsfOscillator::new(14).unwrap();
let mut last = None;
for i in 0..40 {
last = indicator.update(100.0 + f64::from(i));
}
assert!(last.is_some());Implementations§
Trait Implementations§
Source§impl Clone for TsfOscillator
impl Clone for TsfOscillator
Source§fn clone(&self) -> TsfOscillator
fn clone(&self) -> TsfOscillator
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for TsfOscillator
impl Debug for TsfOscillator
Source§impl Indicator for TsfOscillator
impl Indicator for TsfOscillator
Source§fn update(&mut self, input: f64) -> Option<f64>
fn update(&mut self, input: f64) -> Option<f64>
None if the indicator is still warming up.Source§fn reset(&mut self)
fn reset(&mut self)
Source§fn warmup_period(&self) -> usize
fn warmup_period(&self) -> usize
None output can be produced.Auto Trait Implementations§
impl Freeze for TsfOscillator
impl RefUnwindSafe for TsfOscillator
impl Send for TsfOscillator
impl Sync for TsfOscillator
impl Unpin for TsfOscillator
impl UnsafeUnpin for TsfOscillator
impl UnwindSafe for TsfOscillator
Blanket Implementations§
Source§impl<T> BatchExt for Twhere
T: Indicator,
impl<T> BatchExt for Twhere
T: Indicator,
Source§fn batch(&mut self, inputs: &[Self::Input]) -> Vec<Option<Self::Output>>
fn batch(&mut self, inputs: &[Self::Input]) -> Vec<Option<Self::Output>>
None during warmup) per input.Source§impl<T> BatchNanExt for T
impl<T> BatchNanExt for T
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more