Skip to content

Commit

Permalink
Fixes unhandled zero volume (#39)
Browse files Browse the repository at this point in the history
Co-authored-by: taovonqi <[email protected]>
  • Loading branch information
TaoVonQi and taovonqi authored Jan 8, 2024
1 parent 8793cd6 commit 156a794
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/indicators/ease_of_movement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,12 @@ impl<M: MovingAverageConstructor> IndicatorInstance for EaseOfMovementInstance<M

let d = (d_high + d_low) * 0.5;

let v = d * (candle.high() - candle.low()) / candle.volume();
let v = if candle.volume() == 0.0 {
0.0
} else {
d * (candle.high() - candle.low()) / candle.volume()
};

debug_assert!(v.is_finite() && !v.is_nan());

let value = self.m1.next(&v);
Expand Down

0 comments on commit 156a794

Please sign in to comment.