/**
  * Obtains an instance from currency pair, reference currency, reference date and sensitivity
  * value.
  *
  * <p>The sensitivity currency is defaulted to be a currency of the currency pair that is not the
  * reference currency.
  *
  * @param currencyPair the currency pair
  * @param referenceCurrency the reference currency
  * @param referenceDate the reference date
  * @param sensitivity the value of the sensitivity
  * @return the point sensitivity object
  */
 public static FxForwardSensitivity of(
     CurrencyPair currencyPair,
     Currency referenceCurrency,
     LocalDate referenceDate,
     double sensitivity) {
   boolean inverse = referenceCurrency.equals(currencyPair.getCounter());
   CurrencyPair pair = inverse ? currencyPair.inverse() : currencyPair;
   Currency sensitivityCurrency = pair.getCounter();
   return new FxForwardSensitivity(
       currencyPair, referenceCurrency, referenceDate, sensitivityCurrency, sensitivity);
 }
 /**
  * Gets the currency counter to the reference currency.
  *
  * <p>The currency pair contains two currencies. One is the reference currency. This method
  * returns the other.
  *
  * @return the counter currency
  */
 public Currency getReferenceCounterCurrency() {
   boolean inverse = referenceCurrency.equals(currencyPair.getBase());
   return inverse ? currencyPair.getCounter() : currencyPair.getBase();
 }
Exemplo n.º 3
0
 /**
  * Gets the FX rate for the specified currency pair on the valuation date.
  *
  * <p>The rate returned is the rate from the base currency to the counter currency as defined by
  * this formula: {@code (1 * baseCurrency = fxRate * counterCurrency)}.
  *
  * @param currencyPair the ordered currency pair defining the rate required
  * @return the current FX rate for the currency pair
  * @throws IllegalArgumentException if the rate is not available
  */
 @Override
 public default double fxRate(CurrencyPair currencyPair) {
   return fxRate(currencyPair.getBase(), currencyPair.getCounter());
 }