コード例 #1
0
 @Override
 public Double visitVarianceSwap(
     final VarianceSwap derivative, final EquityOptionDataBundle market) {
   Validate.notNull(market);
   Validate.notNull(derivative);
   return PRICER.presentValue(derivative, market);
 }
  /**
   * Calculates the sensitivity of the present value (PV) to a change in the funding rate from
   * valuation to settlement. Also know as PVBP and DV01, though note this return per UNIT change in
   * rate. calcPV01 returns per basis point change in rates.
   *
   * <p>
   *
   * <p>Rates enter the pricing of a VarianceSwap in two places: in the discounting and forward
   * projection.
   *
   * <p>The presentValue has been structured such that the form of the PV = Z(t,T) * FwdPrice(t,T)
   * with Z a zero coupon bond, and t and T the valuation and settlement times respectively. The
   * form of our discounting rates is such that Z(t,T) = exp[- R(t,T) * (T-t)], hence dZ/dR =
   * -(T-t)*Z(t,T) and d(PV)/dR = PV * dZ/dR The forward's dependence on the discounting rate is
   * similar to the zero coupon bonds, but of opposite sign, dF/dR = (T-t)*F(t,T)
   *
   * @param swap the VarianceSwap
   * @param market the VarianceSwapDataBundle
   * @param shift Relative size of shift made in centered-finite difference approximation.
   * @return A Double in the currency, deriv.getCurrency(). Currency amount per unit amount change
   *     in discount rate
   */
  @SuppressWarnings({})
  public Double calcDiscountRateSensitivity(
      final VarianceSwap swap, final VarianceSwapDataBundle market, final double shift) {
    Validate.notNull(market);
    Validate.notNull(swap);
    // Sensitivity from the discounting

    final VarianceSwapStaticReplication pricer = new VarianceSwapStaticReplication();
    final double pv = pricer.presentValue(swap, market);
    final double timeToSettlement = swap.getTimeToSettlement();

    // Sensitivity from forward projection
    final double fwdSens = calcForwardSensitivity(swap, market, shift);
    final double fwd = market.getForwardCurve().getForward(timeToSettlement);

    return timeToSettlement * (fwd * fwdSens - pv);
  }