public virtual void negativeRates() { double shift = 0.05; Curve surface = ConstantCurve.of("shfit", shift); SabrParameters @params = SabrParameters.of(ALPHA_CURVE, BETA_CURVE, RHO_CURVE, NU_CURVE, surface, FORMULA); double expiry = 2.0; assertEquals(@params.alpha(expiry), ALPHA_CURVE.yValue(expiry)); assertEquals(@params.beta(expiry), BETA_CURVE.yValue(expiry)); assertEquals(@params.rho(expiry), RHO_CURVE.yValue(expiry)); assertEquals(@params.nu(expiry), NU_CURVE.yValue(expiry)); double strike = -0.02; double forward = 0.015; double alpha = ALPHA_CURVE.yValue(expiry); double beta = BETA_CURVE.yValue(expiry); double rho = RHO_CURVE.yValue(expiry); double nu = NU_CURVE.yValue(expiry); assertEquals(@params.volatility(expiry, strike, forward), FORMULA.volatility(forward + shift, strike + shift, expiry, alpha, beta, rho, nu)); double[] adjCmp = @params.volatilityAdjoint(expiry, strike, forward).Derivatives.toArray(); double[] adjExp = FORMULA.volatilityAdjoint(forward + shift, strike + shift, expiry, alpha, beta, rho, nu).Derivatives.toArray(); for (int i = 0; i < 4; ++i) { assertEquals(adjCmp[i], adjExp[i]); } }
public virtual void perturbation() { SabrParameters test = PARAMETERS.withPerturbation((i, v, m) => (2d + i) * v); SabrParameters expected = PARAMETERS; for (int i = 0; i < PARAMETERS.ParameterCount; ++i) { expected = expected.withParameter(i, (2d + i) * expected.getParameter(i)); } assertEquals(test, expected); }
//----------------------------------------------------------------------- public override bool Equals(object obj) { if (obj == this) { return(true); } if (obj != null && obj.GetType() == this.GetType()) { SabrParameters other = (SabrParameters)obj; return(JodaBeanUtils.equal(alphaCurve, other.alphaCurve) && JodaBeanUtils.equal(betaCurve, other.betaCurve) && JodaBeanUtils.equal(rhoCurve, other.rhoCurve) && JodaBeanUtils.equal(nuCurve, other.nuCurve) && JodaBeanUtils.equal(shiftCurve, other.shiftCurve) && JodaBeanUtils.equal(sabrVolatilityFormula, other.sabrVolatilityFormula)); } return(false); }