Package com.opengamma.util.money

Examples of com.opengamma.util.money.CurrencyAmount


    final ForexDefinition forexUnderlyingDefinition = new ForexDefinition(EUR, USD, payDate, notional, strike);
    final ForexOptionVanillaDefinition forexOptionDefinition = new ForexOptionVanillaDefinition(forexUnderlyingDefinition, expDate, isCall, isLong);
    final ForexOptionVanilla forexOption = forexOptionDefinition.toDerivative(REFERENCE_DATE);
    final double gammaRelativeSpot = METHOD_OPTION.gammaRelativeSpot(forexOption, SMILE_MULTICURVES, true);
    final double gammaSpotExpected = gammaRelativeSpot * notional;
    final CurrencyAmount gammaSpotComputed = METHOD_OPTION.gammaSpot(forexOption, SMILE_MULTICURVES, true);
    assertEquals("Forex: relative gamma", 1.0, gammaSpotExpected / gammaSpotComputed.getAmount(), TOLERANCE_PV);
    assertEquals("Forex: relative gamma", 1.0, gammaSpotExpected / forexOption.accept(GSFBSC, SMILE_MULTICURVES).getAmount(), TOLERANCE_PV);
    final double gammaSpotExpected2 = METHOD_OPTION.gamma(forexOption, SMILE_MULTICURVES, true).getAmount() * SPOT;
    assertEquals("Forex: relative gamma", 1.0, gammaSpotExpected2 / gammaSpotComputed.getAmount(), TOLERANCE_PV);
  }
View Full Code Here


    final ForexDefinition forexUnderlyingDefinition = new ForexDefinition(USD, EUR, payDate, notional, 1.0 / strike);
    final ForexOptionVanillaDefinition forexOptionDefinition = new ForexOptionVanillaDefinition(forexUnderlyingDefinition, expDate, isCall, isLong);
    final ForexOptionVanilla forexOption = forexOptionDefinition.toDerivative(REFERENCE_DATE);
    final double gammaRelativeSpot = METHOD_OPTION.gammaRelativeSpot(forexOption, SMILE_MULTICURVES, false);
    final double gammaSpotExpected = gammaRelativeSpot * notional;
    final CurrencyAmount gammaSpotComputed = METHOD_OPTION.gammaSpot(forexOption, SMILE_MULTICURVES, false);
    assertEquals("Forex: relative gamma", 1.0, gammaSpotExpected / gammaSpotComputed.getAmount(), TOLERANCE_PV);
    final double gammaSpotExpected2 = METHOD_OPTION.gamma(forexOption, SMILE_MULTICURVES, false).getAmount() * SPOT;
    assertEquals("Forex: relative gamma", 1.0, gammaSpotExpected2 / gammaSpotComputed.getAmount(), TOLERANCE_PV);
  }
View Full Code Here

  public void presentValue() {
    final YieldCurveBundle curves = TestsDataSetsSABR.createCurves1();
    final double forward = FRA_METHOD.parRate(FRA, curves);
    final double dfSettle = curves.getCurve(CURVE_NAME_1[0]).getDiscountFactor(FRA.getPaymentTime());
    final double expectedPv = FRA.getNotional() * dfSettle * FRA.getPaymentYearFraction() * (forward - FRA_RATE) / (1 + FRA.getPaymentYearFraction() * forward);
    final CurrencyAmount pv = FRA_METHOD.presentValue(FRA, curves);
    assertEquals("FRA discounting: present value", expectedPv, pv.getAmount(), TOLERANCE_PV);
  }
View Full Code Here

  }

  @Test
  public void presentValueMethodVsCalculator() {
    final YieldCurveBundle curves = TestsDataSetsSABR.createCurves1();
    final CurrencyAmount pvMethod = FRA_METHOD.presentValue(FRA, curves);
    final double pvCalculator = FRA.accept(PVC, curves);
    assertEquals("FRA discounting: present value calculator vs method", pvCalculator, pvMethod.getAmount(), 1.0E-2);
  }
View Full Code Here

  public void presentValueBuySellParity() {
    final YieldCurveBundle curves = TestsDataSetsSABR.createCurves1();
    final ForwardRateAgreementDefinition fraDefinitionSell = new ForwardRateAgreementDefinition(CUR, PAYMENT_DATE, ACCRUAL_START_DATE, ACCRUAL_END_DATE, ACCRUAL_FACTOR_PAYMENT, -NOTIONAL,
        FIXING_DATE, INDEX, FRA_RATE, CALENDAR);
    final ForwardRateAgreement fraSell = (ForwardRateAgreement) fraDefinitionSell.toDerivative(REFERENCE_DATE, CURVE_NAME_1);
    final CurrencyAmount pvBuy = FRA_METHOD.presentValue(FRA, curves);
    final CurrencyAmount pvSell = FRA_METHOD.presentValue(fraSell, curves);
    assertEquals("FRA discounting: present value - buy/sell parity", pvSell.getAmount(), -pvBuy.getAmount(), 1.0E-2);
  }
View Full Code Here

  @Test
  /**
   * Tests the present value.
   */
  public void presentValueNotStarted() {
    final CurrencyAmount pv = METHOD_OIS.presentValue(EONIA_COUPON_NOTSTARTED, CURVES);
    final double dfForwardStart = CURVES.getCurve(CURVES_NAMES[1]).getDiscountFactor(START_ACCRUAL_TIME_1);
    final double dfForwardEnd = CURVES.getCurve(CURVES_NAMES[1]).getDiscountFactor(END_ACCRUAL_TIME_1);
    final double dfPayment = CURVES.getCurve(CURVES_NAMES[0]).getDiscountFactor(PAYMENT_TIME_1);
    final double forward = (dfForwardStart / dfForwardEnd - 1.0) / PAYMENT_YEAR_FRACTION;
    final double pvExpected = forward * PAYMENT_YEAR_FRACTION * NOTIONAL * dfPayment;
    AssertJUnit.assertEquals("CouponOIS: Present value by discounting", pvExpected, pv.getAmount(), 1.0E-2);
  }
View Full Code Here

  @Test
  /**
   * Tests the present value.
   */
  public void presentValueNotStartedMethodVsCalculator() {
    final CurrencyAmount pvMethod = METHOD_OIS.presentValue(EONIA_COUPON_NOTSTARTED, CURVES);
    final double pvCalculator = EONIA_COUPON_NOTSTARTED.accept(PVC, CURVES);
    AssertJUnit.assertEquals("CouponOIS: Present value by discounting", pvCalculator, pvMethod.getAmount(), 1.0E-2);
  }
View Full Code Here

  @Test
  /**
   * Tests the present value.
   */
  public void presentValueStarted() {
    final CurrencyAmount pv = METHOD_OIS.presentValue(EONIA_COUPON_STARTED, CURVES);
    final double dfRatioStart = CURVES.getCurve(CURVES_NAMES[1]).getDiscountFactor(START_FIXING_TIME_2);
    final double dfRatioEnd = CURVES.getCurve(CURVES_NAMES[1]).getDiscountFactor(END_FIXING_TIME_2);
    final double dfPayment = CURVES.getCurve(CURVES_NAMES[0]).getDiscountFactor(PAYMENT_TIME_2);
    final double dfRatio = dfRatioStart / dfRatioEnd;
    final double pvExpected = (NOTIONAL_WITH_ACCRUED * dfRatio - NOTIONAL) * dfPayment;
    AssertJUnit.assertEquals("CouponOIS: Present value by discounting", pvExpected, pv.getAmount(), 1.0E-2);
  }
View Full Code Here

  @Test
  /**
   * Tests the present value against a previous run.
   */
  public void presentValue() {
    final CurrencyAmount pv = METHOD_NI.presentValue(CMS_SPREAD, BUNDLE_G2PP);
    final double pvPreviousRun = 73582.631; // 5Y - 6M - strike 10bp
    assertEquals("CMS spread: G2++ - present value", pvPreviousRun, pv.getAmount(), TOLERANCE_PV);
  }
View Full Code Here

   * Tests present value when the valuation date is on trade date.
   */
  public void presentValueTrade() {
    final ZonedDateTime referenceDate = DateUtils.getUTCDate(2011, 12, 12);
    final DepositZero deposit = DEPOSIT_DEFINITION.toDerivative(referenceDate, CURVES_NAME[0]);
    final CurrencyAmount pvMethod = METHOD_DEPOSIT.presentValue(deposit, CURVES);
    final double dfEnd = CURVES.getCurve(CURVES_NAME[0]).getDiscountFactor(deposit.getEndTime());
    final double dfStart = CURVES.getCurve(CURVES_NAME[0]).getDiscountFactor(deposit.getStartTime());
    final double pvExpected = (NOTIONAL + deposit.getInterestAmount()) * dfEnd - NOTIONAL * dfStart;
    assertEquals("DepositDefinition: present value", pvExpected, pvMethod.getAmount(), TOLERANCE_PRICE);
    final double pvCalculator = deposit.accept(PVC, CURVES);
    assertEquals("DepositDefinition: present value", pvMethod.getAmount(), pvCalculator, TOLERANCE_PRICE);
  }
View Full Code Here

TOP

Related Classes of com.opengamma.util.money.CurrencyAmount

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.