Package com.opengamma.analytics.financial.forex.derivative

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


    final String discountingEUR = "Discounting EUR";
    final String discountingUSD = "Discounting USD";
    final String[] curves_name = new String[] {discountingEUR, discountingUSD};
    final ZonedDateTime referenceDate = DateUtils.getUTCDate(2011, 5, 20);
    final InstrumentDerivative optionConverted = FX_OPTION_DEFINITION.toDerivative(referenceDate, curves_name);
    final Forex fx = FX_DEFINITION.toDerivative(referenceDate, curves_name);
    final DayCount actAct = DayCountFactory.INSTANCE.getDayCount("Actual/Actual ISDA");
    final double expirationTime = actAct.getDayCountFraction(referenceDate, EXPIRATION_DATE);
    final ForexOptionDigital optionConstructed = new ForexOptionDigital(fx, expirationTime, IS_CALL, IS_LONG, PAY_DOM);
    assertEquals("Convertion to derivative", optionConstructed, optionConverted);
  }
View Full Code Here


   * Tests the conversion to derivative.
   */
  public void toDerivative() {
    final ZonedDateTime referenceDate = DateUtils.getUTCDate(2011, 5, 20);
    final InstrumentDerivative optionConverted = FX_OPTION_DEFINITION.toDerivative(referenceDate);
    final Forex fx = FX_DEFINITION.toDerivative(referenceDate);
    final DayCount actAct = DayCountFactory.INSTANCE.getDayCount("Actual/Actual ISDA");
    final double expirationTime = actAct.getDayCountFraction(referenceDate, EXPIRATION_DATE);
    final ForexOptionDigital optionConstructed = new ForexOptionDigital(fx, expirationTime, IS_CALL, IS_LONG, PAY_DOM);
    assertEquals("Convertion to derivative", optionConstructed, optionConverted);
  }
View Full Code Here

    final String discountingEUR = "Discounting EUR";
    final String discountingUSD = "Discounting USD";
    final String[] curves_name = new String[] {discountingEUR, discountingUSD};
    final ZonedDateTime referenceDate = DateUtils.getUTCDate(2011, 5, 20);
    final InstrumentDerivative optionConverted = FX_OPTION_DEFINITION.toDerivative(referenceDate, curves_name);
    final Forex fx = FX_DEFINITION.toDerivative(referenceDate, curves_name);
    final DayCount actAct = DayCountFactory.INSTANCE.getDayCount("Actual/Actual ISDA");
    final double expirationTime = actAct.getDayCountFraction(referenceDate, EXPIRATION_DATE);
    final ForexOptionVanilla optionConstructed = new ForexOptionVanilla(fx, expirationTime, IS_CALL, IS_LONG);
    assertEquals("Convertion to derivative", optionConstructed, optionConverted);
  }
View Full Code Here

   * Tests the conversion to derivative.
   */
  public void toDerivative() {
    final ZonedDateTime referenceDate = DateUtils.getUTCDate(2011, 5, 20);
    final InstrumentDerivative optionConverted = FX_OPTION_DEFINITION.toDerivative(referenceDate);
    final Forex fx = FX_DEFINITION.toDerivative(referenceDate);
    final DayCount actAct = DayCountFactory.INSTANCE.getDayCount("Actual/Actual ISDA");
    final double expirationTime = actAct.getDayCountFraction(referenceDate, EXPIRATION_DATE);
    final ForexOptionVanilla optionConstructed = new ForexOptionVanilla(fx, expirationTime, IS_CALL, IS_LONG);
    assertEquals("Convertion to derivative", optionConstructed, optionConverted);
  }
View Full Code Here

    final List<Double> ptsInt = new ArrayList<>();
    final List<Double> ptsDiff = new ArrayList<>();
    final List<Double> payTime = new ArrayList<>();
    while (!loopdate.isAfter(endDate)) {
      final ForexDefinition fxSwapDefinition = new ForexDefinition(EUR, USD, loopdate, notionalEUR, fxEURUSDFwdInit);
      final Forex fxSwap = fxSwapDefinition.toDerivative(NOW);
      final MultipleCurrencyAmount pvFxSwap = fxSwap.accept(PVDC, multicurves);
      final double pvUSDCurved = FX_MATRIX.convert(pvFxSwap, USD).getAmount();
      pvUSDCurve.add(pvUSDCurved);
      final double pvUSDPtsd = -(fxEURUSDFwdInit - FX_EURUSD - pointsCurve.getYValue(fxSwap.getPaymentTime()))
          * multicurves.getDiscountFactor(USD, fxSwap.getPaymentTime()) * notionalEUR;
      pvUSDPts.add(pvUSDPtsd);
      pvUSDDiff.add(pvUSDCurved - pvUSDPtsd);
      //      double testUSDI = (fxEURUSDFwdInit)
      //          * multicurves.getDiscountFactor(USD, fxSwap.getPaymentTime()) * notionalEUR;
      //      double testUSDC = (FX_EURUSD + pointsCurve.getYValue(fxSwap.getPaymentTime()))
      //          * multicurves.getDiscountFactor(USD, fxSwap.getPaymentTime()) * notionalEUR;
      //      double testEURUSD = pvFxSwap.getAmount(EUR) * FX_EURUSD;
      final double ptC = (multicurves.getDiscountFactor(EUR, fxSwap.getPaymentTime()) / multicurves.getDiscountFactor(USD, fxSwap.getPaymentTime()) - 1) * FX_EURUSD;
      ptsCurve.add(ptC);
      ptsInt.add(pointsCurve.getYValue(fxSwap.getPaymentTime()));
      ptsDiff.add((ptC - pointsCurve.getYValue(fxSwap.getPaymentTime())) * 10000);
      payTime.add(fxSwap.getPaymentTime());
      loopdate = ScheduleCalculator.getAdjustedDate(loopdate, 1, TARGET);
    }
  }
View Full Code Here

  public void toDerivativeDeprecated() {
    final String discountingEUR = "Discounting EUR";
    final String discountingUSD = "Discounting USD";
    final String[] curves = new String[] {discountingEUR, discountingUSD};
    final ZonedDateTime referenceDate = DateUtils.getUTCDate(2011, 5, 20);
    final Forex fxConverted = FX.toDerivative(referenceDate, curves);
    final PaymentFixed pay1 = PAY_1.toDerivative(referenceDate, discountingEUR);
    final PaymentFixed pay2 = PAY_2.toDerivative(referenceDate, discountingUSD);
    final Forex fxComparison = new Forex(pay1, pay2);
    assertEquals(fxComparison, fxConverted);
  }
View Full Code Here

  /**
   * Tests the conversion to derivative.
   */
  public void toDerivative() {
    final ZonedDateTime referenceDate = DateUtils.getUTCDate(2011, 5, 20);
    final Forex fxConverted = FX.toDerivative(referenceDate);
    final PaymentFixed pay1 = PAY_1.toDerivative(referenceDate);
    final PaymentFixed pay2 = PAY_2.toDerivative(referenceDate);
    final Forex fxComparison = new Forex(pay1, pay2);
    assertEquals(fxComparison, fxConverted);
  }
View Full Code Here

   */
  public void toDerivativeDeprecated() {
    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

  @Test
  /**
   * 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

  /**
   * Test the present value of EUR/USD is the same as an USD/EUR.
   */
  public void presentValueReverse() {
    final ForexDefinition fxReverseDefinition = new ForexDefinition(CUR_2, CUR_1, PAYMENT_DATE, -NOMINAL_1 * FX_RATE, 1.0 / FX_RATE);
    final Forex fxReverse = fxReverseDefinition.toDerivative(REFERENCE_DATE);
    final MultipleCurrencyAmount pv = METHOD_FX.presentValue(FX, MULTICURVES);
    final MultipleCurrencyAmount pvReverse = METHOD_FX.presentValue(fxReverse, MULTICURVES);
    assertEquals("Forex present value: Reverse description", pv.getAmount(CUR_1), pvReverse.getAmount(CUR_1), TOLERANCE_PV);
    assertEquals("Forex present value: Reverse description", pv.getAmount(CUR_2), pvReverse.getAmount(CUR_2), TOLERANCE_PV);
  }
View Full Code Here

TOP

Related Classes of com.opengamma.analytics.financial.forex.derivative.Forex

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.