Docs / nablatensor-quant / com.nablatensor.quant
final class
Calibrator
Least-squares calibration over a recorded objective.
You supply a recording that reads the parameters by name (rec.input("alpha", ...)), builds the sum of squared residuals against the market, and calls rec.output(sumSq) once. The objective is compiled to one kernel; every iteration is a setInput + one adjoint sweep, so the gradient is exact and costs one extra sweep regardless of the parameter count. A box-projected L-BFGS drives it.
Calibrator.Result r = Calibrator.of(rec -> {
SDouble alpha = rec.input("alpha", 0.2);
SDouble rho = rec.input("rho", 0.0);
SDouble nu = rec.input("nu", 0.3);
SDouble beta = rec.constant(0.5);
SDouble sse = rec.constant(0.0);
for (Quote q : quotes) {
SDouble model = SabrHagan.blackVol(rec, alpha, beta, rho, nu, F, q.strike(), T);
SDouble d = model.sub(q.vol());
sse = sse.add(d.mul(d));
}
rec.output(sse);
})
.parameter("alpha", 0.2, 1e-4, 2.0)
.parameter("rho", 0.0, -0.999, 0.999)
.parameter("nu", 0.3, 1e-4, 5.0)
.solve();Methods
Minimise a recorded scalar objective (usually a sum of squared residuals) with L-BFGS.
Fit a recorded residual vector with Levenberg-Marquardt. The body records the parameters by name and returns the named residuals model_i - market_i; the Jacobian each iteration comes from one MultiOutput evaluation (1 + N adjoint sweeps).
Scenario count for a Monte-Carlo objective; the default 1 is a deterministic one.