Skip to main content

RangeEfficiency

Struct RangeEfficiency 

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

Range Efficiency — ratio of net price displacement to the sum of all bar ranges over the last period bars.

net_move   = |close_now - close_N_ago|
total_range = sum(high_i - low_i) for i in last N bars
efficiency  = net_move / total_range
  • Near 1.0: price moved consistently in one direction with tight, efficient bars.
  • Near 0.0: lots of range used, little net movement — choppy, mean-reverting market.
  • Compared to DirectionalEfficiency (which uses bar-to-bar returns), this uses raw bar ranges — it’s more sensitive to volatility.
  • Returns SignalValue::Unavailable until period bars have been seen.
  • Returns SignalValue::Unavailable if total range is zero.

§Errors

Returns FinError::InvalidPeriod if period == 0.

§Example

use fin_primitives::signals::indicators::RangeEfficiency;
use fin_primitives::signals::Signal;

let re = RangeEfficiency::new("re", 10).unwrap();
assert_eq!(re.period(), 10);

Implementations§

Source§

impl RangeEfficiency

Source

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

Constructs a new RangeEfficiency.

§Errors

Returns FinError::InvalidPeriod if period == 0.

Trait Implementations§

Source§

impl Signal for RangeEfficiency

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.