Struct OBV

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

On Balance Volume (OBV) Indicator

OBV is a momentum indicator that uses volume flow to predict changes in stock price. It adds volume on up days and subtracts volume on down days.

Formula:

  • If Close > Previous Close: OBV = Previous OBV + Volume
  • If Close < Previous Close: OBV = Previous OBV - Volume
  • If Close = Previous Close: OBV = Previous OBV

Implementations§

Source§

impl OBV

Source

pub fn new() -> Self

Create a new OBV calculator with default configuration

Source

pub fn with_config(config: OBVConfig) -> Self

Create a new OBV calculator with custom configuration

Source

pub fn calculate(&mut self, input: OBVInput) -> Result<OBVOutput, OBVError>

Calculate OBV for the given input

Source

pub fn calculate_batch( &mut self, inputs: &[OBVInput], ) -> Result<Vec<OBVOutput>, OBVError>

Calculate OBV for a batch of inputs

Source

pub fn reset(&mut self)

Reset the calculator state

Source

pub fn get_state(&self) -> &OBVState

Get current state (for serialization/debugging)

Source

pub fn set_state(&mut self, state: OBVState)

Restore state (for deserialization)

Trait Implementations§

Source§

impl Default for OBV

Source§

fn default() -> OBV

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl Freeze for OBV

§

impl RefUnwindSafe for OBV

§

impl Send for OBV

§

impl Sync for OBV

§

impl Unpin for OBV

§

impl UnwindSafe for OBV

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.