コード例 #1
0
 /**
  * Compute the present value of a bond transaction from its clean price.
  *
  * @param bond The bond transaction.
  * @param curves The curve bundle.
  * @param cleanPrice The bond clean price.
  * @return The present value.
  */
 public double presentValueFromCleanPrice(
     final BondTransaction<? extends BondSecurity<? extends Payment, ? extends Coupon>> bond,
     final YieldCurveBundle curves,
     final double cleanPrice) {
   ArgumentChecker.isTrue(
       bond instanceof BondFixedTransaction,
       "Present value from clean price only for fixed coupon bond");
   final BondFixedTransaction bondFixed = (BondFixedTransaction) bond;
   final double dfSettle =
       curves
           .getCurve(bondFixed.getBondStandard().getRepoCurveName())
           .getDiscountFactor(bondFixed.getBondTransaction().getSettlementTime());
   final double pvPriceStandard =
       (cleanPrice * bondFixed.getNotionalStandard()
               + bondFixed.getBondStandard().getAccruedInterest())
           * dfSettle;
   final double pvNominalStandard = bond.getBondStandard().getNominal().accept(PVC, curves);
   final double pvCouponStandard = bond.getBondStandard().getCoupon().accept(PVC, curves);
   final double pvDiscountingStandard = (pvNominalStandard + pvCouponStandard);
   final double pvNominalTransaction = bond.getBondTransaction().getNominal().accept(PVC, curves);
   final double pvCouponTransaction = bond.getBondTransaction().getCoupon().accept(PVC, curves);
   final double pvDiscountingTransaction = (pvNominalTransaction + pvCouponTransaction);
   return (pvDiscountingTransaction - pvDiscountingStandard + pvPriceStandard)
       * bond.getQuantity();
 }
コード例 #2
0
 /**
  * Compute the present value of a bond transaction from its yield-to-maturity.
  *
  * @param bond The bond transaction.
  * @param curves The curve bundle.
  * @param yield The bond yield.
  * @return The present value.
  */
 public double presentValueFromYield(
     final BondTransaction<? extends BondSecurity<? extends Payment, ? extends Coupon>> bond,
     final YieldCurveBundle curves,
     final double yield) {
   ArgumentChecker.notNull(bond, "Bond");
   ArgumentChecker.isTrue(
       bond instanceof BondFixedTransaction,
       "Present value from clean price only for fixed coupon bond");
   final BondFixedTransaction bondFixed = (BondFixedTransaction) bond;
   double cleanPrice = METHOD_SECURITY.cleanPriceFromYield(bondFixed.getBondStandard(), yield);
   return presentValueFromCleanPrice(bond, curves, cleanPrice);
 }