Package com.opengamma.util.money

Examples of com.opengamma.util.money.MultipleCurrencyAmount.plus()


  @Override
  public MultipleCurrencyAmount visitFixedPayment(final PaymentFixed payment) {
    ArgumentChecker.notNull(payment, "instrument");
    MultipleCurrencyAmount cash = MultipleCurrencyAmount.of(payment.getCurrency(), 0.0);
    if (isWithinLimit(payment.getPaymentTime())) {
      cash = cash.plus(payment.getCurrency(), payment.getAmount());
    }
    return cash;
  }

  @Override
View Full Code Here


  @Override
  public MultipleCurrencyAmount visitGenericAnnuity(final Annuity<? extends Payment> annuity) {
    ArgumentChecker.notNull(annuity, "instrument");
    MultipleCurrencyAmount pv = MultipleCurrencyAmount.of(annuity.getCurrency(), 0.0);
    for (final Payment p : annuity.getPayments()) {
      pv = pv.plus(p.accept(this));
    }
    return pv;
  }

  @Override
View Full Code Here

  @Override
  public MultipleCurrencyAmount visitSwap(final Swap<?, ?> swap) {
    ArgumentChecker.notNull(swap, "instrument");
    final MultipleCurrencyAmount cash = swap.getFirstLeg().accept(this);
    return cash.plus(swap.getSecondLeg().accept(this));
  }

  @Override
  public MultipleCurrencyAmount visitFixedCouponSwap(final SwapFixedCoupon<?> swap) {
    return visitSwap(swap);
View Full Code Here

    final double df2 = multicurves.getDiscountFactor(ccy2, payTime);
    final double ce2 = amount2 * df2;
    final double todayRate = multicurves.getFxRate(ccy1, ccy2);
    final double ce1 = amount1 * df2 * (fwdRate / todayRate);
    MultipleCurrencyAmount ce = MultipleCurrencyAmount.of(ccy1, ce1);
    ce = ce.plus(ccy2, ce2);
    return ce;
  }

  /**
   * Computes the present value curve sensitivity for forex by forward point method.
View Full Code Here

   */
  public MultipleCurrencyAmount presentValue(final ForexSwap fx, final MulticurveProviderInterface multicurves) {
    ArgumentChecker.notNull(fx, "Forex swap");
    ArgumentChecker.notNull(multicurves, "Multi-curves provider");
    final MultipleCurrencyAmount pv = METHOD_FX.presentValue(fx.getNearLeg(), multicurves);
    return pv.plus(METHOD_FX.presentValue(fx.getFarLeg(), multicurves));
  }

  // TODO: do we need this method as it is the same as present value
  public MultipleCurrencyAmount currencyExposure(final ForexSwap fx, final MulticurveProviderInterface multicurves) {
    return presentValue(fx, multicurves);
View Full Code Here

    final double sign = (optionForex.isLong() ? 1.0 : -1.0);
    final double price = priceAdjoint[0] * Math.abs(optionForex.getUnderlyingForex().getPaymentCurrency1().getAmount()) * sign;
    final double deltaSpot = priceAdjoint[1] * dfForeign / dfDomestic;
    MultipleCurrencyAmount currencyExposure = MultipleCurrencyAmount.of(optionForex.getUnderlyingForex().getCurrency1(),
        deltaSpot * Math.abs(optionForex.getUnderlyingForex().getPaymentCurrency1().getAmount()) * sign);
    currencyExposure = currencyExposure.plus(optionForex.getUnderlyingForex().getCurrency2(), -deltaSpot * Math.abs(optionForex.getUnderlyingForex().getPaymentCurrency1().getAmount()) * spot * sign
        + price);
    return currencyExposure;
  }

  /**
 
View Full Code Here

  public MultipleCurrencyAmount visitGenericAnnuity(final Annuity<? extends Payment> annuity, final YieldCurveBundle curves) {
    Validate.notNull(curves);
    Validate.notNull(annuity);
    MultipleCurrencyAmount pv = annuity.getNthPayment(0).accept(this, curves);
    for (int loopp = 1; loopp < annuity.getNumberOfPayments(); loopp++) {
      pv = pv.plus(annuity.getNthPayment(loopp).accept(this, curves));
    }
    return pv;
  }

  @Override
View Full Code Here

  public MultipleCurrencyAmount visitSwap(final Swap<?, ?> swap, final YieldCurveBundle curves) {
    Validate.notNull(curves);
    Validate.notNull(swap);
    final MultipleCurrencyAmount pvFirst = swap.getFirstLeg().accept(this, curves);
    final MultipleCurrencyAmount pvSecond = swap.getSecondLeg().accept(this, curves);
    return pvSecond.plus(pvFirst);
  }

  @Override
  public MultipleCurrencyAmount visitFixedCouponSwap(final SwapFixedCoupon<?> swap, final YieldCurveBundle curves) {
    return visitSwap(swap, curves);
View Full Code Here

        final MultipleCurrencyAmount receiveAmount = receive.get(date);
        MultipleCurrencyAmount combinedAmountForDate = null;
        if (payAmount != null) {
          combinedAmountForDate = payAmount.multipliedBy(-1);
          if (receiveAmount != null) {
            combinedAmountForDate = combinedAmountForDate.plus(receiveAmount);
          }
        } else {
          if (receiveAmount != null) {
            combinedAmountForDate = receiveAmount;
          }
View Full Code Here

    fxMatrix.addCurrency(GBP, EUR, GBP_EUR);
    final double amountGBP = 1.0;
    final double amountEUR = 2.0;
    final double amountUSD = 3.0;
    MultipleCurrencyAmount amount = MultipleCurrencyAmount.of(GBP, amountGBP);
    amount = amount.plus(EUR, amountEUR);
    amount = amount.plus(USD, amountUSD);
    final CurrencyAmount totalUSDCalculated = fxMatrix.convert(amount, USD);
    final double totalUSDExpected = amountUSD + amountEUR * EUR_USD + amountGBP * GBP_EUR * EUR_USD;
    assertEquals("FXMatrix - convert", totalUSDExpected, totalUSDCalculated.getAmount(), 1.0E-10);
    assertEquals("FXMatrix - convert", USD, totalUSDCalculated.getCurrency());
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.