Indicado.SR (Indicado v0.0.4) View Source

This is the SR module used for calculating Stochastic Oscillator.

Link to this section Summary

Functions

Calculates SR for the list.

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

Link to this section Functions

Specs

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

Calculates SR for the list.

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

Examples

iex> Indicado.SR.eval([1, 3, 4, 3, 1, 5], 4)
{:ok, [66.66666666666666, 0.0, 100.0]}

iex> Indicado.SR.eval([1, 10, 5, 3, 9, 12, 6, 3, 4], 5)
{:ok, [88.88888888888889, 100.0, 33.33333333333333, 0.0, 11.11111111111111]}

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

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

Specs

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

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

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

Examples

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

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

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