Package com.opengamma.analytics.util.amount

Examples of com.opengamma.analytics.util.amount.StringAmount


  @Override
  public StringAmount visitGenericAnnuity(final Annuity<? extends Payment> annuity, final YieldCurveBundle curves) {
    Validate.notNull(curves);
    Validate.notNull(annuity);
    StringAmount pvpcs = new StringAmount();
    for (final Payment p : annuity.getPayments()) {
      pvpcs = StringAmount.plus(pvpcs, p.accept(this, curves));
    }
    return pvpcs;
  }
View Full Code Here


    final String discountingCurveName = bond.getDiscountingCurveName();
    final YieldCurveBundle curvesWithZ = new YieldCurveBundle();
    curvesWithZ.addAll(curves);
    final YieldAndDiscountCurve shiftedDiscounting = curves.getCurve(discountingCurveName).withParallelShift(zSpread);
    curvesWithZ.replaceCurve(discountingCurveName, shiftedDiscounting);
    final StringAmount parallelSensi = presentValueParallelCurveSensitivity(bond, curvesWithZ);
    return parallelSensi.getMap().get(discountingCurveName);

  }
View Full Code Here

   * @param bond The bond security.
   * @param curves The curve bundle.
   * @return The present value curve sensitivity.
   */
  public StringAmount presentValueParallelCurveSensitivity(final BondSecurity<? extends Payment, ? extends Coupon> bond, final YieldCurveBundle curves) {
    final StringAmount pvpcsNominal = bond.getNominal().accept(PVPCSC, curves);
    final StringAmount pvpcsCoupon = bond.getCoupon().accept(PVPCSC, curves);
    return StringAmount.plus(pvpcsNominal, pvpcsCoupon);
  }
View Full Code Here

   * @param zSpread The z-spread.
   * @return The Z spread sensitivity.
   */
  public double presentValueZSpreadSensitivity(final BondSecurity<? extends Payment, ? extends Coupon> bond, final IssuerProviderInterface issuerMulticurves, final double zSpread) {
    final IssuerProviderInterface issuerShifted = new IssuerProviderIssuerDecoratedSpread(issuerMulticurves, bond.getIssuerCcy(), zSpread);
    final StringAmount parallelSensi = presentValueParallelCurveSensitivity(bond, issuerShifted);
    return parallelSensi.getMap().get(issuerMulticurves.getName(bond.getIssuerCcy()));
  }
View Full Code Here

   * @return The present value curve sensitivity.
   */
  public StringAmount presentValueParallelCurveSensitivity(final BondSecurity<? extends Payment, ? extends Coupon> bond, final IssuerProviderInterface issuerMulticurves) {
    ArgumentChecker.notNull(bond, "Bond");
    final MulticurveProviderInterface multicurvesDecorated = new MulticurveProviderDiscountingDecoratedIssuer(issuerMulticurves, bond.getCurrency(), bond.getIssuer());
    final StringAmount pvpcsNominal = bond.getNominal().accept(PVPCSDC, multicurvesDecorated);
    final StringAmount pvpcsCoupon = bond.getCoupon().accept(PVPCSDC, multicurvesDecorated);
    return StringAmount.plus(pvpcsNominal, pvpcsCoupon);
  }
View Full Code Here

  @Override
  public StringAmount visitGenericAnnuity(final Annuity<? extends Payment> annuity, final MulticurveProviderInterface multicurves) {
    ArgumentChecker.notNull(annuity, "Annuity");
    ArgumentChecker.notNull(multicurves, "multicurve");
    StringAmount pvpcs = new StringAmount();
    for (final Payment p : annuity.getPayments()) {
      pvpcs = StringAmount.plus(pvpcs, p.accept(this, multicurves));
    }
    return pvpcs;
  }
View Full Code Here

  @Test
  public void multipliedBy() {
    String point1 = "Point 1";
    double value1 = 2345.678;
    StringAmount surf1 = StringAmount.from(point1, value1);
    double factor = 3;
    StringAmount surf2 = StringAmount.multiplyBy(surf1, factor);
    StringAmount surf3 = StringAmount.from(point1, factor * value1);
    assertTrue("Surface value - multipliedBy", StringAmount.compare(surf3, surf2, TOLERANCE));
  }
View Full Code Here

  @Test
  public void compare() {
    String point1 = "Point 1";
    double value1 = 2345.678;
    StringAmount surf1 = StringAmount.from(point1, value1);
    String point2 = "Point 2";
    double value2 = 10 * Math.E;
    StringAmount surf2 = StringAmount.from(point2, value2);
    StringAmount surfPlus1 = StringAmount.plus(surf1, surf2);
    StringAmount surfPlus2 = StringAmount.plus(surf2, surf1);
    assertTrue("Surface value - compare", StringAmount.compare(surfPlus1, surfPlus2, TOLERANCE));
  }
View Full Code Here

  private static final double TOLERANCE = 1.0E-10;

  @Test
  public void constructor() {
    StringAmount surf0 = new StringAmount();
    assertEquals("String value - constructor", 0, surf0.getMap().size());
    String point1 = "String 1";
    double value1 = 2345.678;
    StringAmount surf1 = StringAmount.from(point1, value1);
    assertEquals("Surface value - constructor", 1, surf1.getMap().size());
    assertTrue("Surface value - constructor", surf1.getMap().containsKey(point1));
    assertEquals("Surface value - constructor", value1, surf1.getMap().get(point1), TOLERANCE);
  }
View Full Code Here

  @Test
  public void plus() {
    String point1 = "Point 1";
    double value1 = 2345.678;
    StringAmount surf1 = StringAmount.from(point1, value1);
    String point2 = "Point 2";
    double value2 = 10 * Math.E;
    StringAmount surfPlus1 = StringAmount.plus(surf1, point2, value2);
    assertEquals("Surface value - plus", 2, surfPlus1.getMap().size());
    assertTrue("Surface value - plus", surfPlus1.getMap().containsKey(point1));
    assertTrue("Surface value - plus", surfPlus1.getMap().containsKey(point2));
    assertEquals("Surface value - plus", value1, surfPlus1.getMap().get(point1), TOLERANCE);
    assertEquals("Surface value - plus", value2, surfPlus1.getMap().get(point2), TOLERANCE);
    StringAmount surf2 = StringAmount.from(point2, value2);
    StringAmount surfPlus2 = StringAmount.plus(surf1, surf2);
    assertEquals("Surface value - plus", 2, surfPlus2.getMap().size());
    assertTrue("Surface value - plus", surfPlus2.getMap().containsKey(point1));
    assertTrue("Surface value - plus", surfPlus2.getMap().containsKey(point2));
    assertEquals("Surface value - plus", value1, surfPlus2.getMap().get(point1), TOLERANCE);
    assertEquals("Surface value - plus", value2, surfPlus2.getMap().get(point2), TOLERANCE);
    assertTrue("Surface value - plus", StringAmount.compare(StringAmount.plus(surfPlus2, surfPlus2), StringAmount.multiplyBy(surfPlus2, 2), TOLERANCE));
    String point3 = "Point 3";
    double value3 = 12.345;
    StringAmount surf3 = StringAmount.from(point3, value3);
    assertTrue("Surface value - plus", StringAmount.compare(StringAmount.plus(surfPlus2, point3, value3), StringAmount.plus(surfPlus2, surf3), TOLERANCE));
  }
View Full Code Here

TOP

Related Classes of com.opengamma.analytics.util.amount.StringAmount

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.