@Override protected Object propertyGet(Bean bean, String propertyName, boolean quiet) { switch (propertyName.hashCode()) { case 1574023291: // securityId return ((ResolvedFixedCouponBond) bean).getSecurityId(); case -44199542: // nominalPayment return ((ResolvedFixedCouponBond) bean).getNominalPayment(); case -367345944: // periodicPayments return ((ResolvedFixedCouponBond) bean).getPeriodicPayments(); case -70023844: // frequency return ((ResolvedFixedCouponBond) bean).getFrequency(); case -10223666: // rollConvention return ((ResolvedFixedCouponBond) bean).getRollConvention(); case 747425396: // fixedRate return ((ResolvedFixedCouponBond) bean).getFixedRate(); case 1905311443: // dayCount return ((ResolvedFixedCouponBond) bean).getDayCount(); case -1895216418: // yieldConvention return ((ResolvedFixedCouponBond) bean).getYieldConvention(); case 866287159: // legalEntityId return ((ResolvedFixedCouponBond) bean).getLegalEntityId(); case 135924714: // settlementDateOffset return ((ResolvedFixedCouponBond) bean).getSettlementDateOffset(); } return super.propertyGet(bean, propertyName, quiet); }
/** * Restricted copy constructor. * @param beanToCopy the bean to copy from, not null */ private Builder(ResolvedFixedCouponBond beanToCopy) { this.securityId = beanToCopy.getSecurityId(); this.nominalPayment = beanToCopy.getNominalPayment(); this.periodicPayments = beanToCopy.getPeriodicPayments(); this.frequency = beanToCopy.getFrequency(); this.rollConvention = beanToCopy.getRollConvention(); this.fixedRate = beanToCopy.getFixedRate(); this.dayCount = beanToCopy.getDayCount(); this.yieldConvention = beanToCopy.getYieldConvention(); this.legalEntityId = beanToCopy.getLegalEntityId(); this.settlementDateOffset = beanToCopy.getSettlementDateOffset(); }
/** * Calculates the yield of the fixed coupon bond product from dirty price. * <p> * The dirty price must be fractional. * If the analytic formula is not available, the yield is computed by solving * a root-finding problem with {@link #dirtyPriceFromYield(ResolvedFixedCouponBond, LocalDate, double)}. * The result is also expressed in fraction. * * @param bond the product * @param settlementDate the settlement date * @param dirtyPrice the dirty price * @return the yield of the product */ public double yieldFromDirtyPrice(ResolvedFixedCouponBond bond, LocalDate settlementDate, double dirtyPrice) { if (bond.getYieldConvention().equals(JP_SIMPLE)) { double cleanPrice = cleanPriceFromDirtyPrice(bond, settlementDate, dirtyPrice); LocalDate maturityDate = bond.getUnadjustedEndDate(); double maturity = bond.getDayCount().relativeYearFraction(settlementDate, maturityDate); return (bond.getFixedRate() + (1d - cleanPrice) / maturity) / cleanPrice; } final Function<Double, Double> priceResidual = new Function<Double, Double>() { @Override public Double apply(final Double y) { return dirtyPriceFromYield(bond, settlementDate, y) - dirtyPrice; } }; double[] range = ROOT_BRACKETER.getBracketedPoints(priceResidual, 0.00, 0.20); double yield = ROOT_FINDER.getRoot(priceResidual, range[0], range[1]); return yield; }
return 0d; double maturity = bond.getDayCount().relativeYearFraction(settlementDate, maturityDate); double cleanPrice = (1d + bond.getFixedRate() * maturity) / (1d + yield * maturity); return dirtyPriceFromCleanPrice(bond, settlementDate, cleanPrice);
return 0d; double maturity = bond.getDayCount().relativeYearFraction(settlementDate, maturityDate); double num = 1d + bond.getFixedRate() * maturity; double den = 1d + yield * maturity;
return 0d; double maturity = bond.getDayCount().relativeYearFraction(settlementDate, maturityDate); double num = 1d + bond.getFixedRate() * maturity; double den = 1d + yield * maturity;