Skip to content

Commit

Permalink
Add Converted to negative condition
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaelsimonmaia committed Oct 1, 2024
1 parent 68eedd2 commit ed8b303
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/ex_xirr.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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."}
Expand Down

0 comments on commit ed8b303

Please sign in to comment.