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

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


  public void of() {
    final Map<String, List<DoublesPair>> mapDsc = new HashMap<>();
    mapDsc.put(CURVE_NAME_1, SENSI_DATA_1);
    final Map<String, List<ForwardSensitivity>> mapFwd = new HashMap<>();
    mapFwd.put(CURVE_NAME_2, SENSI_FWD_1);
    final MulticurveSensitivity of = MulticurveSensitivity.of(mapDsc, mapFwd);
    assertEquals("CurveSensitivityMarket: of", mapDsc, of.getYieldDiscountingSensitivities());
    assertEquals("CurveSensitivityMarket: of", mapFwd, of.getForwardSensitivities());

    final MulticurveSensitivity ofDsc = MulticurveSensitivity.ofYieldDiscounting(mapDsc);
    assertEquals("CurveSensitivityMarket: of", mapDsc, ofDsc.getYieldDiscountingSensitivities());
    AssertSensivityObjects.assertEquals("CurveSensitivityMarket: of", MulticurveSensitivity.of(mapDsc, new HashMap<String, List<ForwardSensitivity>>()), ofDsc, TOLERANCE);

    final MulticurveSensitivity ofFwd = MulticurveSensitivity.ofForward(mapFwd);
    assertEquals("CurveSensitivityMarket: of", mapFwd, ofFwd.getForwardSensitivities());
    AssertSensivityObjects.assertEquals("CurveSensitivityMarket: of", MulticurveSensitivity.of(new HashMap<String, List<DoublesPair>>(), mapFwd), ofFwd, TOLERANCE);
  }
View Full Code Here


    final Map<String, List<DoublesPair>> sensi11 = new HashMap<>();
    final Map<String, List<DoublesPair>> sensi12 = new HashMap<>();
    final Map<String, List<DoublesPair>> sensi22 = new HashMap<>();
    final Map<String, List<DoublesPair>> sensi33 = new HashMap<>();
    sensi11.put(CURVE_NAME_1, SENSI_DATA_1);
    final MulticurveSensitivity pvSensi_11 = MulticurveSensitivity.ofYieldDiscounting(sensi11);
    sensi22.put(CURVE_NAME_2, SENSI_DATA_2);
    final MulticurveSensitivity pvSensi_22 = MulticurveSensitivity.ofYieldDiscounting(sensi22);
    sensi12.put(CURVE_NAME_1, SENSI_DATA_2);
    final MulticurveSensitivity pvSensi_12 = MulticurveSensitivity.ofYieldDiscounting(sensi12);
    sensi33.put(CURVE_NAME_3, SENSI_DATA_3);
    final MulticurveSensitivity pvSensi_33 = MulticurveSensitivity.ofYieldDiscounting(sensi33);
    // Simple add
    final Map<String, List<DoublesPair>> expectedSensi11add22 = new HashMap<>();
    expectedSensi11add22.put(CURVE_NAME_1, SENSI_DATA_1);
    expectedSensi11add22.put(CURVE_NAME_2, SENSI_DATA_2);
    assertEquals(expectedSensi11add22, pvSensi_11.plus(pvSensi_22).getYieldDiscountingSensitivities());
    assertEquals(MulticurveSensitivity.ofYieldDiscounting(expectedSensi11add22), pvSensi_11.plus(pvSensi_22));
    // Multiply
    final List<DoublesPair> sensiData1Multiply050 = Arrays.asList(new DoublesPair[] {new DoublesPair(1, 5.0), new DoublesPair(2, 10.0), new DoublesPair(3, 15.0), new DoublesPair(4, 20.0)});
    final Map<String, List<DoublesPair>> expectedSensi1Multiply05 = new HashMap<>();
    expectedSensi1Multiply05.put(CURVE_NAME_1, sensiData1Multiply050);
    assertEquals(expectedSensi1Multiply05, pvSensi_11.multipliedBy(0.5).getYieldDiscountingSensitivities());
    assertEquals(MulticurveSensitivity.ofYieldDiscounting(expectedSensi1Multiply05), pvSensi_11.multipliedBy(0.5));
    // Add on the same curve
    final List<DoublesPair> expectedSensiData1add2 = new ArrayList<>();
    expectedSensiData1add2.addAll(SENSI_DATA_1);
    expectedSensiData1add2.addAll(SENSI_DATA_2);
    final Map<String, List<DoublesPair>> expectedSensi11add12 = new HashMap<>();
    expectedSensi11add12.put(CURVE_NAME_1, expectedSensiData1add2);
    assertEquals(expectedSensi11add12, pvSensi_11.plus(pvSensi_12).getYieldDiscountingSensitivities());
    assertEquals(MulticurveSensitivity.ofYieldDiscounting(expectedSensi11add12), pvSensi_11.plus(pvSensi_12));
    // Add multi-curve
    final Map<String, List<DoublesPair>> expectedSensiAddMulti = new HashMap<>();
    expectedSensiAddMulti.put(CURVE_NAME_1, expectedSensiData1add2);
    expectedSensiAddMulti.put(CURVE_NAME_2, SENSI_DATA_2);
    expectedSensiAddMulti.put(CURVE_NAME_3, SENSI_DATA_3);
    assertEquals(expectedSensiAddMulti, pvSensi_11.plus(pvSensi_22.plus(pvSensi_33.plus(pvSensi_12))).getYieldDiscountingSensitivities());
    assertEquals(MulticurveSensitivity.ofYieldDiscounting(expectedSensiAddMulti), pvSensi_11.plus(pvSensi_22.plus(pvSensi_33.plus(pvSensi_12))));
  }
View Full Code Here

  public void plusMultipliedByDscFwd() {
    final Map<String, List<DoublesPair>> sensi11 = new HashMap<>();
    sensi11.put(CURVE_NAME_1, SENSI_DATA_1);
    final Map<String, List<ForwardSensitivity>> sensiFwd11 = new HashMap<>();
    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);

    final Map<String, List<ForwardSensitivity>> sensiFwd32 = new HashMap<>();
    sensiFwd22.put(CURVE_NAME_3, sensiFwd2);
    final MulticurveSensitivity pvSensiDscFwd3 = MulticurveSensitivity.of(sensi32, sensiFwd32);
    AssertSensivityObjects.assertEquals("CurveSensitivityMarket: plusMultipliedBy", pvSensiDscFwd3.plus(pvSensiDscFwd2).cleaned(), pvSensiDscFwd2.plus(pvSensiDscFwd3).cleaned(), TOLERANCE);
  }
View Full Code Here

  @Test
  public void cleaned() {
    final Map<String, List<DoublesPair>> sensi11 = new HashMap<>();
    final Map<String, List<DoublesPair>> sensi12 = new HashMap<>();
    sensi11.put(CURVE_NAME_1, SENSI_DATA_1);
    final MulticurveSensitivity pvSensi_11 = MulticurveSensitivity.ofYieldDiscounting(sensi11);
    sensi12.put(CURVE_NAME_1, SENSI_DATA_2);
    final MulticurveSensitivity pvSensi_12 = MulticurveSensitivity.ofYieldDiscounting(sensi12);
    final List<DoublesPair> expectedSensiDataClean12 = Arrays.asList(new DoublesPair[] {new DoublesPair(1, 50), new DoublesPair(2, 50), new DoublesPair(3, 50), new DoublesPair(4, 50)});
    final Map<String, List<DoublesPair>> expectedSensiClean12 = new HashMap<>();
    expectedSensiClean12.put(CURVE_NAME_1, expectedSensiDataClean12);
    assertEquals(MulticurveSensitivity.ofYieldDiscounting(expectedSensiClean12).getYieldDiscountingSensitivities(), pvSensi_11.plus(pvSensi_12).cleaned().getYieldDiscountingSensitivities());
  }
View Full Code Here

    mapDsc.put(CURVE_NAME_2, SENSI_DATA_1);
    final Map<String, List<ForwardSensitivity>> mapFwd = new HashMap<>();
    mapFwd.put(CURVE_NAME_2, SENSI_FWD_1);
    final Map<String, List<ForwardSensitivity>> mapFwd2 = new HashMap<>();
    mapFwd2.put(CURVE_NAME_3, SENSI_FWD_1);
    final MulticurveSensitivity cs = MulticurveSensitivity.of(mapDsc, mapFwd);
    assertEquals("ParameterSensitivity: equalHash", cs, cs);
    assertEquals("ParameterSensitivity: equalHash", cs.hashCode(), cs.hashCode());
    assertFalse("ParameterSensitivity: equalHash", cs.equals(mapDsc));
    MulticurveSensitivity modified;
    modified = MulticurveSensitivity.of(mapDsc2, mapFwd);
    assertFalse("ParameterSensitivity: equalHash", cs.equals(modified));
    modified = MulticurveSensitivity.of(mapDsc, mapFwd2);
    assertFalse("ParameterSensitivity: equalHash", cs.equals(modified));
  }
View Full Code Here

    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

    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

    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)));
    priceCurveSensitivities.put(name4, Arrays.asList(new DoublesPair(9.8, 8.7), new DoublesPair(5.4, 3.2), new DoublesPair(2.33, 3.44)));
View Full Code Here

    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);
    MultipleCurrencyInflationSensitivity sensitivities = new MultipleCurrencyInflationSensitivity();
View Full Code Here

  private static final double TOLERANCE = 1.0E-10;

  @Test(expectedExceptions = IllegalArgumentException.class)
  public void nullCcy() {
    MultipleCurrencyMulticurveSensitivity.of(null, new MulticurveSensitivity());
  }
View Full Code Here

TOP

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

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.