Skip to main content

RelativeVolatilityIndex

Struct RelativeVolatilityIndex 

Source
pub struct RelativeVolatilityIndex { /* private fields */ }
Expand description

Relative Volatility Index: the Relative Strength Index construction applied to volatility instead of to price change.

For each bar the standard deviation of the last stdev_len prices is computed. That figure is then filed under “up” or “down” depending on which way the price moved, and the two are Wilder-smoothed over smooth_len:

up_t    = stdev_t if price rose, else 0
down_t  = stdev_t if price fell, else 0
RVI     = 100 * rma(up) / (rma(up) + rma(down))

So it answers “is the recent movement concentrated on the up side or the down side”, where movement means dispersion, not distance. A market that falls steadily with little scatter can therefore read differently from an RSI on the same bars.

This is not the Relative Vigor Index, which this crate registers as rvi and which compares the close-open span to the high-low span. Same three letters, unrelated measurement; hence the separate name.

No claim of numerical agreement with any other implementation is made: the published descriptions of this indicator leave the direction rule, the smoothing and the seed open, and what is implemented here is the contract stated above.

Unit: 0..=100. A bar where the price did not move contributes to neither side. A window in which nothing moved at all leaves both averages at zero; the documented convention there is 50, the same neutral reading this crate’s RSI uses.

First output: once both the deviation window and the Wilder averages are ready, i.e. with bar stdev_len + smooth_len - 1. Indicator::reset clears the window and both averages.

Implementations§

Source§

impl RelativeVolatilityIndex

Source

pub fn new( stdev_len: usize, smooth_len: usize, variant: RelativeVolatilityVariant, ) -> Self

Source

pub fn with_defaults() -> Self

Source

pub fn variant(&self) -> RelativeVolatilityVariant

Trait Implementations§

Source§

impl Clone for RelativeVolatilityIndex

Source§

fn clone(&self) -> RelativeVolatilityIndex

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for RelativeVolatilityIndex

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Indicator for RelativeVolatilityIndex

Source§

fn name(&self) -> &str

Source§

fn warmup_period(&self) -> usize

Source§

fn on_bar(&mut self, bar: &Bar) -> Option<IndicatorOutput>

Source§

fn reset(&mut self)

Source§

fn on_checked_bar( &mut self, bar: &Bar, ) -> Result<Option<IndicatorOutput>, BarValidationError>

Validates a bar before forwarding it to Indicator::on_bar.
Source§

fn alerts(&self) -> Vec<IndicatorAlert>

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.