Struct MFI

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

Money Flow Index (MFI) Indicator

MFI is a momentum indicator that uses both price and volume to identify overbought or oversold conditions. It’s often called “Volume-weighted RSI”.

Formula:

  1. Typical Price = (High + Low + Close) / 3
  2. Raw Money Flow = Typical Price × Volume
  3. Money Flow Direction: Positive if current TP > previous TP, else Negative
  4. Money Ratio = (Positive Money Flow Sum) / (Negative Money Flow Sum)
  5. MFI = 100 - (100 / (1 + Money Ratio))

Implementations§

Source§

impl MFI

Source

pub fn new() -> Self

Create a new MFI calculator with default configuration (period=14)

Source

pub fn with_period(period: usize) -> Result<Self, MFIError>

Create a new MFI calculator with custom period

Source

pub fn with_config(config: MFIConfig) -> Self

Create a new MFI calculator with custom configuration

Source

pub fn calculate(&mut self, input: MFIInput) -> Result<MFIOutput, MFIError>

Calculate MFI for the given input

Source

pub fn calculate_batch( &mut self, inputs: &[MFIInput], ) -> Result<Vec<MFIOutput>, MFIError>

Calculate MFI for a batch of inputs

Source

pub fn reset(&mut self)

Reset the calculator state

Source

pub fn get_state(&self) -> &MFIState

Get current state (for serialization/debugging)

Source

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

Restore state (for deserialization)

Source

pub fn positive_money_flow(&self) -> f64

Get current positive money flow sum

Source

pub fn negative_money_flow(&self) -> f64

Get current negative money flow sum

Trait Implementations§

Source§

impl Default for MFI

Source§

fn default() -> Self

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

Auto Trait Implementations§

§

impl Freeze for MFI

§

impl RefUnwindSafe for MFI

§

impl Send for MFI

§

impl Sync for MFI

§

impl Unpin for MFI

§

impl UnwindSafe for MFI

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.