pub struct VolumeRsi { /* private fields */ }Expand description
Volume RSI — the Relative Strength Index computed on volume changes instead of price changes.
Wilder’s Rsi measures the balance of up- versus down-price
moves; the Volume RSI applies the identical accumulator to the bar-over-bar
change in volume:
change_t = volume_t − volume_{t−1}
gain = max(change, 0), loss = max(−change, 0)
avg_gain, avg_loss = Wilder-smoothed over `period`
VolumeRSI = 100 * avg_gain / (avg_gain + avg_loss)Readings above 50 mean volume is expanding (more was added than removed over
the smoothing window) and tend to confirm the prevailing move; readings below
50 mark contracting participation. Output is bounded in [0, 100]; a stretch
of unchanged volume drives both averages to 0 and the indicator reports the
neutral 50 rather than an undefined 0 / 0.
Only the candle’s volume is used. The first bar sets the previous volume,
then period changes seed Wilder’s averages, so the first value lands after
period + 1 inputs. Each update is O(1).
§Example
use wickra_core::{Candle, Indicator, VolumeRsi};
let mut indicator = VolumeRsi::new(14).unwrap();
let mut last = None;
for i in 0..40 {
let v = 1_000.0 + (f64::from(i) * 0.3).sin() * 400.0;
let c = Candle::new(100.0, 101.0, 99.0, 100.5, v, 0).unwrap();
last = indicator.update(c);
}
assert!(last.is_some());Implementations§
Trait Implementations§
Source§impl Indicator for VolumeRsi
impl Indicator for VolumeRsi
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 VolumeRsi
impl RefUnwindSafe for VolumeRsi
impl Send for VolumeRsi
impl Sync for VolumeRsi
impl Unpin for VolumeRsi
impl UnsafeUnpin for VolumeRsi
impl UnwindSafe for VolumeRsi
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