/** * 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); }
@Override public int hashCode() { final int prime = 31; int result = super.hashCode(); long temp; temp = Double.doubleToLongBits(_dividendRatio); result = prime * result + (int) (temp ^ (temp >>> 32)); temp = Double.doubleToLongBits(_notionalAmount); result = prime * result + (int) (temp ^ (temp >>> 32)); result = prime * result + _notionalCurrency.hashCode(); result = prime * result + _equity.hashCode(); return result; }
/** * 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(); }
/** * Gets the convention name, such as 'GBP-Deposit'. * * <p>This will default to the currency code suffixed by '-Deposit' if not specified. * * @return the convention name */ @Override public String getName() { return name != null ? name : currency.getCode() + "-Deposit"; }