public virtual void test_price() { double computed = PRICER.price(FUTURE_TRADE, RATE_PROVIDER, HW_PROVIDER); double expected = PRICER_PRODUCT.price(FUTURE, RATE_PROVIDER, HW_PROVIDER); assertEquals(computed, expected, TOL); }
public virtual void test_price() { double computed = PRICER.price(FUTURE, RATE_PROVIDER, HW_PROVIDER); LocalDate start = FUTURE.IborRate.Observation.EffectiveDate; LocalDate end = FUTURE.IborRate.Observation.MaturityDate; double fixingYearFraction = FUTURE.IborRate.Observation.YearFraction; double convexity = HW_PROVIDER.futuresConvexityFactor(FUTURE.LastTradeDate, start, end); double forward = RATE_PROVIDER.iborIndexRates(EUR_EURIBOR_3M).rate(FUTURE.IborRate.Observation); double expected = 1d - convexity * forward + (1d - convexity) / fixingYearFraction; assertEquals(computed, expected, TOL); }
//------------------------------------------------------------------------- /// <summary> /// Calculates the price of the Ibor future trade. /// <para> /// The price of the trade is the price on the valuation date. /// The price is calculated using the Hull-White model. /// /// </para> /// </summary> /// <param name="trade"> the trade </param> /// <param name="ratesProvider"> the rates provider </param> /// <param name="hwProvider"> the Hull-White model parameter provider </param> /// <returns> the price of the trade, in decimal form </returns> public virtual double price(ResolvedIborFutureTrade trade, RatesProvider ratesProvider, HullWhiteOneFactorPiecewiseConstantParametersProvider hwProvider) { return(productPricer.price(trade.Product, ratesProvider, hwProvider)); }