pub struct RangeMidpointPosition { /* private fields */ }Expand description
Range Midpoint Position — (close - midpoint) / half_range normalized to [-1, 1].
Computes the N-period high/low midpoint and measures where the close sits:
- +1.0: close at the period high.
- 0.0: close at the midpoint of the period range.
- -1.0: close at the period low.
Returns SignalValue::Unavailable until period bars have been accumulated,
or when high == low (zero range).
§Errors
Returns FinError::InvalidPeriod if period == 0.
§Example
use fin_primitives::signals::indicators::RangeMidpointPosition;
use fin_primitives::signals::Signal;
let rmp = RangeMidpointPosition::new("rmp_20", 20).unwrap();
assert_eq!(rmp.period(), 20);Implementations§
Trait Implementations§
Source§impl Signal for RangeMidpointPosition
impl Signal for RangeMidpointPosition
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 RangeMidpointPosition
impl RefUnwindSafe for RangeMidpointPosition
impl Send for RangeMidpointPosition
impl Sync for RangeMidpointPosition
impl Unpin for RangeMidpointPosition
impl UnsafeUnpin for RangeMidpointPosition
impl UnwindSafe for RangeMidpointPosition
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