Indicado.WR (Indicado v0.0.4) View Source

This is the WR module used for calculating Williams %R.

Link to this section Summary

Functions

Calculates WR for the list.

Calculates WR for the list. Raises exceptions when arguments does not satisfy needed conditions to calculate WR.

Link to this section Functions

Specs

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

Calculates WR for the list.

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

Examples

iex> Indicado.WR.eval([1, 3, 4, 3, 1, 5], 4)
{:ok, [0.3333333333333333, 1.0, 0.0]}

iex> Indicado.WR.eval([1, 10, 5, 3, 9, 12, 6, 3, 4], 5)
{:ok, [0.1111111111111111, 0.0, 0.6666666666666666, 1.0, 0.8888888888888888]}

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

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

Specs

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

Calculates WR for the list. Raises exceptions when arguments does not satisfy needed conditions to calculate WR.

Raises NotEnoughDataError if the given list is not long enough for calculating WR.

Raises BadPeriodError if period is an unacceptable number.

Examples

iex> Indicado.WR.eval!([1, 3, 4, 3, 1, 5], 4)
[0.3333333333333333, 1.0, 0.0]

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

iex> Indicado.WR.eval!([1, 5], 0)
** (BadPeriodError) bad period