//------------------------------------------------------------------------- /// <summary> /// Calculates the present value sensitivity of the Overnight rate future trade. /// <para> /// The present value sensitivity of the trade is the sensitivity of the present value to /// the underlying curves. /// /// </para> /// </summary> /// <param name="trade"> the trade </param> /// <param name="ratesProvider"> the rates provider </param> /// <returns> the present value curve sensitivity of the trade </returns> public virtual PointSensitivities presentValueSensitivity(ResolvedOvernightFutureTrade trade, RatesProvider ratesProvider) { ResolvedOvernightFuture product = trade.Product; PointSensitivities priceSensi = productPricer.priceSensitivity(product, ratesProvider); PointSensitivities marginIndexSensi = productPricer.marginIndexSensitivity(product, priceSensi); return(marginIndexSensi.multipliedBy(trade.Quantity)); }
/// <summary> /// Calculates the price sensitivity of the Overnight rate future product. /// <para> /// The price sensitivity of the product is the sensitivity of the price to the underlying curves. /// /// </para> /// </summary> /// <param name="future"> the future </param> /// <param name="ratesProvider"> the rates provider </param> /// <returns> the price curve sensitivity of the product </returns> public virtual PointSensitivities priceSensitivity(ResolvedOvernightFuture future, RatesProvider ratesProvider) { PointSensitivityBuilder forwardRateSensitivity = rateComputationFn.rateSensitivity(future.OvernightRate, future.OvernightRate.StartDate, future.OvernightRate.EndDate, ratesProvider); // The sensitivity should be to no currency or currency XXX. To avoid useless conversion, the dimension-less // price sensitivity is reported in the future currency. return(forwardRateSensitivity.build().multipliedBy(-1d)); }
//------------------------------------------------------------------------- /// <summary> /// Calculates the present value of the Overnight rate future trade from the current price. /// <para> /// The present value of the product is the value on the valuation date. /// </para> /// <para> /// The calculation is performed against a reference price. The reference price /// must be the last settlement price used for margining, except on the trade date, /// when it must be the trade price. /// /// </para> /// </summary> /// <param name="trade"> the trade </param> /// <param name="currentPrice"> the current price, in decimal form </param> /// <param name="referencePrice"> the reference price to margin against, typically the last settlement price, in decimal form </param> /// <returns> the present value </returns> internal virtual CurrencyAmount presentValue(ResolvedOvernightFutureTrade trade, double currentPrice, double referencePrice) { ResolvedOvernightFuture future = trade.Product; double priceIndex = productPricer.marginIndex(future, currentPrice); double referenceIndex = productPricer.marginIndex(future, referencePrice); double pv = (priceIndex - referenceIndex) * trade.Quantity; return(CurrencyAmount.of(future.Currency, pv)); }
//------------------------------------------------------------------------- /// <summary> /// Calculates the price of the Overnight rate future product. /// <para> /// The price of the product is the price on the valuation date. /// /// </para> /// </summary> /// <param name="future"> the future </param> /// <param name="ratesProvider"> the rates provider </param> /// <returns> the price of the product, in decimal form </returns> public virtual double price(ResolvedOvernightFuture future, RatesProvider ratesProvider) { double forwardRate = rateComputationFn.rate(future.OvernightRate, future.OvernightRate.StartDate, future.OvernightRate.EndDate, ratesProvider); return(1d - forwardRate); }
/// <summary> /// Calculates the margin index sensitivity of the Overnight rate future product. /// <para> /// The margin index sensitivity is the sensitivity of the margin index to the underlying curves. /// For two consecutive settlement prices C1 and C2, the daily margin is computed as /// {@code (marginIndex(future, C2) - marginIndex(future, C1))}. /// /// </para> /// </summary> /// <param name="future"> the future </param> /// <param name="priceSensitivity"> the price sensitivity of the product </param> /// <returns> the index sensitivity </returns> internal virtual PointSensitivities marginIndexSensitivity(ResolvedOvernightFuture future, PointSensitivities priceSensitivity) { return(priceSensitivity.multipliedBy(future.Notional * future.AccrualFactor)); }
//------------------------------------------------------------------------- /// <summary> /// Calculates the number related to Overnight rate futures product on which the daily margin is computed. /// <para> /// For two consecutive settlement prices C1 and C2, the daily margin is computed as /// {@code (marginIndex(future, C2) - marginIndex(future, C1))}. /// /// </para> /// </summary> /// <param name="future"> the future </param> /// <param name="price"> the price of the product, in decimal form </param> /// <returns> the index </returns> internal virtual double marginIndex(ResolvedOvernightFuture future, double price) { return(price * future.Notional * future.AccrualFactor); }