Indicado.MFI (Indicado v0.0.4) View Source
This is the MFI module used for calculating Money Flow Index
Link to this section Summary
Types
The argument passed to eval functions should be a list of mfi_data_map type.
Functions
Calculates MFI for the list. It needs list of mfi_data_map and lenght of list should be at least 1 higher then period.
Calculates MFI for the list. It needs list of mfi_data_map and lenght of list should be at least 1 higher then period.
Link to this section Types
Specs
The argument passed to eval functions should be a list of mfi_data_map type.
Link to this section Functions
Specs
eval([mfi_data_map(), ...], pos_integer()) :: {:ok, [float(), ...] | {:error, atom()}}
Calculates MFI for the list. It needs list of mfi_data_map and lenght of list should be at least 1 higher then period.
Returns {:ok, mfi_list}
or {:error, reason}
Examples
iex> Indicado.MFI.eval([%{low: 1, high: 3, close: 2, volume: 1}, %{low: 2, high: 4, close: 3, volume: 2}, %{low: 1, high: 2, close: 2, volume: 5}, %{low: 3, high: 5, close: 4, volume: 1}], 2)
{:ok, [41.860465116279066, 32.432432432432435]}
iex> Indicado.MFI.eval([%{low: 2, high: 4, close: 4, volume: 1}, %{low: 2, high: 5, close: 3, volume: 5}, %{low: 5, high: 8, close: 5, volume: 5}, %{low: 3, high: 5, close: 5, volume: 3}, %{low: 1, high: 3, close: 2, volume: 10}], 3)
{:ok, [69.76744186046511, 47.61904761904762]}
iex> Indicado.MFI.eval([%{low: 1, high: 3, close: 2, volume: 1}, %{low: 2, high: 4, close: 3, volume: 2}, %{low: 1, high: 2, close: 2, volume: 5}, %{low: 3, high: 5, close: 4, volume: 1}], 5)
{:error, :not_enough_data}
iex> Indicado.MFI.eval([%{low: 1, high: 3, close: 2, volume: 1}, %{low: 2, high: 4, close: 3, volume: 2}, %{low: 1, high: 2, close: 2, volume: 5}, %{low: 3, high: 5, close: 4, volume: 1}], 0)
{:error, :bad_period}
Specs
eval!([mfi_data_map(), ...], pos_integer()) :: [float(), ...] | no_return()
Calculates MFI for the list. It needs list of mfi_data_map and lenght of list should be at least 1 higher then period.
Raises NotEnoughDataError
if the given list is not longh enough for calculating MFI.
Raises BadPeriodError
if period is an unacceptable number.
Examples
iex> Indicado.MFI.eval!([%{low: 1, high: 3, close: 2, volume: 1}, %{low: 2, high: 4, close: 3, volume: 2}, %{low: 1, high: 2, close: 2, volume: 5}, %{low: 3, high: 5, close: 4, volume: 1}], 2)
[41.860465116279066, 32.432432432432435]
iex> Indicado.MFI.eval!([%{low: 1, high: 3, close: 2, volume: 1}, %{low: 2, high: 4, close: 3, volume: 2}, %{low: 1, high: 2, close: 2, volume: 5}, %{low: 3, high: 5, close: 4, volume: 1}], 5)
** (NotEnoughDataError) not enough data
iex> Indicado.MFI.eval!([%{low: 1, high: 3, close: 2, volume: 1}, %{low: 2, high: 4, close: 3, volume: 2}, %{low: 1, high: 2, close: 2, volume: 5}, %{low: 3, high: 5, close: 4, volume: 1}], 0)
** (BadPeriodError) bad period