public virtual void test_price()
        {
            double computed = TRADE_PRICER.price(FUTURE_TRADE, PROVIDER);
            double expected = PRODUCT_PRICER.price(FUTURE_PRODUCT, PROVIDER);

            assertEquals(computed, expected, TOL);
        }
Exemple #2
0
        //-------------------------------------------------------------------------
        public virtual void test_price()
        {
            double computed   = FUTURE_PRICER.price(FUTURE_PRODUCT, PROVIDER);
            double dirtyPrice = BOND_PRICER.dirtyPriceFromCurves(BOND, PROVIDER, FUTURE_PRODUCT.LastDeliveryDate);
            double expected   = BOND_PRICER.cleanPriceFromDirtyPrice(BOND, FUTURE_PRODUCT.LastDeliveryDate, dirtyPrice) / CONVERSION_FACTOR[0];

            assertEquals(computed, expected, TOL);
        }
Exemple #3
0
        public virtual void test_price()
        {
            double computed     = OPTION_PRICER.price(FUTURE_OPTION_PRODUCT, RATE_PROVIDER, VOLS);
            double futurePrice  = FUTURE_PRICER.price(FUTURE_OPTION_PRODUCT.UnderlyingFuture, RATE_PROVIDER);
            double strike       = FUTURE_OPTION_PRODUCT.StrikePrice;
            double expiryTime   = ACT_365F.relativeYearFraction(VAL_DATE, FUTURE_OPTION_PRODUCT.ExpiryDate);
            double logMoneyness = Math.Log(strike / futurePrice);
            double vol          = SURFACE.zValue(expiryTime, logMoneyness);
            double expected     = BlackFormulaRepository.price(futurePrice, strike, expiryTime, vol, true);

            assertEquals(computed, expected, TOL);
        }
        //-------------------------------------------------------------------------
        public virtual void test_presentValueSensitivity()
        {
            PointSensitivities             point    = OPTION_TRADE_PRICER.presentValueSensitivityRates(OPTION_TRADE, RATE_PROVIDER, VOLS);
            CurrencyParameterSensitivities computed = RATE_PROVIDER.parameterSensitivity(point);
            double futurePrice    = FUTURE_PRICER.price(OPTION_PRODUCT.UnderlyingFuture, RATE_PROVIDER);
            double strike         = OPTION_PRODUCT.StrikePrice;
            double expiryTime     = ACT_365F.relativeYearFraction(VAL_DATE, OPTION_PRODUCT.ExpiryDate);
            double logMoneyness   = Math.Log(strike / futurePrice);
            double logMoneynessUp = Math.Log(strike / (futurePrice + EPS));
            double logMoneynessDw = Math.Log(strike / (futurePrice - EPS));
            double vol            = SURFACE.zValue(expiryTime, logMoneyness);
            double volUp          = SURFACE.zValue(expiryTime, logMoneynessUp);
            double volDw          = SURFACE.zValue(expiryTime, logMoneynessDw);
            double volSensi       = 0.5 * (volUp - volDw) / EPS;
            double vega           = BlackFormulaRepository.vega(futurePrice, strike, expiryTime, vol);
            CurrencyParameterSensitivities sensiVol = RATE_PROVIDER.parameterSensitivity(FUTURE_PRICER.priceSensitivity(OPTION_PRODUCT.UnderlyingFuture, RATE_PROVIDER)).multipliedBy(-vega * volSensi * NOTIONAL * QUANTITY);
            CurrencyParameterSensitivities expected = FD_CAL.sensitivity(RATE_PROVIDER, (p) => OPTION_TRADE_PRICER.presentValue(OPTION_TRADE, (p), VOLS, REFERENCE_PRICE));

            assertTrue(computed.equalWithTolerance(expected.combinedWith(sensiVol), 30d * EPS * NOTIONAL * QUANTITY));
        }
        //-------------------------------------------------------------------------
        // calculate the price of the underlying future
        private double futurePrice(ResolvedBondFutureOption futureOption, LegalEntityDiscountingProvider discountingProvider)
        {
            ResolvedBondFuture future = futureOption.UnderlyingFuture;

            return(futurePricer.price(future, discountingProvider));
        }
 //-------------------------------------------------------------------------
 /// <summary>
 /// Calculates the price of the bond future trade.
 /// <para>
 /// The price of the trade is the price on the valuation date.
 /// </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="trade">  the trade </param>
 /// <param name="discountingProvider">  the discounting provider </param>
 /// <returns> the price of the trade, in decimal form </returns>
 public double price(ResolvedBondFutureTrade trade, LegalEntityDiscountingProvider discountingProvider)
 {
     return(productPricer.price(trade.Product, discountingProvider));
 }