Examples of ForexSwap


Examples of com.opengamma.analytics.financial.forex.derivative.ForexSwap

    if (date.isAfter(_nearLeg.getExchangeDate())) { // Implementation note: only the far leg left.
      return _farLeg.toDerivative(date, yieldCurveNames);
    }
    final Forex nearLeg = _nearLeg.toDerivative(date, yieldCurveNames);
    final Forex farLeg = _farLeg.toDerivative(date, yieldCurveNames);
    return new ForexSwap(nearLeg, farLeg);
  }
View Full Code Here

Examples of com.opengamma.analytics.financial.forex.derivative.ForexSwap

    if (date.isAfter(_nearLeg.getExchangeDate())) { // Implementation note: only the far leg left.
      return _farLeg.toDerivative(date);
    }
    final Forex nearLeg = _nearLeg.toDerivative(date);
    final Forex farLeg = _farLeg.toDerivative(date);
    return new ForexSwap(nearLeg, farLeg);
  }
View Full Code Here

Examples of com.opengamma.analytics.financial.forex.derivative.ForexSwap

   * Tests the parSpread method.
   */
  public void parSpread() {
    final double parSpread = METHOD_FX_SWAP.parSpread((ForexSwap) FX_SWAP, CURVES_FX);
    final ForexSwapDefinition fxSwap0Definition = new ForexSwapDefinition(CUR_1, CUR_2, NEAR_DATE, FAR_DATE, NOMINAL_1, FX_RATE, FORWARD_POINTS + parSpread);
    final ForexSwap fxSwap0 = (ForexSwap) fxSwap0Definition.toDerivative(REFERENCE_DATE, CURVES_NAME);
    final MultipleCurrencyAmount pv0 = METHOD_FX_SWAP.presentValue(fxSwap0, CURVES);
    assertEquals("Forex swap: par spread", 0, FX_MATRIX.convert(pv0, CUR_1).getAmount(), TOLERANCE_PV);
  }
View Full Code Here

Examples of com.opengamma.analytics.financial.forex.derivative.ForexSwap

  @Test
  /**
   * Tests parSpread curve sensitivity.
   */
  public void parSpreadCurveSensitivity() {
    final ForexSwap fxSwap = (ForexSwap) FX_SWAP;
    InterestRateCurveSensitivity pscsMethod = METHOD_FX_SWAP.parSpreadCurveSensitivity(fxSwap, CURVES_FX);
    pscsMethod = pscsMethod.cleaned(0.0, 1.0E-8);
    final double ps = METHOD_FX_SWAP.parSpread(fxSwap, CURVES_FX);
    final double deltaShift = 0.000001;
    final int nbNode = 2;
    final double[] result = new double[nbNode];
    final double[] nodeTimesExtended = new double[nbNode + 1];
    nodeTimesExtended[1] = fxSwap.getNearLeg().getPaymentTime();
    nodeTimesExtended[2] = fxSwap.getFarLeg().getPaymentTime();
    final double[] yields = new double[nbNode + 1];
    YieldAndDiscountCurve curveToBump;
    YieldAndDiscountCurve curveNode;
    // EUR Dsc
    final List<DoublesPair> sensi1 = pscsMethod.getSensitivities().get(CURVES_NAME[0]);
    curveToBump = CURVES.getCurve(CURVES_NAME[0]);
    yields[0] = curveToBump.getInterestRate(0.0);
    yields[1] = curveToBump.getInterestRate(nodeTimesExtended[1]);
    yields[2] = curveToBump.getInterestRate(nodeTimesExtended[2]);
    curveNode = YieldCurve.from(InterpolatedDoublesCurve.fromSorted(nodeTimesExtended, yields, new LinearInterpolator1D()));
    for (int loopnode = 0; loopnode < nbNode; loopnode++) {
      final YieldAndDiscountCurve curveBumped = curveNode.withSingleShift(nodeTimesExtended[loopnode + 1], deltaShift);
      CURVES_FX.replaceCurve(CURVES_NAME[0], curveBumped);
      final double psBumped = METHOD_FX_SWAP.parSpread(fxSwap, CURVES_FX);
      result[loopnode] = (psBumped - ps) / deltaShift;
      final DoublesPair pairPv = sensi1.get(loopnode);
      assertEquals("Sensitivity par spread to curve: Node " + loopnode, nodeTimesExtended[loopnode + 1], pairPv.getFirst(), TOLERANCE_TIME);
      assertEquals("Sensitivity par spread to curve: Node", pairPv.second, result[loopnode], TOLERANCE_SPREAD_DELTA);
    }
    CURVES_FX.replaceCurve(CURVES_NAME[0], curveToBump);
    // USD Dsc
    final List<DoublesPair> sensi2 = pscsMethod.getSensitivities().get(CURVES_NAME[0]);
    curveToBump = CURVES.getCurve(CURVES_NAME[1]);
    yields[0] = curveToBump.getInterestRate(0.0);
    yields[1] = curveToBump.getInterestRate(nodeTimesExtended[1]);
    yields[2] = curveToBump.getInterestRate(nodeTimesExtended[2]);
    curveNode = YieldCurve.from(InterpolatedDoublesCurve.fromSorted(nodeTimesExtended, yields, new LinearInterpolator1D()));
    for (int loopnode = 0; loopnode < nbNode; loopnode++) {
      final YieldAndDiscountCurve curveBumped = curveNode.withSingleShift(nodeTimesExtended[loopnode + 1], deltaShift);
      CURVES_FX.replaceCurve(CURVES_NAME[1], curveBumped);
      final double psBumped = METHOD_FX_SWAP.parSpread(fxSwap, CURVES_FX);
      result[loopnode] = (psBumped - ps) / deltaShift;
      final DoublesPair pairPv = sensi2.get(loopnode);
      assertEquals("Sensitivity par spread to curve: Node " + loopnode, nodeTimesExtended[loopnode + 1], pairPv.getFirst(), TOLERANCE_TIME);
    }
    CURVES_FX.replaceCurve(CURVES_NAME[1], curveToBump);
    InterestRateCurveSensitivity prcsCalculator = fxSwap.accept(PSCSC, CURVES_FX);
    prcsCalculator = prcsCalculator.cleaned(0.0, 1.0E-4);
    AssertSensivityObjects.assertEquals("Forex swap: par rate curve sensitivity", pscsMethod, prcsCalculator, TOLERANCE_SPREAD_DELTA);
  }
View Full Code Here

Examples of com.opengamma.analytics.financial.forex.derivative.ForexSwap

    final String eur = "Discounting EUR";
    final String usd = "Discounting USD";
    final String[] names = new String[] {eur, usd};
    final Forex fxNear = FX_NEAR_DEFINITION.toDerivative(REFERENCE_DATE, names);
    final Forex fxFar = FX_FAR_DEFINITION.toDerivative(REFERENCE_DATE, names);
    final ForexSwap fxSwapExpected = new ForexSwap(fxNear, fxFar);
    final InstrumentDerivative fxSwap = FX_SWAP_DEFINITION_FIN.toDerivative(REFERENCE_DATE, names);
    assertEquals(fxSwapExpected, fxSwap);
  }
View Full Code Here

Examples of com.opengamma.analytics.financial.forex.derivative.ForexSwap

   * Tests the conversion to derivative.
   */
  public void toDerivative() {
    final Forex fxNear = FX_NEAR_DEFINITION.toDerivative(REFERENCE_DATE);
    final Forex fxFar = FX_FAR_DEFINITION.toDerivative(REFERENCE_DATE);
    final ForexSwap fxSwapExpected = new ForexSwap(fxNear, fxFar);
    final InstrumentDerivative fxSwap = FX_SWAP_DEFINITION_FIN.toDerivative(REFERENCE_DATE);
    assertEquals(fxSwapExpected, fxSwap);
  }
View Full Code Here

Examples of com.opengamma.analytics.financial.forex.derivative.ForexSwap

   */
  public void parSpread() {
    final double parSpread = METHOD_FX_SWAP.parSpread(FX_SWAP, MULTICURVES);
    final ForexSwapDefinition fxSwap0Definition = new ForexSwapDefinition(CUR_1, CUR_2, NEAR_DATE, FAR_DATE, NOMINAL_1, MULTICURVES.getFxRate(CUR_1, CUR_2), FORWARD_POINTS
        + parSpread);
    final ForexSwap fxSwap0 = (ForexSwap) fxSwap0Definition.toDerivative(REFERENCE_DATE);
    final MultipleCurrencyAmount pv0 = METHOD_FX_SWAP.presentValue(fxSwap0, MULTICURVES);
    assertEquals("Forex swap: par spread", 0, MULTICURVES.getFxRates().convert(pv0, CUR_1).getAmount(), TOLERANCE_PV);
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.