コード例 #1
0
  @Override
  public org.drip.analytics.support.CaseInsensitiveTreeMap<java.lang.Double> value(
      final org.drip.param.valuation.ValuationParams valParams,
      final org.drip.param.pricer.PricerParams pricerParams,
      final org.drip.param.definition.ComponentMarketParams mktParams,
      final org.drip.param.valuation.QuotingParams quotingParams) {
    if (null == valParams || valParams._dblValue >= _dblMaturity || null == mktParams) return null;

    org.drip.analytics.definition.DiscountCurve dc = mktParams.getDiscountCurve();

    if (null == dc) return null;

    long lStart = System.nanoTime();

    org.drip.analytics.support.CaseInsensitiveTreeMap<java.lang.Double> mapResult =
        new org.drip.analytics.support.CaseInsensitiveTreeMap<java.lang.Double>();

    try {
      double dblCashSettle =
          null == _settleParams
              ? valParams._dblCashPay
              : _settleParams.cashSettleDate(valParams._dblValue);

      double dblUnadjustedAnnuity =
          dc.getDF(_dblMaturity) / dc.getDF(_dblEffective) / dc.getDF(dblCashSettle);

      double dblAdjustedAnnuity = dblUnadjustedAnnuity / dc.getDF(dblCashSettle);

      mapResult.put(
          "pv",
          dblAdjustedAnnuity * _dblNotional * 0.01 * getNotional(_dblEffective, _dblMaturity));

      mapResult.put("price", 100. * dblAdjustedAnnuity);

      mapResult.put(
          "rate",
          ((1. / dblUnadjustedAnnuity) - 1.)
              / org.drip.analytics.daycount.Convention.YearFraction(
                  _dblEffective, _dblMaturity, _strDC, false, _dblMaturity, null, _strCalendar));
    } catch (java.lang.Exception e) {
      e.printStackTrace();
    }

    mapResult.put("calctime", (System.nanoTime() - lStart) * 1.e-09);

    return mapResult;
  }
コード例 #2
0
  @Override
  public org.drip.math.calculus.WengertJacobian calcQuoteDFMicroJack(
      final java.lang.String strQuote,
      final org.drip.param.valuation.ValuationParams valParams,
      final org.drip.param.pricer.PricerParams pricerParams,
      final org.drip.param.definition.ComponentMarketParams mktParams,
      final org.drip.param.valuation.QuotingParams quotingParams) {
    if (null == valParams
        || valParams._dblValue >= _dblMaturity
        || null == strQuote
        || null == mktParams
        || null == mktParams.getDiscountCurve()) return null;

    if ("Rate".equalsIgnoreCase(strQuote)) {
      try {
        org.drip.analytics.definition.DiscountCurve dc = mktParams.getDiscountCurve();

        org.drip.math.calculus.WengertJacobian wjDF = dc.getDFJacobian(_dblMaturity);

        if (null == wjDF) return null;

        org.drip.math.calculus.WengertJacobian wjDFMicroJack =
            new org.drip.math.calculus.WengertJacobian(1, wjDF.numParameters());

        for (int k = 0; k < wjDF.numParameters(); ++k) {
          if (!wjDFMicroJack.accumulatePartialFirstDerivative(
              0,
              k,
              -365.25
                  / (_dblMaturity - _dblEffective)
                  / dc.getDF(_dblMaturity)
                  * wjDF.getFirstDerivative(0, k))) return null;
        }

        return wjDFMicroJack;
      } catch (java.lang.Exception e) {
        e.printStackTrace();
      }
    }

    return null;
  }
コード例 #3
0
  @Override
  public org.drip.math.calculus.WengertJacobian calcPVDFMicroJack(
      final org.drip.param.valuation.ValuationParams valParams,
      final org.drip.param.pricer.PricerParams pricerParams,
      final org.drip.param.definition.ComponentMarketParams mktParams,
      final org.drip.param.valuation.QuotingParams quotingParams) {
    if (null == valParams
        || valParams._dblValue >= _dblMaturity
        || null == mktParams
        || null == mktParams.getDiscountCurve()) return null;

    try {
      org.drip.analytics.support.CaseInsensitiveTreeMap<java.lang.Double> mapMeasures =
          value(valParams, pricerParams, mktParams, quotingParams);

      if (null == mapMeasures) return null;

      double dblPV = mapMeasures.get("PV");

      org.drip.analytics.definition.DiscountCurve dc = mktParams.getDiscountCurve();

      org.drip.math.calculus.WengertJacobian wjDFDF = dc.getDFJacobian(_dblMaturity);

      if (null == wjDFDF) return null;

      org.drip.math.calculus.WengertJacobian wjPVDFMicroJack =
          new org.drip.math.calculus.WengertJacobian(1, wjDFDF.numParameters());

      for (int k = 0; k < wjDFDF.numParameters(); ++k) {
        if (!wjPVDFMicroJack.accumulatePartialFirstDerivative(
            0, k, wjDFDF.getFirstDerivative(0, k))) return null;
      }

      return adjustPVDFMicroJackForCashSettle(valParams._dblCashPay, dblPV, dc, wjPVDFMicroJack)
          ? wjPVDFMicroJack
          : null;
    } catch (java.lang.Exception e) {
      e.printStackTrace();
    }

    return null;
  }