@Override public org.drip.state.estimator.PredictorResponseWeightConstraint generateCalibPRLC( 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, final org.drip.state.representation.LatentStateMetricMeasure lsmm) { if (null == valParams || valParams.valueDate() >= getMaturityDate().getJulian() || null == lsmm || !(lsmm instanceof org.drip.analytics.rates.RatesLSMM) || !org.drip.analytics.rates.DiscountCurve.LATENT_STATE_DISCOUNT.equalsIgnoreCase( lsmm.getID())) return null; if (org.drip.analytics.rates.DiscountCurve.QUANTIFICATION_METRIC_FORWARD_RATE.equalsIgnoreCase( lsmm.getQuantificationMetric()) || org.drip.analytics.rates.DiscountCurve.QUANTIFICATION_METRIC_DISCOUNT_FACTOR .equalsIgnoreCase(lsmm.getQuantificationMetric())) { if (null == mktParams) return null; org.drip.analytics.rates.DiscountCurve dc = mktParams.getDiscountCurve(); if (null == dc) return null; org.drip.state.estimator.PredictorResponseWeightConstraint prwc = new org.drip.state.estimator.PredictorResponseWeightConstraint(); double dblDirtyCV100 = 0.; boolean bFirstPeriod = true; try { for (org.drip.analytics.period.CashflowPeriod period : _lsCouponPeriod) { if (null == period) continue; double dblPayDate = period.getPayDate(); if (valParams.valueDate() > dblPayDate) continue; double dblPeriodDCF = period.getCouponDCF(); if (bFirstPeriod) { bFirstPeriod = false; dblPeriodDCF -= period.getAccrualDCF(valParams.valueDate()); } double dblPeriodCV100 = dblPeriodDCF * dc.df(dblPayDate) * getNotional(dblPayDate); dblDirtyCV100 += dblPeriodCV100; if (!prwc.addPredictorResponseWeight(dblPayDate, dblPeriodCV100 * _dblNotional)) return null; } return prwc.updateValue(-1. * dblDirtyCV100 * _dblNotional * lsmm.getMeasureQuoteValue()) ? prwc : null; } catch (java.lang.Exception e) { e.printStackTrace(); return null; } } return null; }
@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 || null == mktParams) return null; org.drip.analytics.rates.DiscountCurve dc = mktParams.getDiscountCurve(); if (null == dc) return null; long lStart = System.nanoTime(); double dblFixing01 = 0.; double dblAccrued01 = 0.; double dblDirtyDV01 = 0.; boolean bFirstPeriod = true; double dblDirtyFloatingPV = 0.; double dblCashPayDF = java.lang.Double.NaN; double dblResetDate = java.lang.Double.NaN; double dblResetRate = java.lang.Double.NaN; java.lang.String strFRI = _fri.fullyQualifiedName(); org.drip.analytics.rates.ForwardRateEstimator fc = mktParams.getForwardCurve(); if (null != fc && !_fri.match(fc.index())) fc = null; for (org.drip.analytics.period.CashflowPeriod period : _lsCouponPeriod) { double dblFloatingRate = 0.; double dblDirtyPeriodDV01 = java.lang.Double.NaN; double dblPeriodPayDate = period.getPayDate(); if (dblPeriodPayDate < valParams.valueDate()) continue; if (null == fc) fc = dc.forwardRateEstimator(dblPeriodPayDate, _fri); try { if (bFirstPeriod) { bFirstPeriod = false; if (null == mktParams.getFixings() || null == mktParams .getFixings() .get(new org.drip.analytics.date.JulianDate(period.getResetDate())) || null == mktParams .getFixings() .get(new org.drip.analytics.date.JulianDate(period.getResetDate())) .get(strFRI)) dblResetRate = dblFloatingRate = null == fc ? dc.libor(_fri.tenor()) : fc.forward(period.getPayDate()); else dblResetRate = dblFloatingRate = mktParams .getFixings() .get(new org.drip.analytics.date.JulianDate(period.getResetDate())) .get(strFRI); dblFixing01 = period.getAccrualDCF(valParams.valueDate()) * 0.0001 * getNotional(period.getAccrualStartDate(), valParams.valueDate()); if (period.getStartDate() < valParams.valueDate()) dblAccrued01 = dblFixing01; dblResetDate = period.getResetDate(); } else dblFloatingRate = null == fc ? dc.libor(period.getStartDate(), period.getEndDate()) : fc.forward(period.getPayDate()); dblDirtyPeriodDV01 = 0.0001 * period.getCouponDCF() * mktParams.getDiscountCurve().df(dblPeriodPayDate) * getNotional(period.getAccrualStartDate(), period.getEndDate()); } catch (java.lang.Exception e) { e.printStackTrace(); return null; } if (s_bBlog) { try { System.out.println( new org.drip.analytics.date.JulianDate(period.getResetDate()) + " [" + new org.drip.analytics.date.JulianDate(period.getStartDate()) + "->" + new org.drip.analytics.date.JulianDate(period.getEndDate()) + "] => " + org.drip.quant.common.FormatUtil.FormatDouble(dblFloatingRate, 1, 4, 100.)); } catch (java.lang.Exception e) { e.printStackTrace(); } } dblDirtyDV01 += dblDirtyPeriodDV01; dblDirtyFloatingPV += dblDirtyPeriodDV01 * 10000. * dblFloatingRate; } try { double dblCashSettle = valParams.cashPayDate(); if (null != _settleParams) dblCashSettle = _settleParams.cashSettleDate(valParams.valueDate()); dblCashPayDF = mktParams.getDiscountCurve().df(dblCashSettle); } catch (java.lang.Exception e) { e.printStackTrace(); return null; } dblDirtyDV01 /= dblCashPayDF; dblDirtyFloatingPV /= dblCashPayDF; double dblCleanDV01 = dblDirtyDV01 - dblAccrued01; double dblCleanFloatingPV = dblDirtyFloatingPV - dblAccrued01 * (dblResetRate + _dblSpread); org.drip.analytics.support.CaseInsensitiveTreeMap<java.lang.Double> mapResult = new org.drip.analytics.support.CaseInsensitiveTreeMap<java.lang.Double>(); mapResult.put("ResetDate", dblResetDate); mapResult.put("ResetRate", dblResetRate); mapResult.put("Accrued01", dblAccrued01 * _dblNotional); mapResult.put("Fixing01", dblFixing01 * _dblNotional); mapResult.put( "FloatAccrued", dblAccrued01 * 10000. * (dblResetRate + _dblSpread) * _dblNotional); mapResult.put("DV01", dblCleanDV01 * _dblNotional); mapResult.put("CleanDV01", dblCleanDV01 * _dblNotional); mapResult.put("DirtyDV01", dblDirtyDV01 * _dblNotional); mapResult.put("CleanFloatingPV", dblCleanFloatingPV * _dblNotional); mapResult.put("DirtyFloatingPV", dblDirtyFloatingPV * _dblNotional); mapResult.put("PV", dblCleanFloatingPV * _dblNotional); mapResult.put("CleanPV", dblCleanFloatingPV * _dblNotional); mapResult.put("DirtyPV", dblDirtyFloatingPV * _dblNotional); mapResult.put("Upfront", dblCleanFloatingPV * _dblNotional); mapResult.put("FairPremium", dblCleanFloatingPV / dblCleanDV01); mapResult.put("Rate", dblCleanFloatingPV / dblCleanDV01); mapResult.put("ParRate", dblCleanFloatingPV / dblCleanDV01); double dblValueNotional = java.lang.Double.NaN; try { dblValueNotional = getNotional(valParams.valueDate()); } catch (java.lang.Exception e) { e.printStackTrace(); } if (org.drip.quant.common.NumberUtil.IsValid(dblValueNotional)) { double dblPrice = 100. * (1. + (dblCleanFloatingPV / _dblNotional / dblValueNotional)); mapResult.put("Price", dblPrice); mapResult.put("CleanPrice", dblPrice); } mapResult.put("CalcTime", (System.nanoTime() - lStart) * 1.e-09); return mapResult; }