pub struct EaseOfMovement { /* private fields */ }Expand description
Richard Arms’ Ease of Movement — how far price travels per unit of volume.
distance_t = (high_t + low_t)/2 − (high_{t−1} + low_{t−1})/2
EMV_t = distance_t · (high_t − low_t) · divisor / volume_t
EOM_t = SMA(EMV, period)_tA large positive EMV means price climbed a long way on light volume — it
moved “easily”; a value near zero means heavy volume was needed to shift
price at all. The divisor only rescales the output: the conventional
1e8 keeps EMV in a readable range for typical share volumes. A bar with
zero volume contributes EMV = 0 (no trading carries no signal), as does a
zero-range bar. The first candle only seeds the previous midpoint, so the
first value appears on candle period + 1.
§Example
use wickra_core::{Candle, Indicator, EaseOfMovement};
let mut indicator = EaseOfMovement::new(14).unwrap();
let mut last = None;
for i in 0..80 {
let base = 100.0 + f64::from(i);
let candle =
Candle::new(base, base + 2.0, base - 2.0, base + 1.0, 10.0, i64::from(i)).unwrap();
last = indicator.update(candle);
}
assert!(last.is_some());Implementations§
Source§impl EaseOfMovement
impl EaseOfMovement
Sourcepub fn new(period: usize) -> Result<Self>
pub fn new(period: usize) -> Result<Self>
Construct an Ease of Movement with the conventional 1e8 volume divisor.
§Errors
Returns Error::PeriodZero if period == 0.
Sourcepub fn with_divisor(period: usize, divisor: f64) -> Result<Self>
pub fn with_divisor(period: usize, divisor: f64) -> Result<Self>
Construct an Ease of Movement with an explicit volume divisor. The
divisor is a pure output-scaling constant; pick whatever keeps EMV
readable for your instrument’s volume magnitude.
§Errors
Returns Error::PeriodZero if period == 0 and
Error::NonPositiveMultiplier if divisor is not strictly positive
and finite.
Trait Implementations§
Source§impl Clone for EaseOfMovement
impl Clone for EaseOfMovement
Source§fn clone(&self) -> EaseOfMovement
fn clone(&self) -> EaseOfMovement
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for EaseOfMovement
impl Debug for EaseOfMovement
Source§impl Indicator for EaseOfMovement
impl Indicator for EaseOfMovement
Source§type Input = Candle
type Input = Candle
f64 for a price, or Candle / Tick).Source§fn update(&mut self, candle: Candle) -> Option<f64>
fn update(&mut self, candle: Candle) -> Option<f64>
None if the indicator is still warming up.Source§fn reset(&mut self)
fn reset(&mut self)
Source§fn warmup_period(&self) -> usize
fn warmup_period(&self) -> usize
None output can be produced.Auto Trait Implementations§
impl Freeze for EaseOfMovement
impl RefUnwindSafe for EaseOfMovement
impl Send for EaseOfMovement
impl Sync for EaseOfMovement
impl Unpin for EaseOfMovement
impl UnsafeUnpin for EaseOfMovement
impl UnwindSafe for EaseOfMovement
Blanket Implementations§
Source§impl<T> BatchExt for Twhere
T: Indicator,
impl<T> BatchExt for Twhere
T: Indicator,
Source§fn batch(&mut self, inputs: &[Self::Input]) -> Vec<Option<Self::Output>>
fn batch(&mut self, inputs: &[Self::Input]) -> Vec<Option<Self::Output>>
None during warmup) per input.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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more