From ed8b303e4e71dc0292ce14103aa9dfab1a6dac2a Mon Sep 17 00:00:00 2001 From: Rafael Simon Maia Date: Mon, 30 Sep 2024 19:05:28 -0600 Subject: [PATCH] Add Converted to negative condition --- lib/ex_xirr.ex | 3 +++ 1 file changed, 3 insertions(+) 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."}