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

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


      final List<FudgeField> currencies = message.getAllByName(CURRENCY);
      final List<FudgeField> sensitivities = message.getAllByName(SENSITIVITIES);
      if (currencies.size() != sensitivities.size()) {
        throw new OpenGammaRuntimeException("Should have same number of sensitivities as currencies");
      }
      MultipleCurrencyMulticurveSensitivity result = new MultipleCurrencyMulticurveSensitivity();
      for (int i = 0; i < currencies.size(); i++) {
        final Currency currency = Currency.of((String) currencies.get(i).getValue());
        final MulticurveSensitivity sensitivity = deserializer.fieldValueToObject(MulticurveSensitivity.class, sensitivities.get(i));
        result = result.plus(currency, sensitivity);
      }
      return result;
    }
View Full Code Here


    for (int loopswap = 0; loopswap <= nbSwap; loopswap++) {
      final double strike = strikeMin + loopswap * (strikeMax - strikeMin) / nbSwap;
      swapDefinition[loopswap] = SwapFixedIborSpreadDefinition.from(START_DATE, tenor, EUR1YEURIBOR3M, NOTIONAL, strike, SPREAD, IS_PAYER, TARGET);
      final SwapFixedCoupon<Coupon> swap = swapDefinition[loopswap].toDerivative(REFERENCE_DATE);
      pv[loopswap] = swap.accept(PVDC, MULTICURVES).getAmount(EUR);
      final MultipleCurrencyMulticurveSensitivity pvcs = swap.accept(PVCSDC, MULTICURVES);
    }
    endTime = System.currentTimeMillis();
    System.out.println(nbSwap + " swap construction/pv/delta: " + (endTime - startTime) + " ms");
    // Performance note: build/pv/delta: 22-Dec-2012: On Mac Air 1.86 GHz Core 2 Duo: 900 ms for 1250 swaps.

    startTime = System.currentTimeMillis();
    for (int loopswap = 0; loopswap <= nbSwap; loopswap++) {
      final double strike = strikeMin + loopswap * (strikeMax - strikeMin) / nbSwap;
      swapDefinition[loopswap] = SwapFixedIborSpreadDefinition.from(START_DATE, tenor, EUR1YEURIBOR3M, NOTIONAL, strike, SPREAD, IS_PAYER, TARGET);
      final SwapFixedCoupon<Coupon> swap = swapDefinition[loopswap].toDerivative(REFERENCE_DATE);
      pv[loopswap] = swap.accept(PVDC, MULTICURVES).getAmount(EUR);
      final MultipleCurrencyMulticurveSensitivity pvcs = swap.accept(PVCSDC, MULTICURVES);
    }
    endTime = System.currentTimeMillis();
    System.out.println(nbSwap + " swap construction/pv/delta: " + (endTime - startTime) + " ms");
    // Performance note: build/pv/delta: 22-Dec-2012: On Mac Air 1.86 GHz Core 2 Duo: xx ms for 1250 swaps.

View Full Code Here

    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

        assertEquals(-pairs2.get(i).second / pairs1.get(i).second, dPdZ, 1e-15);
      }
    }
    zSpread = 0.0;
    dPdC = CALCULATOR.calculatePriceSensitivityToCurve(PAYMENTS, CONSTANT_CURVES, zSpread);
    final MultipleCurrencyMulticurveSensitivity mcms = PAYMENTS.accept(PVS_CALCULATOR, CONSTANT_CURVES);
    assertEquals(mcms.getCurrencies().size(), 1);
    final Map<String, List<DoublesPair>> pvSensitivity = mcms.getSensitivity(CUR).getYieldDiscountingSensitivities();
    iter1 = dPdC.entrySet().iterator();
    iter2 = pvSensitivity.entrySet().iterator();
    while (iter1.hasNext()) {
      final Entry<String, List<DoublesPair>> e1 = iter1.next();
      final Entry<String, List<DoublesPair>> e2 = iter2.next();
View Full Code Here

  @Test
  public void of() {
    final MulticurveSensitivity cs = MulticurveSensitivity.of(SENSI_11, SENSI_FWD_11);
    final Currency ccy1 = Currency.AUD;
    final MultipleCurrencyMulticurveSensitivity mcs = MultipleCurrencyMulticurveSensitivity.of(ccy1, cs);
    assertEquals("MultipleCurrencyCurveSensitivityMarket: of", cs, mcs.getSensitivity(ccy1));
    MultipleCurrencyMulticurveSensitivity constructor = new MultipleCurrencyMulticurveSensitivity();
    constructor = constructor.plus(ccy1, cs);
    AssertSensivityObjects.assertEquals("MultipleCurrencyCurveSensitivityMarket: of", mcs.cleaned(), constructor.cleaned(), TOLERANCE);
    AssertSensivityObjects.assertEquals("MultipleCurrencyCurveSensitivityMarket: getSensitivity", new MulticurveSensitivity(), mcs.getSensitivity(Currency.CAD), TOLERANCE);
  }
View Full Code Here

  @Test
  public void plusMultipliedBy() {
    final Currency ccy1 = Currency.AUD;
    final Currency ccy2 = Currency.CAD;
    final MulticurveSensitivity cs = MulticurveSensitivity.of(SENSI_11, SENSI_FWD_11);
    MultipleCurrencyMulticurveSensitivity mcs = MultipleCurrencyMulticurveSensitivity.of(ccy1, cs);
    final MulticurveSensitivity cs2 = MulticurveSensitivity.ofYieldDiscounting(SENSI_22);
    final MultipleCurrencyMulticurveSensitivity mcs2 = MultipleCurrencyMulticurveSensitivity.of(ccy1, cs2);
    final MultipleCurrencyMulticurveSensitivity mcs3 = mcs.plus(mcs2);
    final Map<String, List<DoublesPair>> sum = InterestRateCurveSensitivityUtils.addSensitivity(SENSI_11, SENSI_22);
    final MultipleCurrencyMulticurveSensitivity mcs3Expected = MultipleCurrencyMulticurveSensitivity.of(ccy1, MulticurveSensitivity.of(sum, SENSI_FWD_11));
    AssertSensivityObjects.assertEquals("", mcs3Expected.cleaned(), mcs3.cleaned(), TOLERANCE);
    mcs = mcs.plus(ccy2, cs);
    assertEquals("MultipleCurrencyCurveSensitivityMarket: plusMultipliedBy", cs, mcs.getSensitivity(ccy1));
    assertEquals("MultipleCurrencyCurveSensitivityMarket: plusMultipliedBy", cs, mcs.getSensitivity(ccy2));
    AssertSensivityObjects.assertEquals("", mcs.plus(mcs).cleaned(), mcs.multipliedBy(2.0).cleaned(), TOLERANCE);
  }
View Full Code Here

  public void cleaned() {
    final Currency ccy1 = Currency.AUD;
    final Currency ccy2 = Currency.CAD;
    final MulticurveSensitivity cs1 = MulticurveSensitivity.of(SENSI_11, SENSI_FWD_11);
    final MulticurveSensitivity cs2 = MulticurveSensitivity.of(SENSI_22, SENSI_FWD_11);
    MultipleCurrencyMulticurveSensitivity mcs1 = MultipleCurrencyMulticurveSensitivity.of(ccy1, cs1);
    mcs1 = mcs1.plus(ccy2, cs2);
    MultipleCurrencyMulticurveSensitivity mcs2 = MultipleCurrencyMulticurveSensitivity.of(ccy2, cs2);
    mcs2 = mcs2.plus(ccy1, cs1);
    AssertSensivityObjects.assertEquals("MultipleCurrencyCurveSensitivityMarket: cleaned", mcs1.cleaned(), mcs2.cleaned(), TOLERANCE);
  }
View Full Code Here

  public void converted() {
    final Currency ccy1 = Currency.EUR;
    final Currency ccy2 = Currency.USD;
    final FXMatrix fxMatrix = new FXMatrix(ccy1, ccy2, 1.25);
    final MulticurveSensitivity cs = MulticurveSensitivity.of(SENSI_11, SENSI_FWD_11);
    final MultipleCurrencyMulticurveSensitivity mcs = MultipleCurrencyMulticurveSensitivity.of(ccy1, cs);
    final MultipleCurrencyMulticurveSensitivity mcsConverted = mcs.converted(ccy2, fxMatrix);
    final MultipleCurrencyMulticurveSensitivity mcsExpected = MultipleCurrencyMulticurveSensitivity.of(ccy2, cs.multipliedBy(fxMatrix.getFxRate(ccy1, ccy2)));
    AssertSensivityObjects.assertEquals("MultipleCurrencyCurveSensitivityMarket: converted", mcsExpected.cleaned(), mcsConverted.cleaned(), TOLERANCE);
  }
View Full Code Here

  @Test
  public void equalHash() {
    final Currency ccy1 = Currency.EUR;
    final Currency ccy2 = Currency.USD;
    final MulticurveSensitivity cs = MulticurveSensitivity.of(SENSI_11, SENSI_FWD_11);
    final MultipleCurrencyMulticurveSensitivity mcs = MultipleCurrencyMulticurveSensitivity.of(ccy1, cs);
    assertEquals("MultipleCurrencyCurveSensitivityMarket: equalHash", mcs, mcs);
    assertEquals("MultipleCurrencyCurveSensitivityMarket: equalHash", mcs.hashCode(), mcs.hashCode());
    assertFalse("MultipleCurrencyCurveSensitivityMarket: equalHash", mcs.equals(null));
    assertFalse("MultipleCurrencyCurveSensitivityMarket: equalHash", mcs.equals(SENSI_11));
    final MultipleCurrencyMulticurveSensitivity other = MultipleCurrencyMulticurveSensitivity.of(ccy1, cs);
    assertEquals("MultipleCurrencyCurveSensitivityMarket: equalHash", mcs, other);
    MultipleCurrencyMulticurveSensitivity modified;
    modified = MultipleCurrencyMulticurveSensitivity.of(ccy2, cs);
    assertFalse("MultipleCurrencyCurveSensitivityMarket: equalHash", mcs.equals(modified));
  }
View Full Code Here

    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);
    MultipleCurrencyMulticurveSensitivity result = new MultipleCurrencyMulticurveSensitivity();
    result = result.plus(deposit.getCurrency(), MulticurveSensitivity.of(mapDsc, mapFwd));
    return result;
  }
View Full Code Here

TOP

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

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.