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::Unavailableuntilperiodbars have been seen. - Returns
SignalValue::Unavailableif 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§
Trait Implementations§
Source§impl Signal for RangeEfficiency
impl Signal for RangeEfficiency
Source§fn period(&self) -> usize
fn period(&self) -> usize
Returns the number of bars required before the signal produces a value.
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 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 RangeEfficiency
impl RefUnwindSafe for RangeEfficiency
impl Send for RangeEfficiency
impl Sync for RangeEfficiency
impl Unpin for RangeEfficiency
impl UnsafeUnpin for RangeEfficiency
impl UnwindSafe for RangeEfficiency
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