@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; }
@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; }