public void regression_withZSpread_periodic() {
    double price =
        FUTURE_PRICER.priceWithZSpread(
            FUTURE_PRODUCT, PROVIDER, Z_SPREAD, PERIODIC, PERIOD_PER_YEAR);
    assertEquals(price, 1.1720190529653407, TOL);
    PointSensitivities point =
        FUTURE_PRICER.priceSensitivityWithZSpread(
            FUTURE_PRODUCT, PROVIDER, Z_SPREAD, PERIODIC, PERIOD_PER_YEAR);
    CurrencyParameterSensitivities test = PROVIDER.parameterSensitivity(point);

    DoubleArray expectedIssuer =
        DoubleArray.of(
            -3.9201229100932256E-4,
            -0.0041367134351306374,
            -0.014173323438217467,
            -0.9886444827927878,
            -4.07533109609094,
            0);
    DoubleArray actualIssuer =
        test.getSensitivity(METADATA_ISSUER.getCurveName(), USD).getSensitivity();
    assertTrue(actualIssuer.equalWithTolerance(expectedIssuer, TOL));

    DoubleArray expectedRepo =
        DoubleArray.of(0.1428352116441475, 0.20242871054203687, 0.0, 0.0, 0.0, 0.0);
    DoubleArray actualRepo =
        test.getSensitivity(METADATA_REPO.getCurveName(), USD).getSensitivity();
    assertTrue(actualRepo.equalWithTolerance(expectedRepo, TOL));
  }
 public void test_priceWithZSpread_continuous() {
   double computed =
       FUTURE_PRICER.priceWithZSpread(FUTURE_PRODUCT, PROVIDER, Z_SPREAD, CONTINUOUS, 0);
   double dirtyPrice =
       BOND_PRICER.dirtyPriceFromCurvesWithZSpread(
           BOND, PROVIDER, Z_SPREAD, CONTINUOUS, 0, FUTURE_PRODUCT.getLastDeliveryDate());
   double expected =
       BOND_PRICER.cleanPriceFromDirtyPrice(BOND, FUTURE_PRODUCT.getLastDeliveryDate(), dirtyPrice)
           / CONVERSION_FACTOR[0];
   assertEquals(computed, expected, TOL);
 }
 public void test_priceSensitivityWithZSpread_continuous() {
   PointSensitivities point =
       FUTURE_PRICER.priceSensitivityWithZSpread(
           FUTURE_PRODUCT, PROVIDER, Z_SPREAD, CONTINUOUS, 0);
   CurrencyParameterSensitivities computed = PROVIDER.parameterSensitivity(point);
   CurrencyParameterSensitivities expected =
       FD_CAL.sensitivity(
           PROVIDER,
           (p) ->
               CurrencyAmount.of(
                   USD,
                   FUTURE_PRICER.priceWithZSpread(FUTURE_PRODUCT, (p), Z_SPREAD, CONTINUOUS, 0)));
   assertTrue(computed.equalWithTolerance(expected, EPS * 10.0));
 }
 public void test_priceWithZSpread_periodic() {
   double computed =
       FUTURE_PRICER.priceWithZSpread(
           FUTURE_PRODUCT, PROVIDER, Z_SPREAD, PERIODIC, PERIOD_PER_YEAR);
   double dirtyPrice =
       BOND_PRICER.dirtyPriceFromCurvesWithZSpread(
           BOND,
           PROVIDER,
           Z_SPREAD,
           PERIODIC,
           PERIOD_PER_YEAR,
           FUTURE_PRODUCT.getLastDeliveryDate());
   double expected =
       BOND_PRICER.cleanPriceFromDirtyPrice(BOND, FUTURE_PRODUCT.getLastDeliveryDate(), dirtyPrice)
           / CONVERSION_FACTOR[0];
   assertEquals(computed, expected, TOL);
 }
 public void regression_withZSpread_continuous() {
   double price =
       FUTURE_PRICER.priceWithZSpread(FUTURE_PRODUCT, PROVIDER, Z_SPREAD, CONTINUOUS, 0);
   assertEquals(price, 1.1718691843665354, TOL);
   // curve parameter sensitivity is not supported for continuous z-spread in 2.x.
 }