Skip to main content

VolatilityCompression

Struct VolatilityCompression 

Source
pub struct VolatilityCompression { /* private fields */ }
Expand description

Volatility Compression — consecutive count of bars where the bar’s range is below the rolling average range over the last period bars.

Outputs:

  • +N: N consecutive bars where range < rolling avg (compression building).
  • 0: current bar has range >= rolling avg (compression broken).

This is useful for detecting squeeze setups: prolonged compression often precedes a volatility expansion breakout.

Returns SignalValue::Unavailable until period bars have been seen.

§Errors

Returns FinError::InvalidPeriod if period == 0.

§Example

use fin_primitives::signals::indicators::VolatilityCompression;
use fin_primitives::signals::Signal;

let vc = VolatilityCompression::new("vc", 14).unwrap();
assert_eq!(vc.period(), 14);

Implementations§

Source§

impl VolatilityCompression

Source

pub fn new(name: impl Into<String>, period: usize) -> Result<Self, FinError>

Constructs a new VolatilityCompression.

§Errors

Returns FinError::InvalidPeriod if period == 0.

Source

pub fn streak(&self) -> u32

Returns the current compression streak count.

Trait Implementations§

Source§

impl Signal for VolatilityCompression

Source§

fn name(&self) -> &str

Returns the name of this signal (unique within a pipeline).
Source§

fn period(&self) -> usize

Returns the number of bars required before the signal produces a value.
Source§

fn is_ready(&self) -> bool

Returns true if the signal has accumulated enough bars to produce a value.
Source§

fn update(&mut self, bar: &BarInput) -> Result<SignalValue, FinError>

Updates the signal with a BarInput and returns the current value. Read more
Source§

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>

Convenience wrapper: converts bar to BarInput and calls Self::update.
Source§

fn warm_up(&mut self, bars: &[BarInput]) -> Result<SignalValue, FinError>

Feed a slice of historical bars to prime the indicator in one call. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.