Package com.opengamma.analytics.financial.forex.definition

Examples of com.opengamma.analytics.financial.forex.definition.ForexDefinition.toDerivative()


    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;
 
View Full Code Here


    final String curve2 = "Discounting USD";
    final String[] names = new String[] {curve1, curve2};
    final ForexDefinition fxNearDefinition = new ForexDefinition(CUR_1, CUR_2, NEAR_DATE, NOMINAL_1, FX_RATE);
    final ForexDefinition fxFarDefinition = new ForexDefinition(CUR_1, CUR_2, FAR_DATE, -NOMINAL_1, FX_RATE + FORWARD_POINTS);
    final Forex fxNear = fxNearDefinition.toDerivative(REFERENCE_DATE, names);
    final Forex fxFar = fxFarDefinition.toDerivative(REFERENCE_DATE, names);
    final ForexSwap fxSwap = new ForexSwap(fxNear, fxFar);
    assertTrue(fxSwap.equals(fxSwap));
    final ForexSwap newFxSwap = new ForexSwap(fxNear, fxFar);
    assertTrue(fxSwap.equals(newFxSwap));
    assertTrue(fxSwap.hashCode() == newFxSwap.hashCode());
View Full Code Here

    modifiedOption = new ForexOptionDigital(FX, EXPIRATION_TIME - 0.01, IS_CALL, IS_LONG, true);
    assertFalse(modifiedOption.equals(FX_OPTION));
    modifiedOption = new ForexOptionDigital(FX, EXPIRATION_TIME, IS_CALL, !IS_LONG, true);
    assertFalse(modifiedOption.equals(FX_OPTION));
    final ForexDefinition modifiedFxDefinition = new ForexDefinition(CUR_1, CUR_2, PAYMENT_DATE, NOMINAL_1 + 1.0, FX_RATE);
    final Forex modifiedFx = modifiedFxDefinition.toDerivative(REFERENCE_DATE);
    modifiedOption = new ForexOptionDigital(modifiedFx, EXPIRATION_TIME, IS_CALL, IS_LONG, true);
    assertFalse(modifiedOption.equals(FX_OPTION));
    assertFalse(modifiedOption.equals(null));
  }
View Full Code Here

    modifiedOption = new ForexOptionDigital(fx, EXPIRATION_TIME - 0.01, IS_CALL, IS_LONG, true);
    assertFalse(modifiedOption.equals(option));
    modifiedOption = new ForexOptionDigital(fx, EXPIRATION_TIME, IS_CALL, !IS_LONG, true);
    assertFalse(modifiedOption.equals(option));
    final ForexDefinition modifiedFxDefinition = new ForexDefinition(CUR_1, CUR_2, PAYMENT_DATE, NOMINAL_1 + 1.0, FX_RATE);
    final Forex modifiedFx = modifiedFxDefinition.toDerivative(REFERENCE_DATE, curveNames);
    modifiedOption = new ForexOptionDigital(modifiedFx, EXPIRATION_TIME, IS_CALL, IS_LONG, true);
    assertFalse(modifiedOption.equals(option));
    assertFalse(modifiedOption.equals(null));
  }
}
View Full Code Here

    final ForexOptionVanilla optPositiveCall = new ForexOptionVanilla(fx, EXPIRATION_TIME, IS_CALL, IS_LONG);
    assertTrue("Forex vanilla option call/put: Positive amount / call", optPositiveCall.isCall());
    final ForexOptionVanilla optPositivePut = new ForexOptionVanilla(fx, EXPIRATION_TIME, !IS_CALL, IS_LONG);
    assertTrue("Forex vanilla option call/put: Positive amount / put", !optPositivePut.isCall());
    final ForexDefinition fxNegativeDefinition = new ForexDefinition(CUR_1, CUR_2, PAYMENT_DATE, -NOMINAL_1, FX_RATE);
    final Forex fxNegative = fxNegativeDefinition.toDerivative(REFERENCE_DATE, CURVES_NAME);
    final ForexOptionVanilla optNegativePut = new ForexOptionVanilla(fxNegative, EXPIRATION_TIME, !IS_CALL, IS_LONG);
    assertTrue("Forex vanilla option call/put: Negative amount / put", optNegativePut.isCall());
    final ForexOptionVanilla optNegativeCall = new ForexOptionVanilla(fxNegative, EXPIRATION_TIME, IS_CALL, IS_LONG);
    assertTrue("Forex vanilla option call/put: Negative amount / call", !optNegativeCall.isCall());
  }
View Full Code Here

    modifiedOption = new ForexOptionVanilla(fx, EXPIRATION_TIME - 0.01, IS_CALL, IS_LONG);
    assertFalse(modifiedOption.equals(fxOption));
    modifiedOption = new ForexOptionVanilla(fx, EXPIRATION_TIME, IS_CALL, !IS_LONG);
    assertFalse(modifiedOption.equals(fxOption));
    final ForexDefinition modifiedFxDefinition = new ForexDefinition(CUR_1, CUR_2, PAYMENT_DATE, NOMINAL_1 + 1.0, FX_RATE);
    final Forex modifiedFx = modifiedFxDefinition.toDerivative(REFERENCE_DATE, CURVES_NAME);
    modifiedOption = new ForexOptionVanilla(modifiedFx, EXPIRATION_TIME, IS_CALL, IS_LONG);
    assertFalse(modifiedOption.equals(fxOption));
    final EuropeanVanillaOption option = new EuropeanVanillaOption(fxOption.getStrike(), fxOption.getTimeToExpiry(), fxOption.isCall());
    assertFalse(fxOption.equals(option));
    assertFalse(modifiedOption.equals(null));
View Full Code Here

    final ForexOptionVanilla optPositiveCall = new ForexOptionVanilla(FX, EXPIRATION_TIME, IS_CALL, IS_LONG);
    assertTrue("Forex vanilla option call/put: Positive amount / call", optPositiveCall.isCall());
    final ForexOptionVanilla optPositivePut = new ForexOptionVanilla(FX, EXPIRATION_TIME, !IS_CALL, IS_LONG);
    assertTrue("Forex vanilla option call/put: Positive amount / put", !optPositivePut.isCall());
    final ForexDefinition fxNegativeDefinition = new ForexDefinition(CUR_1, CUR_2, PAYMENT_DATE, -NOMINAL_1, FX_RATE);
    final Forex fxNegative = fxNegativeDefinition.toDerivative(REFERENCE_DATE);
    final ForexOptionVanilla optNegativePut = new ForexOptionVanilla(fxNegative, EXPIRATION_TIME, !IS_CALL, IS_LONG);
    assertTrue("Forex vanilla option call/put: Negative amount / put", optNegativePut.isCall());
    final ForexOptionVanilla optNegativeCall = new ForexOptionVanilla(fxNegative, EXPIRATION_TIME, IS_CALL, IS_LONG);
    assertTrue("Forex vanilla option call/put: Negative amount / call", !optNegativeCall.isCall());
  }
View Full Code Here

    modifiedOption = new ForexOptionVanilla(FX, EXPIRATION_TIME - 0.01, IS_CALL, IS_LONG);
    assertFalse(modifiedOption.equals(FX_OPTION));
    modifiedOption = new ForexOptionVanilla(FX, EXPIRATION_TIME, IS_CALL, !IS_LONG);
    assertFalse(modifiedOption.equals(FX_OPTION));
    final ForexDefinition modifiedFxDefinition = new ForexDefinition(CUR_1, CUR_2, PAYMENT_DATE, NOMINAL_1 + 1.0, FX_RATE);
    final Forex modifiedFx = modifiedFxDefinition.toDerivative(REFERENCE_DATE);
    modifiedOption = new ForexOptionVanilla(modifiedFx, EXPIRATION_TIME, IS_CALL, IS_LONG);
    assertFalse(modifiedOption.equals(FX_OPTION));
    final EuropeanVanillaOption option = new EuropeanVanillaOption(FX_OPTION.getStrike(), FX_OPTION.getTimeToExpiry(), FX_OPTION.isCall());
    assertFalse(FX_OPTION.equals(option));
    assertFalse(modifiedOption.equals(null));
View Full Code Here

    final ForexDefinition forexUnderlyingDefinition = new ForexDefinition(EUR, USD, payDate, notional, strike);
    final ForexOptionVanillaDefinition forexOptionDefinitionCall = new ForexOptionVanillaDefinition(forexUnderlyingDefinition, expDate, isCall, isLong);
    final ForexOptionVanillaDefinition forexOptionDefinitionPut = new ForexOptionVanillaDefinition(forexUnderlyingDefinition, expDate, !isCall, isLong);
    final ForexOptionVanilla forexOptionCall = forexOptionDefinitionCall.toDerivative(REFERENCE_DATE, CURVES_NAME);
    final ForexOptionVanilla forexOptionPut = forexOptionDefinitionPut.toDerivative(REFERENCE_DATE, CURVES_NAME);
    final Forex forexForward = forexUnderlyingDefinition.toDerivative(REFERENCE_DATE, CURVES_NAME);
    final MultipleCurrencyAmount currencyExposureCall = METHOD_OPTION.currencyExposure(forexOptionCall, SMILE_BUNDLE);
    final MultipleCurrencyAmount currencyExposurePut = METHOD_OPTION.currencyExposure(forexOptionPut, SMILE_BUNDLE);
    final MultipleCurrencyAmount currencyExposureForward = METHOD_DISC.currencyExposure(forexForward, SMILE_BUNDLE);
    assertEquals("Forex vanilla option: currency exposure put/call parity foreign", currencyExposureForward.getAmount(EUR), currencyExposureCall.getAmount(EUR) - currencyExposurePut.getAmount(EUR),
        1E-2);
View Full Code Here

    final ZonedDateTime payDate = ScheduleCalculator.getAdjustedDate(REFERENCE_DATE, Period.ofMonths(9), BUSINESS_DAY, CALENDAR);
    final ZonedDateTime expDate = ScheduleCalculator.getAdjustedDate(payDate, -SETTLEMENT_DAYS, CALENDAR);
    final ForexDefinition forexUnderlyingDefinition = new ForexDefinition(EUR, USD, payDate, notional, strike);
    final ForexOptionVanillaDefinition forexOptionDefinitionCall = new ForexOptionVanillaDefinition(forexUnderlyingDefinition, expDate, isCall, isLong);
    final ForexOptionVanilla forexOptionCall = forexOptionDefinitionCall.toDerivative(REFERENCE_DATE, CURVES_NAME);
    final Forex forexForward = forexUnderlyingDefinition.toDerivative(REFERENCE_DATE, CURVES_NAME);
    final MultipleCurrencyInterestRateCurveSensitivity sensi = METHOD_OPTION.presentValueCurveSensitivity(forexOptionCall, SMILE_BUNDLE);
    final double dfDomestic = CURVES.getCurve(CURVES_NAME[1]).getDiscountFactor(forexForward.getPaymentTime());
    final double dfForeign = CURVES.getCurve(CURVES_NAME[0]).getDiscountFactor(forexForward.getPaymentTime());
    final double forward = SPOT * dfForeign / dfDomestic;
    final double volatility = SMILE_TERM.getVolatility(new Triple<>(forexOptionCall.getTimeToExpiry(), strike, forward));
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.