Skip to main content

Vortex

Struct Vortex 

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

Vortex Indicator — computes VI+ (upward movement) as the primary scalar output.

VM+[i] = |high[i] - low[i-1]|
VM-[i] = |low[i]  - high[i-1]|
TR[i]  = max(high[i], prev_close) - min(low[i], prev_close)

VI+    = sum(VM+, n) / sum(TR, n)
VI-    = sum(VM-, n) / sum(TR, n)

Signal::update() returns VI+ as the primary scalar. Access VI- via Vortex::vi_minus.

Returns SignalValue::Unavailable until period bars have been seen.

§Example

use fin_primitives::signals::indicators::Vortex;
use fin_primitives::signals::Signal;

let vortex = Vortex::new("vx", 14).unwrap();
assert_eq!(vortex.period(), 14);

Implementations§

Source§

impl Vortex

Source

pub fn new(name: impl Into<String>, period: usize) -> Result<Self, FinError>

Constructs a new Vortex with the given period.

§Errors

Returns FinError::InvalidPeriod if period == 0.

Source

pub fn vi_minus(&self) -> Option<Decimal>

Returns the latest VI- value, or None if not yet ready.

Trait Implementations§

Source§

impl Signal for Vortex

Source§

fn name(&self) -> &str

Returns the name of this signal (unique within a pipeline).
Source§

fn update(&mut self, bar: &BarInput) -> Result<SignalValue, FinError>

Updates the signal with a BarInput and returns the current value. Read more
Source§

fn is_ready(&self) -> bool

Returns true if the signal has accumulated enough bars to produce a value.
Source§

fn period(&self) -> usize

Returns the number of bars required before the signal produces a value.
Source§

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>

Convenience wrapper: converts bar to BarInput and calls Self::update.
Source§

fn warm_up(&mut self, bars: &[BarInput]) -> Result<SignalValue, FinError>

Feed a slice of historical bars to prime the indicator in one call. Read more

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> 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.