Package com.opengamma.util.tuple

Examples of com.opengamma.util.tuple.DoublesPair


*/
@Test(groups = TestGroup.UNIT)
public class QuadrantDoublesPairComparatorTest {

  public void testCompare_differentQuadrants() {
    final DoublesPair first = Pair.of(0.0, 0.0);
    final DoublesPair second = Pair.of(-0.1, 0.0);
    final DoublesPair third = Pair.of(-0.1, -0.1);
    final DoublesPair fourth = Pair.of(0.0, -0.1);
   
    final Comparator<DoublesPair> test = QuadrantDoublesPairComparator.INSTANCE;
   
    assertTrue(test.compare(first, first) == 0);
    assertTrue(test.compare(first, second) < 0);
View Full Code Here


    assertTrue(test.compare(fourth, third) > 0);
    assertTrue(test.compare(fourth, fourth) == 0);
  }

  public void testCompare_sameQuadrant() {
    final DoublesPair first = Pair.of(0.0, 0.0);
    final DoublesPair second = Pair.of(1.0, 0.0);
   
    final Comparator<DoublesPair> test = QuadrantDoublesPairComparator.INSTANCE;
   
    assertTrue(test.compare(first, first) == 0);
    assertTrue(test.compare(first, second) < 0);
View Full Code Here

*/
@Test(groups = TestGroup.UNIT)
public class FirstThenSecondDoublesPairComparatorTest {

  public void testSingleton() {
    DoublesPair a = Pair.of(1.0, 1.0);
    DoublesPair b = Pair.of(1.0, 2.0);
    assertTrue(FirstThenSecondDoublesPairComparator.INSTANCE.compare(a, a) == 0);
    assertTrue(FirstThenSecondDoublesPairComparator.INSTANCE.compare(a, b) < 0);
   
    assertTrue(FirstThenSecondDoublesPairComparator.INSTANCE.compare(b, a) > 0);
    assertTrue(FirstThenSecondDoublesPairComparator.INSTANCE.compare(b, b) == 0);
View Full Code Here

    assertTrue(FirstThenSecondDoublesPairComparator.INSTANCE.compare(b, a) > 0);
    assertTrue(FirstThenSecondDoublesPairComparator.INSTANCE.compare(b, b) == 0);
  }

  public void testCompare() {
    final DoublesPair first = Pair.of(1.0, 3.0);
    final DoublesPair second = Pair.of(1.0, 5.0);
    final DoublesPair third = Pair.of(1.0, 6.0);
    final DoublesPair fourth = Pair.of(2.0, 1.0);
   
    final FirstThenSecondDoublesPairComparator test = new FirstThenSecondDoublesPairComparator();
   
    assertTrue(test.compare(first, first) == 0);
    assertTrue(test.compare(first, second) < 0);
View Full Code Here

    double rateBar = 1.0;
    double pvFloatingBar = -1.0d / (dfPay * cpnFixed.getNotional()) * rateBar;
    double dfBar = pvLegFloating.getAmount() / (dfPay * dfPay * cpnFixed.getNotional()) * rateBar;
    final double dfDr = -cpnFixed.getPaymentTime() * dfPay;
    final List<DoublesPair> list = new ArrayList<>();
    list.add(new DoublesPair(cpnFixed.getPaymentTime(), dfDr * dfBar));
    final Map<String, List<DoublesPair>> dfMap = new HashMap<>();
    dfMap.put(cpnFixed.getFundingCurveName(), list);
    InterestRateCurveSensitivity result = new InterestRateCurveSensitivity(dfMap);
    InterestRateCurveSensitivity pvLegFloatingDr = METHOD_COUPON_ON_CMP.presentValueCurveSensitivity(fixedCouponSwap.getSecondLeg().getNthPayment(0), curves);
    result = result.plus(pvLegFloatingDr.multipliedBy(pvFloatingBar));
View Full Code Here

    final Annuity<CouponFixedAccruedCompounding> annuityFixed = fixedCouponSwap.getFirstLeg();
    double time;
    final List<DoublesPair> list = new ArrayList<>();
    for (int loopcpn = 0; loopcpn < annuityFixed.getPayments().length; loopcpn++) {
      time = annuityFixed.getNthPayment(loopcpn).getPaymentTime();
      final DoublesPair s = new DoublesPair(time, -time * discountingCurve.getDiscountFactor(time) * annuityFixed.getNthPayment(loopcpn).getPaymentYearFraction()
          * Math.abs(annuityFixed.getNthPayment(loopcpn).getNotional()));
      list.add(s);
    }
    return list;
  }
View Full Code Here

    final Annuity<CouponFixedAccruedCompounding> annuityFixed = fixedCouponSwap.getFirstLeg();
    double time;
    final List<DoublesPair> list = new ArrayList<>();
    for (int loopcpn = 0; loopcpn < annuityFixed.getPayments().length; loopcpn++) {
      time = annuityFixed.getNthPayment(loopcpn).getPaymentTime();
      final DoublesPair s = new DoublesPair(time, -time * discountingCurve.getDiscountFactor(time)
          * dayCount.getDayCountFraction(annuityFixed.getNthPayment(loopcpn).getAccrualStartDate(), annuityFixed.getNthPayment(loopcpn).getAccrualEndDate(), calendar)
          * Math.abs(annuityFixed.getNthPayment(loopcpn).getNotional()));
      list.add(s);
    }
    return list;
View Full Code Here

    final Annuity<CouponFixedAccruedCompounding> annuityFixed = fixedCouponSwap.getFirstLeg();
    double time;
    final List<DoublesPair> list = new ArrayList<>();
    for (int loopcpn = 0; loopcpn < annuityFixed.getPayments().length; loopcpn++) {
      time = annuityFixed.getNthPayment(loopcpn).getPaymentTime();
      final DoublesPair s = new DoublesPair(time, -time * discountingCurve.getDiscountFactor(time)
          * dayCount.getDayCountFraction(annuityFixed.getNthPayment(loopcpn).getAccrualStartDate(), annuityFixed.getNthPayment(loopcpn).getAccrualEndDate())
          * Math.abs(annuityFixed.getNthPayment(loopcpn).getNotional()));
      list.add(s);
    }
    return list;
View Full Code Here

    final BlackFunctionData dataBlack = new BlackFunctionData(forward, 1.0, volatility);
    final double[] priceAdjoint = BLACK_FUNCTION.getPriceAdjoint(option, dataBlack);
    // Backward sweep
    final double priceBar = 1.0;
    final double volatilityBar = priceAdjoint[2] * priceBar;
    final DoublesPair expiryStrikeDelay = new DoublesPair(security.getExpirationTime(), strike);
    final SurfaceValue sensi = SurfaceValue.from(expiryStrikeDelay, volatilityBar);
    return sensi;
  }
View Full Code Here

    final BlackFunctionData dataBlack = new BlackFunctionData(forward, 1.0, volatilityAdjoint[0]);
    final double[] priceAdjoint = BLACK_FUNCTION.getPriceAdjoint(option, dataBlack);
    // Backward sweep
    final double priceBar = 1.0;
    final double volatilityBar = priceAdjoint[2] * priceBar;
    final DoublesPair expiryDelay = new DoublesPair(security.getExpirationTime(), delay);
    sensi.addAlpha(expiryDelay, volatilityAdjoint[3] * volatilityBar);
    sensi.addBeta(expiryDelay, volatilityAdjoint[4] * volatilityBar);
    sensi.addRho(expiryDelay, volatilityAdjoint[5] * volatilityBar);
    sensi.addNu(expiryDelay, volatilityAdjoint[6] * volatilityBar);
    return sensi;
View Full Code Here

TOP

Related Classes of com.opengamma.util.tuple.DoublesPair

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.