[][src]Struct ta::indicators::OnBalanceVolume

pub struct OnBalanceVolume { /* fields omitted */ }

On Balance Volume (OBV).

The OBV is an volume and price based oscillator which gives cumulative total volumes. OBV measures buying and selling pressure as a cumulative indicator, adding volume on up days and subtracting it on down days.

Formula

If the closing price is above the prior close price then: Current OBV = Previous OBV + Current Volume

If the closing price is below the prior close price then: Current OBV = Previous OBV - Current Volume

If the closing prices equals the prior close price then: Current OBV = Previous OBV

Where:

obv - on the balance volume

Example

use ta::indicators::OnBalanceVolume;
use ta::{Next, DataItem};

let mut obv = OnBalanceVolume::new();

let di1 = DataItem::builder()
            .high(3.0)
            .low(1.0)
            .close(2.0)
            .open(1.5)
            .volume(1000.0)
            .build().unwrap();

let di2 = DataItem::builder()
            .high(3.0)
            .low(1.0)
            .close(1.5)
            .open(1.5)
            .volume(300.0)
            .build().unwrap();

assert_eq!(obv.next(&di1), 1000.0);
assert_eq!(obv.next(&di2), 700.0);

Links

Methods

impl OnBalanceVolume[src]

pub fn new() -> Self[src]

Trait Implementations

impl Clone for OnBalanceVolume[src]

impl Debug for OnBalanceVolume[src]

impl Default for OnBalanceVolume[src]

impl Display for OnBalanceVolume[src]

impl<'a, T: Close + Volume> Next<&'a T> for OnBalanceVolume[src]

type Output = f64

impl Reset for OnBalanceVolume[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.