Exemplo n.º 1
0
        public virtual 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.LastDeliveryDate);
            double expected   = BOND_PRICER.cleanPriceFromDirtyPrice(BOND, FUTURE_PRODUCT.LastDeliveryDate, dirtyPrice) / CONVERSION_FACTOR[0];

            assertEquals(computed, expected, TOL);
        }
        public virtual void test_dirtyPriceFromCurvesWithZSpread_continuous()
        {
            double         computed   = PRICER.dirtyPriceFromCurvesWithZSpread(PRODUCT, PROVIDER, REF_DATA, Z_SPREAD, CONTINUOUS, 0);
            CurrencyAmount pv         = PRICER.presentValueWithZSpread(PRODUCT, PROVIDER, Z_SPREAD, CONTINUOUS, 0);
            LocalDate      settlement = DATE_OFFSET.adjust(VAL_DATE, REF_DATA);
            double         df         = DSC_FACTORS_REPO.discountFactor(settlement);

            assertEquals(computed, pv.Amount / df / NOTIONAL);
        }
        /// <summary>
        /// Calculates the price of the bond future product with z-spread.
        /// <para>
        /// The price of the product is the price on the valuation date.
        /// </para>
        /// <para>
        /// The z-spread is a parallel shift applied to continuously compounded rates or periodic compounded rates
        /// of the issuer discounting curve.
        /// </para>
        /// <para>
        /// Strata uses <i>decimal prices</i> for bond futures. This is coherent with the pricing of <seealso cref="FixedCouponBond"/>.
        /// For example, a price of 99.32% is represented in Strata by 0.9932.
        ///
        /// </para>
        /// </summary>
        /// <param name="future">  the future </param>
        /// <param name="discountingProvider">  the discounting provider </param>
        /// <param name="zSpread">  the z-spread </param>
        /// <param name="compoundedRateType">  the compounded rate type </param>
        /// <param name="periodPerYear">  the number of periods per year </param>
        /// <returns> the price of the product, in decimal form </returns>
        public double priceWithZSpread(ResolvedBondFuture future, LegalEntityDiscountingProvider discountingProvider, double zSpread, CompoundedRateType compoundedRateType, int periodPerYear)
        {
            ImmutableList <ResolvedFixedCouponBond> basket = future.DeliveryBasket;
            int size = basket.size();

            double[] priceBonds = new double[size];
            for (int i = 0; i < size; ++i)
            {
                ResolvedFixedCouponBond bond = basket.get(i);
                double dirtyPrice            = bondPricer.dirtyPriceFromCurvesWithZSpread(bond, discountingProvider, zSpread, compoundedRateType, periodPerYear, future.LastDeliveryDate);
                priceBonds[i] = bondPricer.cleanPriceFromDirtyPrice(bond, future.LastDeliveryDate, dirtyPrice) / future.ConversionFactors.get(i);
            }
            return(Doubles.min(priceBonds));
        }