pub struct OnBalanceVolume { /* private fields */ }
Expand description
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
Implementations§
Trait Implementations§
Source§impl Clone for OnBalanceVolume
impl Clone for OnBalanceVolume
Source§fn clone(&self) -> OnBalanceVolume
fn clone(&self) -> OnBalanceVolume
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for OnBalanceVolume
impl Debug for OnBalanceVolume
Source§impl Default for OnBalanceVolume
impl Default for OnBalanceVolume
Source§impl Display for OnBalanceVolume
impl Display for OnBalanceVolume
Auto Trait Implementations§
impl Freeze for OnBalanceVolume
impl RefUnwindSafe for OnBalanceVolume
impl Send for OnBalanceVolume
impl Sync for OnBalanceVolume
impl Unpin for OnBalanceVolume
impl UnwindSafe for OnBalanceVolume
Blanket Implementations§
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
Mutably borrows from an owned value. Read more