Xirr (xirr v0.9.0)

Library to calculate XIRR and absolute rate of return through the Newton Raphson method.

Link to this section Summary

Functions

Function to calculate the absolute rate of return for a given array of dates and values.

Function to calculate the rate of return for a given array of dates and values.

Link to this section Functions

Link to this function

absolute_rate(rate, days)

Specs

absolute_rate(float(), integer()) :: {:ok, float()} | {:error, String.t()}

Function to calculate the absolute rate of return for a given array of dates and values.

Examples

iex> d = [{1985, 1, 1}, {1990, 1, 1}, {1995, 1, 1}]
iex> v = [1000, -600, -200]
iex> {:ok, rate} = Xirr.xirr(d,v)
iex> Xirr.absolute_rate(rate, 50)
{:ok, -0.481092}
Link to this function

xirr(dates, values)

Specs

xirr([Date.t()], [number()]) :: float()

Function to calculate the rate of return for a given array of dates and values.

Examples

iex> d = [{1985, 1, 1}, {1990, 1, 1}, {1995, 1, 1}]
iex> v = [1000, -600, -200]
iex> Xirr.xirr(d,v)
{:ok, -0.034592}