/**
 * Copyright (C) 2015 - present by OpenGamma Inc. and the OpenGamma group of companies
 *
 * Please see distribution for license.
 */
package com.opengamma.strata.pricer.deposit;

import com.opengamma.strata.basics.currency.CurrencyAmount;
import com.opengamma.strata.collect.ArgChecker;
import com.opengamma.strata.market.sensitivity.PointSensitivities;
import com.opengamma.strata.pricer.rate.ImmutableRatesProvider;
import com.opengamma.strata.product.deposit.ResolvedIborFixingDeposit;
import com.opengamma.strata.product.deposit.ResolvedIborFixingDepositTrade;

/**
 * The methods associated to the pricing of Ibor fixing deposit trades by discounting.
 * <p>
 * This function provides the ability to price {@link ResolvedIborFixingDepositTrade}.
 * These trades are synthetic trades which are used for curve calibration purposes.
 * They should not be used as actual trades.
 */
public class DiscountingIborFixingDepositTradePricer {

  /**
   * Default implementation.
   */
  public static final DiscountingIborFixingDepositTradePricer DEFAULT =
      new DiscountingIborFixingDepositTradePricer(DiscountingIborFixingDepositProductPricer.DEFAULT);

  /**
   * Pricer for {@link ResolvedIborFixingDeposit}.
   */
  private final DiscountingIborFixingDepositProductPricer productPricer;

  /**
   * Creates an instance.
   * 
   * @param productPricer  the pricer for {@link ResolvedIborFixingDeposit}
   */
  public DiscountingIborFixingDepositTradePricer(DiscountingIborFixingDepositProductPricer productPricer) {
    this.productPricer = ArgChecker.notNull(productPricer, "productPricer");
  }

  //-------------------------------------------------------------------------
  /**
   * Calculates the present value of the Ibor fixing deposit trade.
   * <p>
   * The present value of the trade is the value on the valuation date.
   * 
   * @param trade  the trade to price
   * @param provider  the rates provider
   * @return the present value of the product
   */
  public CurrencyAmount presentValue(ResolvedIborFixingDepositTrade trade, ImmutableRatesProvider provider) {
    return productPricer.presentValue(trade.getProduct(), provider);
  }

  /**
   * Calculates the present value sensitivity of the Ibor fixing deposit trade.
   * <p>
   * The present value sensitivity of the trade is the sensitivity of the present value to
   * the underlying curves.
   * 
   * @param trade  the trade to price
   * @param provider  the rates provider
   * @return the point sensitivity of the present value
   */
  public PointSensitivities presentValueSensitivity(ResolvedIborFixingDepositTrade trade, ImmutableRatesProvider provider) {
    return productPricer.presentValueSensitivity(trade.getProduct(), provider);
  }

  //-------------------------------------------------------------------------
  /**
   * Calculates the spread to be added to the deposit rate to have a zero present value.
   * 
   * @param trade  the trade to price
   * @param provider  the rates provider
   * @return the par spread
   */
  public double parSpread(ResolvedIborFixingDepositTrade trade, ImmutableRatesProvider provider) {
    return productPricer.parSpread(trade.getProduct(), provider);
  }

  /**
   * Calculates the par spread curve sensitivity.
   * 
   * @param trade  the trade to price
   * @param provider  the rates provider
   * @return the par spread curve sensitivity
   */
  public PointSensitivities parSpreadSensitivity(ResolvedIborFixingDepositTrade trade, ImmutableRatesProvider provider) {
    return productPricer.parSpreadSensitivity(trade.getProduct(), provider);
  }

}

@@ -392,25 +392,16 @@
 er.rate.
-Immutable
 RatesPro
@@ -2033,33 +2033,24 @@
 rade trade, 
-Immutable
 RatesProvide
@@ -2055,32 +2055,32 @@
 der provider) %7B%0A
+
     return produ
@@ -2584,33 +2584,24 @@
 rade trade, 
-Immutable
 RatesProvide
@@ -3051,33 +3051,24 @@
 rade trade, 
-Immutable
 RatesProvide
@@ -3341,24 +3341,24 @@
 ivity%0A   */%0A
+
   public Poi
@@ -3436,17 +3436,8 @@
 de, 
-Immutable
 Rate

Change pricer to use rates provider