Q: XIRR implementation in Java I tried using https://github.com/RayDeCampo/java-xirr but in some cases it's throwing the exception. If anyone has already solve the issue will be super helpful.
Not working example:

import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.ArrayList;
import java.util.List;

import org.decampo.xirr.NewtonRaphson;
import org.decampo.xirr.Transaction;
import org.decampo.xirr.Xirr;

public class XIRR {

    private static List<Transaction> txns = new ArrayList<>();

    public static void main(String[] args) {
        //txns.add(new Transaction(-100.0, "2022-05-29"));
        //txns.add(new Transaction(-100.0, "2022-05-29"));
        txns.add(new Transaction(-300.0, "2022-05-29"));
        
        txns.add(new Transaction(295.47, "2022-05-31"));
        
        double xirr = Xirr.builder()
                .withTransactions(txns)
                .withNewtonRaphsonBuilder(NewtonRaphson.builder().withIterations(10000).withTolerance(0.000001))
                .withGuess(0.1)
                .xirr()
                *100;
        System.out.println("xirr = " + xirr);
    }
}

It is throwing an exception like
Exception in thread "main" org.decampo.xirr.OverflowException: Candidate overflow: {guess=0.1, iteration=140, candidate=-Infinity, value=-14359.837609828492, derivative=-4.844899455942689E-307}
at org.decampo.xirr.NewtonRaphson$Calculation.setCandidate(NewtonRaphson.java:166)
at org.decampo.xirr.NewtonRaphson$Calculation.solve(NewtonRaphson.java:213)
at org.decampo.xirr.NewtonRaphson.inverse(NewtonRaphson.java:89)
at org.decampo.xirr.NewtonRaphson.findRoot(NewtonRaphson.java:70)
at org.decampo.xirr.NewtonRaphson$Builder.findRoot(NewtonRaphson.java:136)
at org.decampo.xirr.Xirr.xirr(Xirr.java:155)
at org.decampo.xirr.Xirr$Builder.xirr(Xirr.java:262)
at com.app.experiments.XIRR.main(XIRR.java:27)
From excel, correct XIRR is -0.937760641
