Indicado.RSI (Indicado v0.0.4) View Source

This is the RSI module used for calculating Relative Strength Index

Link to this section Summary

Functions

Calculates RSI for the list. It needs list of numbers and the length of list argument should at least be 1 more than period.

Calculates RSI for the list. It needs list of numbers and the length of list argument should at least be 1 more than period.

Link to this section Functions

Specs

eval([list(), ...], pos_integer()) :: {:ok, [float(), ...] | {:error, atom()}}

Calculates RSI for the list. It needs list of numbers and the length of list argument should at least be 1 more than period.

Returns {:ok, rsi_list} or {:error, reason}

Examples

iex> Indicado.RSI.eval([1, 2, 3, 4, 5, 6], 2)
{:ok, [100.0, 100.0, 100.0, 100.0]}

iex> Indicado.RSI.eval([5, 4, 3, 2, 1, 0], 4)
{:ok, [0.0, 0.0]}

iex> Indicado.RSI.eval([2, 4, 6, 7, 2, 1, 5, 10], 3)
{:ok, [100.0, 37.5, 14.285714285714292, 39.99999999999999, 90.0]}

iex> Indicado.RSI.eval([], 2)
{:error, :not_enough_data}

iex> Indicado.RSI.eval([1, 5, 10], 3)
{:error, :not_enough_data}

iex> Indicado.RSI.eval([1, 4], 0)
{:error, :bad_period}

Specs

eval!([list(), ...], pos_integer()) :: [float(), ...] | no_return()

Calculates RSI for the list. It needs list of numbers and the length of list argument should at least be 1 more than period.

Raises NotEnoughDataError if the given list is not longh enough for calculating RSI. Raises BadPeriodError if period is an unacceptable number.

Examples

iex> Indicado.RSI.eval!([1, 3, 5, 7], 2)
[100.0, 100.0]

iex> Indicado.RSI.eval!([1, 3], 3)
** (NotEnoughDataError) not enough data

iex> Indicado.RSI.eval!([1, 3, 4], 0)
** (BadPeriodError) bad period