diff --git a/lib/ex_xirr.ex b/lib/ex_xirr.ex index 33103db..65bc2ce 100644 --- a/lib/ex_xirr.ex +++ b/lib/ex_xirr.ex @@ -185,6 +185,9 @@ defmodule ExXirr do defp calculate(:xirr, _, _, rate, _) when rate > 1_000_000_000, do: {:error, "Converged on infinity."} + defp calculate(:xirr, _, _, rate, _) when rate > -1_000_000, + do: {:error, "Converged on infinity."} + defp calculate(:xirr, _, acc, rate, _) when acc in [-0.0, +0.0], do: {:ok, Float.round(rate, 8)} defp calculate(:xirr, _, _, -1.0, _), do: {:error, "Could not converge."}