pub struct LinearDeviation { /* private fields */ }Expand description
Linear Deviation — the percentage distance between the current close and the
least-squares linear regression value for that bar over the last period bars.
linear_dev = (close - linreg_value) / close × 100Positive values mean price is above the regression line (overbought pressure); negative values mean price is below (oversold pressure).
Returns SignalValue::Unavailable until period bars have been seen or close is zero.
§Example
use fin_primitives::signals::indicators::LinearDeviation;
use fin_primitives::signals::Signal;
let ld = LinearDeviation::new("ld", 14).unwrap();
assert_eq!(ld.period(), 14);Implementations§
Trait Implementations§
Source§impl Signal for LinearDeviation
impl Signal for LinearDeviation
Source§fn is_ready(&self) -> bool
fn is_ready(&self) -> bool
Returns
true if the signal has accumulated enough bars to produce a value.Source§fn period(&self) -> usize
fn period(&self) -> usize
Returns the number of bars required before the signal produces a value.
Source§fn reset(&mut self)
fn reset(&mut self)
Resets the signal to its initial state as if no bars had been seen. Read more
Source§fn update_bar(&mut self, bar: &OhlcvBar) -> Result<SignalValue, FinError>
fn update_bar(&mut self, bar: &OhlcvBar) -> Result<SignalValue, FinError>
Auto Trait Implementations§
impl Freeze for LinearDeviation
impl RefUnwindSafe for LinearDeviation
impl Send for LinearDeviation
impl Sync for LinearDeviation
impl Unpin for LinearDeviation
impl UnsafeUnpin for LinearDeviation
impl UnwindSafe for LinearDeviation
Blanket Implementations§
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
Mutably borrows from an owned value. Read more