/** * Retrieve the basket product's coupon amount at the given date * * @param dblDate Double JulianDate * @param bmp Basket Market Parameters * @return Coupon Amount * @throws java.lang.Exception Thrown if coupon cannot be calculated */ public double getCoupon( final double dblDate, final org.drip.param.definition.BasketMarketParams bmp) throws java.lang.Exception { double dblNotional = getNotional(dblDate); if (null == bmp || 0. == dblNotional || !org.drip.quant.common.NumberUtil.IsValid(dblNotional)) throw new java.lang.Exception("BasketProduct::getCoupon => Cannot extract basket notional"); org.drip.product.definition.Component[] aComp = getComponents(); double dblCoupon = 0.; int iNumComp = aComp.length; for (int i = 0; i < iNumComp; ++i) dblCoupon += aComp[i].getCoupon(dblDate, bmp.getComponentMarketParams(aComp[i])); return dblCoupon / dblNotional; }
/** * Generate a full list of the basket product measures for the full input set of market parameters * * @param valParams ValuationParams * @param pricerParams PricerParams * @param bmp BasketMarketParams * @param quotingParams Quoting Parameters * @return Map of measure name and value */ 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.BasketMarketParams bmp, final org.drip.param.valuation.QuotingParams quotingParams) { long lStart = System.nanoTime(); org.drip.analytics.support.CaseInsensitiveTreeMap<java.lang.Double> mapBasketOP = new org.drip.analytics.support.CaseInsensitiveTreeMap<java.lang.Double>(); org.drip.product.definition.Component[] aComp = getComponents(); double[] adblWeight = getWeights(); int iNumComp = aComp.length; for (int i = 0; i < iNumComp; ++i) { org.drip.analytics.support.CaseInsensitiveTreeMap<java.lang.Double> mapCompOP = aComp[i].value( valParams, pricerParams, bmp.getComponentMarketParams(aComp[i]), quotingParams); if (null == mapCompOP || 0 == mapCompOP.size()) continue; java.util.Set<java.util.Map.Entry<java.lang.String, java.lang.Double>> mapCompOPES = mapCompOP.entrySet(); if (null == mapCompOPES) continue; for (java.util.Map.Entry<java.lang.String, java.lang.Double> meCompOP : mapCompOPES) { if (null == meCompOP) continue; java.lang.String strKey = meCompOP.getKey(); if (null == strKey || strKey.isEmpty()) continue; java.lang.Double dblCompValue = mapCompOP.get(strKey); java.lang.Double dblBasketValue = mapBasketOP.get(strKey); if (MEASURE_AGGREGATION_TYPE_CUMULATIVE == measureAggregationType(strKey)) mapBasketOP.put( strKey, (null == dblCompValue ? 0. : dblCompValue) + (null == dblBasketValue ? 0. : dblBasketValue)); else if (MEASURE_AGGREGATION_TYPE_WEIGHTED_CUMULATIVE == measureAggregationType(strKey) && null != adblWeight) mapBasketOP.put( strKey, (null == dblCompValue ? 0. : adblWeight[i] * dblCompValue) + (null == dblBasketValue ? 0. : dblBasketValue)); else if (MEASURE_AGGREGATION_TYPE_UNIT_ACCUMULATE == measureAggregationType(strKey)) mapBasketOP.put( aComp[i].getComponentName() + "[" + strKey + "]", (null == dblCompValue ? 0. : dblCompValue)); } } mapBasketOP.put("CalcTime", (System.nanoTime() - lStart) * 1.e-09); return mapBasketOP; }