コード例 #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);
 }
コード例 #3
0
 /**
  * Compute the present value of a fixed coupon bond transaction.
  *
  * @param bond The bond transaction.
  * @param curves The curve bundle.
  * @return The present value.
  */
 public double presentValue(final BondFixedTransaction bond, final YieldCurveBundle curves) {
   final double pvNominal = bond.getBondTransaction().getNominal().accept(PVC, curves);
   final double pvCoupon = bond.getBondTransaction().getCoupon().accept(PVC, curves);
   final double settlementAmount =
       -(bond.getTransactionPrice()
                   * bond.getBondTransaction().getCoupon().getNthPayment(0).getNotional()
               + bond.getBondTransaction().getAccruedInterest())
           * bond.getQuantity();
   final PaymentFixed settlement =
       new PaymentFixed(
           bond.getBondTransaction().getCurrency(),
           bond.getBondTransaction().getSettlementTime(),
           settlementAmount,
           bond.getBondTransaction().getRepoCurveName());
   final double pvSettlement = settlement.accept(PVC, curves);
   return (pvNominal + pvCoupon) * bond.getQuantity() + pvSettlement;
 }
コード例 #4
0
 /**
  * Compute the present value sensitivity of a bond transaction.
  *
  * @param bond The bond transaction.
  * @param curves The curve bundle.
  * @return The present value sensitivity.
  */
 public InterestRateCurveSensitivity presentValueSensitivity(
     final BondFixedTransaction bond, final YieldCurveBundle curves) {
   final InterestRateCurveSensitivity pvsNominal =
       new InterestRateCurveSensitivity(
           bond.getBondTransaction().getNominal().accept(PVSC, curves));
   final InterestRateCurveSensitivity pvsCoupon =
       new InterestRateCurveSensitivity(
           bond.getBondTransaction().getCoupon().accept(PVSC, curves));
   final double settlementAmount =
       -(bond.getTransactionPrice()
                   * bond.getBondTransaction().getCoupon().getNthPayment(0).getNotional()
               + bond.getBondTransaction().getAccruedInterest())
           * bond.getQuantity();
   final PaymentFixed settlement =
       new PaymentFixed(
           bond.getBondTransaction().getCurrency(),
           bond.getBondTransaction().getSettlementTime(),
           settlementAmount,
           bond.getBondTransaction().getRepoCurveName());
   final InterestRateCurveSensitivity pvsSettlement =
       new InterestRateCurveSensitivity(settlement.accept(PVSC, curves));
   return pvsNominal.plus(pvsCoupon).multipliedBy(bond.getQuantity()).plus(pvsSettlement);
 }