/** * Calculates the price of the bond future product. * <p> * The price of the product is the price on the valuation date. * <p> * Strata uses <i>decimal prices</i> for bond futures. This is coherent with the pricing of {@link FixedCouponBond}. * For example, a price of 99.32% is represented in Strata by 0.9932. * * @param future the future * @param discountingProvider the discounting provider * @return the price of the product, in decimal form */ public double price(ResolvedBondFuture future, LegalEntityDiscountingProvider discountingProvider) { ImmutableList<ResolvedFixedCouponBond> basket = future.getDeliveryBasket(); int size = basket.size(); double[] priceBonds = new double[size]; for (int i = 0; i < size; ++i) { ResolvedFixedCouponBond bond = basket.get(i); double dirtyPrice = bondPricer.dirtyPriceFromCurves(bond, discountingProvider, future.getLastDeliveryDate()); priceBonds[i] = bondPricer.cleanPriceFromDirtyPrice( bond, future.getLastDeliveryDate(), dirtyPrice) / future.getConversionFactors().get(i); } return Doubles.min(priceBonds); }
for (int i = 0; i < size; i++) { ResolvedFixedCouponBond bond = basket.get(i); double dirtyPrice = bondPricer.dirtyPriceFromCurves(bond, discountingProvider, future.getLastDeliveryDate()); priceBonds[i] = bondPricer.cleanPriceFromDirtyPrice( bond, future.getLastDeliveryDate(), dirtyPrice) / future.getConversionFactors().get(i); if (priceBonds[i] < priceMin) { priceMin = priceBonds[i]; bond, discountingProvider, future.getLastDeliveryDate()); return pointSensi.multipliedBy(1d / future.getConversionFactors().get(indexCTD)).build();
ResolvedFixedCouponBond bond = basket.get(i); double dirtyPrice = bondPricer.dirtyPriceFromCurvesWithZSpread( bond, discountingProvider, zSpread, compoundedRateType, periodPerYear, future.getLastDeliveryDate()); priceBonds[i] = bondPricer.cleanPriceFromDirtyPrice( bond, future.getLastDeliveryDate(), dirtyPrice) / future.getConversionFactors().get(i);
ResolvedFixedCouponBond bond = basket.get(i); double dirtyPrice = bondPricer.dirtyPriceFromCurvesWithZSpread( bond, discountingProvider, zSpread, compoundedRateType, periodPerYear, future.getLastDeliveryDate()); priceBonds[i] = bondPricer.cleanPriceFromDirtyPrice( bond, future.getLastDeliveryDate(), dirtyPrice) / future.getConversionFactors().get(i); if (priceBonds[i] < priceMin) { priceMin = priceBonds[i]; bond, discountingProvider, zSpread, compoundedRateType, periodPerYear, future.getLastDeliveryDate()); return pointSensi.multipliedBy(1d / future.getConversionFactors().get(indexCTD)).build();
public void test_priceWithZSpread_continuous() { double computed = FUTURE_PRICER.priceWithZSpread(FUTURE_PRODUCT, PROVIDER, Z_SPREAD, CONTINUOUS, 0); double dirtyPrice = BOND_PRICER.dirtyPriceFromCurvesWithZSpread( BOND, PROVIDER, Z_SPREAD, CONTINUOUS, 0, FUTURE_PRODUCT.getLastDeliveryDate()); double expected = BOND_PRICER.cleanPriceFromDirtyPrice( BOND, FUTURE_PRODUCT.getLastDeliveryDate(), dirtyPrice) / CONVERSION_FACTOR[0]; assertEquals(computed, expected, TOL); }
public void test_price() { double computed = FUTURE_PRICER.price(FUTURE_PRODUCT, PROVIDER); double dirtyPrice = BOND_PRICER.dirtyPriceFromCurves( BOND, PROVIDER, FUTURE_PRODUCT.getLastDeliveryDate()); double expected = BOND_PRICER.cleanPriceFromDirtyPrice( BOND, FUTURE_PRODUCT.getLastDeliveryDate(), dirtyPrice) / CONVERSION_FACTOR[0]; assertEquals(computed, expected, TOL); }
public void test_priceWithZSpread_periodic() { double computed = FUTURE_PRICER.priceWithZSpread(FUTURE_PRODUCT, PROVIDER, Z_SPREAD, PERIODIC, PERIOD_PER_YEAR); double dirtyPrice = BOND_PRICER.dirtyPriceFromCurvesWithZSpread( BOND, PROVIDER, Z_SPREAD, PERIODIC, PERIOD_PER_YEAR, FUTURE_PRODUCT.getLastDeliveryDate()); double expected = BOND_PRICER.cleanPriceFromDirtyPrice( BOND, FUTURE_PRODUCT.getLastDeliveryDate(), dirtyPrice) / CONVERSION_FACTOR[0]; assertEquals(computed, expected, TOL); }
/** * Restricted copy constructor. * @param beanToCopy the bean to copy from, not null */ private Builder(ResolvedBondFuture beanToCopy) { this.securityId = beanToCopy.getSecurityId(); this.deliveryBasket = beanToCopy.getDeliveryBasket(); this.conversionFactors = beanToCopy.getConversionFactors(); this.lastTradeDate = beanToCopy.getLastTradeDate(); this.firstNoticeDate = beanToCopy.getFirstNoticeDate(); this.lastNoticeDate = beanToCopy.getLastNoticeDate(); this.firstDeliveryDate = beanToCopy.getFirstDeliveryDate(); this.lastDeliveryDate = beanToCopy.getLastDeliveryDate(); this.rounding = beanToCopy.getRounding(); }
@Override protected Object propertyGet(Bean bean, String propertyName, boolean quiet) { switch (propertyName.hashCode()) { case 1574023291: // securityId return ((ResolvedBondFuture) bean).getSecurityId(); case 1999764186: // deliveryBasket return ((ResolvedBondFuture) bean).getDeliveryBasket(); case 1655488270: // conversionFactors return ((ResolvedBondFuture) bean).getConversionFactors(); case -1041950404: // lastTradeDate return ((ResolvedBondFuture) bean).getLastTradeDate(); case -1085415050: // firstNoticeDate return ((ResolvedBondFuture) bean).getFirstNoticeDate(); case -1060668964: // lastNoticeDate return ((ResolvedBondFuture) bean).getLastNoticeDate(); case 1755448466: // firstDeliveryDate return ((ResolvedBondFuture) bean).getFirstDeliveryDate(); case -233366664: // lastDeliveryDate return ((ResolvedBondFuture) bean).getLastDeliveryDate(); case -142444: // rounding return ((ResolvedBondFuture) bean).getRounding(); } return super.propertyGet(bean, propertyName, quiet); }
public void test_builder_noDeliveryDate() { ResolvedBondFuture base = sut(); ResolvedBondFuture test = ResolvedBondFuture.builder() .securityId(base.getSecurityId()) .deliveryBasket(base.getDeliveryBasket()) .conversionFactors(base.getConversionFactors()) .firstNoticeDate(base.getFirstNoticeDate()) .lastNoticeDate(base.getLastNoticeDate()) .firstDeliveryDate(base.getFirstDeliveryDate()) .lastDeliveryDate(base.getLastDeliveryDate()) .lastTradeDate(base.getLastTradeDate()) .rounding(base.getRounding()) .build(); assertEquals(test, base); }
.firstDeliveryDate(base.getFirstDeliveryDate()) .lastNoticeDate(base.getLastNoticeDate()) .lastDeliveryDate(base.getLastDeliveryDate()) .lastTradeDate(base.getLastTradeDate()) .rounding(base.getRounding())