Package com.opengamma.analytics.financial.provider.sensitivity.multicurve

Examples of com.opengamma.analytics.financial.provider.sensitivity.multicurve.ForwardSensitivity


    sensiFwd11.put(CURVE_NAME_2, SENSI_FWD_1);
    final MulticurveSensitivity pvSensiDscFwd = MulticurveSensitivity.of(sensi11, sensiFwd11);
    AssertSensivityObjects.assertEquals("CurveSensitivityMarket: plusMultipliedBy", pvSensiDscFwd.plus(pvSensiDscFwd).cleaned(), pvSensiDscFwd.multipliedBy(2.0).cleaned(), TOLERANCE);

    final List<ForwardSensitivity> sensiFwd2 = new ArrayList<>();
    sensiFwd2.add(new ForwardSensitivity(2.5, 2.75, 0.26, 11));
    final Map<String, List<DoublesPair>> sensi32 = new HashMap<>();
    sensi11.put(CURVE_NAME_3, SENSI_DATA_2);
    final Map<String, List<ForwardSensitivity>> sensiFwd22 = new HashMap<>();
    sensiFwd22.put(CURVE_NAME_2, sensiFwd2);
    final MulticurveSensitivity pvSensiDscFwd2 = MulticurveSensitivity.of(sensi32, sensiFwd22);
    final List<ForwardSensitivity> sensiFwd3 = new ArrayList<>();
    sensiFwd3.addAll(SENSI_FWD_1);
    sensiFwd3.add(new ForwardSensitivity(2.5, 2.75, 0.26, 11));
    final Map<String, List<ForwardSensitivity>> sensiFwd23 = new HashMap<>();
    sensiFwd23.put(CURVE_NAME_2, sensiFwd3);
    AssertSensivityObjects.assertEquals("CurveSensitivityMarket: plusMultipliedBy", MulticurveSensitivity.of(InterestRateCurveSensitivityUtils.addSensitivity(sensi11, sensi32), sensiFwd23).cleaned(),
        pvSensiDscFwd.plus(pvSensiDscFwd2).cleaned(), TOLERANCE);
View Full Code Here


@Test(groups = TestGroup.UNIT)
public class CurveResultBuildersTest extends AnalyticsTestBase {

  @Test
  public void testForwardSensitivity() {
    final ForwardSensitivity forwardSensitivity = new ForwardSensitivity(12., 13., 17., 25.);
    assertEquals(forwardSensitivity, cycleObject(ForwardSensitivity.class, forwardSensitivity));
  }
View Full Code Here

    final String name2 = "YC2";
    final Map<String, List<DoublesPair>> yieldCurveSensitivities = new HashMap<>();
    yieldCurveSensitivities.put(name1, Arrays.asList(new DoublesPair(1., 2.), new DoublesPair(3.5, 6.8)));
    yieldCurveSensitivities.put(name2, Arrays.asList(new DoublesPair(11., 12.), new DoublesPair(13.5, 16.8), new DoublesPair(45., 12.)));
    final Map<String, List<ForwardSensitivity>> forwardCurveSensitivities = new HashMap<>();
    forwardCurveSensitivities.put(name1, Arrays.asList(new ForwardSensitivity(1, 5, 0.25, 10), new ForwardSensitivity(2, 3, 0.215, 20), new ForwardSensitivity(3, 9, 0.225, 30)));
    forwardCurveSensitivities.put(name2, Arrays.asList(new ForwardSensitivity(0.1, 4, 0.5, 10)));
    final MulticurveSensitivity sensitivities = MulticurveSensitivity.of(yieldCurveSensitivities, forwardCurveSensitivities);
    assertEquals(sensitivities, cycleObject(MulticurveSensitivity.class, sensitivities));
  }
View Full Code Here

    final String name2 = "YC2";
    final Map<String, List<DoublesPair>> yieldCurveSensitivities1 = new HashMap<>();
    yieldCurveSensitivities1.put(name1, Arrays.asList(new DoublesPair(1., 2.), new DoublesPair(3.5, 6.8)));
    yieldCurveSensitivities1.put(name2, Arrays.asList(new DoublesPair(11., 12.), new DoublesPair(13.5, 16.8), new DoublesPair(45., 12.)));
    final Map<String, List<ForwardSensitivity>> forwardCurveSensitivities1 = new HashMap<>();
    forwardCurveSensitivities1.put(name1, Arrays.asList(new ForwardSensitivity(1, 5, 0.25, 10), new ForwardSensitivity(2, 3, 0.215, 20), new ForwardSensitivity(3, 9, 0.225, 30)));
    forwardCurveSensitivities1.put(name2, Arrays.asList(new ForwardSensitivity(0.1, 4, 0.5, 10)));
    final MulticurveSensitivity sensitivities1 = MulticurveSensitivity.of(yieldCurveSensitivities1, forwardCurveSensitivities1);
    final String name3 = "YC3";
    final String name4 = "YC4";
    final Map<String, List<DoublesPair>> yieldCurveSensitivities2 = new HashMap<>();
    yieldCurveSensitivities2.put(name3, Arrays.asList(new DoublesPair(10., 20.)));
    yieldCurveSensitivities2.put(name4, Arrays.asList(new DoublesPair(110., 120.), new DoublesPair(13.51, 16.81), new DoublesPair(45.3, 12.3)));
    final Map<String, List<ForwardSensitivity>> forwardCurveSensitivities2 = new HashMap<>();
    forwardCurveSensitivities2.put(name3, Arrays.asList(new ForwardSensitivity(18, 58, 0.258, 108), new ForwardSensitivity(32, 92, 0.2252, 302)));
    forwardCurveSensitivities2.put(name4, Arrays.asList(new ForwardSensitivity(0.18, 48, 0.58, 18)));
    final MulticurveSensitivity sensitivities2 = MulticurveSensitivity.of(yieldCurveSensitivities2, forwardCurveSensitivities2);
    MultipleCurrencyMulticurveSensitivity sensitivities = new MultipleCurrencyMulticurveSensitivity();
    sensitivities = sensitivities.plus(Currency.AUD, sensitivities1);
    sensitivities = sensitivities.plus(Currency.CAD, sensitivities2);
    assertEquals(sensitivities, cycleObject(MultipleCurrencyMulticurveSensitivity.class, sensitivities));
View Full Code Here

    final String name2 = "YC2";
    final Map<String, List<DoublesPair>> yieldCurveSensitivities = new HashMap<>();
    yieldCurveSensitivities.put(name1, Arrays.asList(new DoublesPair(1., 2.), new DoublesPair(3.5, 6.8)));
    yieldCurveSensitivities.put(name2, Arrays.asList(new DoublesPair(11., 12.), new DoublesPair(13.5, 16.8), new DoublesPair(45., 12.)));
    final Map<String, List<ForwardSensitivity>> forwardCurveSensitivities = new HashMap<>();
    forwardCurveSensitivities.put(name1, Arrays.asList(new ForwardSensitivity(1, 5, 0.25, 10), new ForwardSensitivity(2, 3, 0.215, 20), new ForwardSensitivity(3, 9, 0.225, 30)));
    forwardCurveSensitivities.put(name2, Arrays.asList(new ForwardSensitivity(0.1, 4, 0.5, 10)));
    final MulticurveSensitivity sensitivities = MulticurveSensitivity.of(yieldCurveSensitivities, forwardCurveSensitivities);
    final String name3 = "PC1";
    final String name4 = "PC2";
    final Map<String, List<DoublesPair>> priceCurveSensitivities = new HashMap<>();
    priceCurveSensitivities.put(name3, Arrays.asList(new DoublesPair(1.2, 2.3), new DoublesPair(3.4, 4.5)));
View Full Code Here

    final String name2 = "YC2";
    final Map<String, List<DoublesPair>> yieldCurveSensitivities1 = new HashMap<>();
    yieldCurveSensitivities1.put(name1, Arrays.asList(new DoublesPair(1., 2.), new DoublesPair(3.5, 6.8)));
    yieldCurveSensitivities1.put(name2, Arrays.asList(new DoublesPair(11., 12.), new DoublesPair(13.5, 16.8), new DoublesPair(45., 12.)));
    final Map<String, List<ForwardSensitivity>> forwardCurveSensitivities1 = new HashMap<>();
    forwardCurveSensitivities1.put(name1, Arrays.asList(new ForwardSensitivity(1, 5, 0.25, 10), new ForwardSensitivity(2, 3, 0.215, 20), new ForwardSensitivity(3, 9, 0.225, 30)));
    forwardCurveSensitivities1.put(name2, Arrays.asList(new ForwardSensitivity(0.1, 4, 0.5, 10)));
    final MulticurveSensitivity sensitivities1 = MulticurveSensitivity.of(yieldCurveSensitivities1, forwardCurveSensitivities1);
    final Map<String, List<DoublesPair>> priceCurveSensitivities1 = new HashMap<>();
    priceCurveSensitivities1.put("PC1", Arrays.asList(new DoublesPair(1.2, 2.3), new DoublesPair(3.4, 4.5)));
    priceCurveSensitivities1.put("PC2", Arrays.asList(new DoublesPair(9.8, 8.7), new DoublesPair(5.4, 3.2), new DoublesPair(2.33, 3.44)));
    final InflationSensitivity is1 = InflationSensitivity.of(sensitivities1, priceCurveSensitivities1);
    final String name3 = "YC3";
    final String name4 = "YC4";
    final Map<String, List<DoublesPair>> yieldCurveSensitivities2 = new HashMap<>();
    yieldCurveSensitivities2.put(name3, Arrays.asList(new DoublesPair(10., 20.)));
    yieldCurveSensitivities2.put(name4, Arrays.asList(new DoublesPair(110., 120.), new DoublesPair(13.51, 16.81), new DoublesPair(45.3, 12.3)));
    final Map<String, List<ForwardSensitivity>> forwardCurveSensitivities2 = new HashMap<>();
    forwardCurveSensitivities2.put(name3, Arrays.asList(new ForwardSensitivity(18, 58, 0.258, 108), new ForwardSensitivity(32, 92, 0.2252, 302)));
    forwardCurveSensitivities2.put(name4, Arrays.asList(new ForwardSensitivity(0.18, 48, 0.58, 18)));
    final MulticurveSensitivity sensitivities2 = MulticurveSensitivity.of(yieldCurveSensitivities2, forwardCurveSensitivities2);
    final Map<String, List<DoublesPair>> priceCurveSensitivities2 = new HashMap<>();
    priceCurveSensitivities1.put("PC3", Arrays.asList(new DoublesPair(1.21, 2.31), new DoublesPair(3.41, 4.51)));
    priceCurveSensitivities1.put("PC4", Arrays.asList(new DoublesPair(9.81, 8.71), new DoublesPair(5.41, 3.21), new DoublesPair(2.331, 3.441)));
    final InflationSensitivity is2 = InflationSensitivity.of(sensitivities2, priceCurveSensitivities2);
View Full Code Here

  private static final double ACCRUAL_FACTOR = 0.251;
  private static final ForwardSensitivity SENSITIVITY = new ForwardSensitivity(START, END, ACCRUAL_FACTOR, VALUE);

  @Test(expectedExceptions = IllegalArgumentException.class)
  public void testEndBeforeStart() {
    new ForwardSensitivity(END, START, ACCRUAL_FACTOR, VALUE);
  }
View Full Code Here

    assertEquals(VALUE, SENSITIVITY.getValue());
  }

  @Test
  public void testObject() {
    ForwardSensitivity other = new ForwardSensitivity(START, END, ACCRUAL_FACTOR, VALUE);
    assertEquals(SENSITIVITY, other);
    assertEquals(SENSITIVITY.hashCode(), other.hashCode());
    other = new ForwardSensitivity(START * 0.5, END, ACCRUAL_FACTOR, VALUE);
    assertFalse(SENSITIVITY.equals(other));
    other = new ForwardSensitivity(START, END * 1.5, ACCRUAL_FACTOR, VALUE);
    assertFalse(SENSITIVITY.equals(other));
    other = new ForwardSensitivity(START, END, ACCRUAL_FACTOR * 1.2, VALUE);
    assertFalse(SENSITIVITY.equals(other));
    other = new ForwardSensitivity(START, END, ACCRUAL_FACTOR, VALUE + 1);
    assertFalse(SENSITIVITY.equals(other));
  }
View Full Code Here

    // Backward sweep
    final double forwardBar = deposit.getAccrualFactor() * dfEnd;
    final double dfEndBar = deposit.getAccrualFactor() * (deposit.getRate() - forward);
    final Map<String, List<ForwardSensitivity>> mapFwd = new HashMap<>();
    final List<ForwardSensitivity> listForward = new ArrayList<>();
    listForward.add(new ForwardSensitivity(deposit.getStartTime(), deposit.getEndTime(), deposit.getAccrualFactor(), forwardBar));
    mapFwd.put(multicurves.getName(deposit.getIndex()), listForward);
    final Map<String, List<DoublesPair>> mapDsc = new HashMap<>();
    final List<DoublesPair> listDiscounting = new ArrayList<>();
    listDiscounting.add(new DoublesPair(deposit.getEndTime(), -deposit.getEndTime() * dfEnd * dfEndBar));
    mapDsc.put(multicurves.getName(deposit.getCurrency()), listDiscounting);
View Full Code Here

  public MulticurveSensitivity parSpreadCurveSensitivity(final DepositIbor deposit, final MulticurveProviderInterface multicurve) {
    ArgumentChecker.notNull(deposit, "Deposit");
    ArgumentChecker.notNull(multicurve, "Multicurves");
    final Map<String, List<ForwardSensitivity>> mapFwd = new HashMap<>();
    final List<ForwardSensitivity> listForward = new ArrayList<>();
    listForward.add(new ForwardSensitivity(deposit.getStartTime(), deposit.getEndTime(), deposit.getAccrualFactor(), 1.0));
    mapFwd.put(multicurve.getName(deposit.getIndex()), listForward);
    return MulticurveSensitivity.ofForward(mapFwd);
  }
View Full Code Here

TOP

Related Classes of com.opengamma.analytics.financial.provider.sensitivity.multicurve.ForwardSensitivity

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.