@Override public String getName() { return name != null ? name : currencyPair.toString(); }
@Override public int compareKey(PointSensitivity other) { if (other instanceof FxForwardSensitivity) { FxForwardSensitivity otherFx = (FxForwardSensitivity) other; return ComparisonChain.start() .compare(currencyPair.toString(), otherFx.currencyPair.toString()) .compare(currency, otherFx.currency) .compare(referenceCurrency, otherFx.referenceCurrency) .compare(referenceDate, otherFx.referenceDate) .result(); } return getClass().getSimpleName().compareTo(other.getClass().getSimpleName()); }
@Override public int compareKey(PointSensitivity other) { if (other instanceof FxOptionSensitivity) { FxOptionSensitivity otherOption = (FxOptionSensitivity) other; return ComparisonChain.start() .compare(volatilitiesName, otherOption.volatilitiesName) .compare(currencyPair.toString(), otherOption.currencyPair.toString()) .compare(expiry, otherOption.expiry) .compare(strike, otherOption.strike) .compare(forward, otherOption.forward) .compare(currency, otherOption.currency) .result(); } return getClass().getSimpleName().compareTo(other.getClass().getSimpleName()); }
/** * Finds the other currency in the pair. * <p> * If the pair is AAA/BBB, then passing in AAA will return BBB, and passing in BBB will return AAA. * Passing in CCC will throw an exception. * * @param currency the currency to check * @return the other currency in the pair * @throws IllegalArgumentException if the specified currency is not one of those in the pair */ public Currency other(Currency currency) { ArgChecker.notNull(currency, "currency"); if (currency.equals(base)) { return counter; } if (currency.equals(counter)) { return base; } throw new IllegalArgumentException("Unable to find other currency, " + currency + " is not present in " + toString()); }
public void test_of_CurrencyCurrency_same() { CurrencyPair test = CurrencyPair.of(USD, USD); assertEquals(test.getBase(), USD); assertEquals(test.getCounter(), USD); assertEquals(test.isIdentity(), true); assertEquals(test.toString(), "USD/USD"); }
public void test_of_CurrencyCurrency_reverseStandardOrder() { CurrencyPair test = CurrencyPair.of(USD, GBP); assertEquals(test.getBase(), USD); assertEquals(test.getCounter(), GBP); assertEquals(test.isIdentity(), false); assertEquals(test.toSet(), ImmutableSet.of(GBP, USD)); assertEquals(test.toString(), "USD/GBP"); }
public void test_of_CurrencyCurrency() { CurrencyPair test = CurrencyPair.of(GBP, USD); assertEquals(test.getBase(), GBP); assertEquals(test.getCounter(), USD); assertEquals(test.isIdentity(), false); assertEquals(test.toSet(), ImmutableSet.of(GBP, USD)); assertEquals(test.toString(), "GBP/USD"); }
public void test_of_bda() { ImmutableFxSwapConvention test = ImmutableFxSwapConvention.of(EUR_USD, PLUS_TWO_DAYS, BDA_FOLLOW); assertEquals(test.getName(), EUR_USD.toString()); assertEquals(test.getCurrencyPair(), EUR_USD); assertEquals(test.getSpotDateOffset(), PLUS_TWO_DAYS); assertEquals(test.getBusinessDayAdjustment(), BDA_FOLLOW); }
@Override public MarketDataBox<FxRate> applyTo(MarketDataBox<FxRate> marketData, ReferenceData refData) { log.debug("Applying {} shift to FX rate '{}'", shiftType, marketData.getValue(0).getPair().toString()); return marketData.mapWithIndex( getScenarioCount(), (fxRate, scenarioIndex) -> FxRate.of( currencyPair, shiftType.applyShift(fxRate.fxRate(currencyPair), shiftAmount.get(scenarioIndex)))); }
public void test_of_nobda() { ImmutableFxSwapConvention test = ImmutableFxSwapConvention.of(EUR_USD, PLUS_TWO_DAYS); assertEquals(test.getName(), EUR_USD.toString()); assertEquals(test.getCurrencyPair(), EUR_USD); assertEquals(test.getSpotDateOffset(), PLUS_TWO_DAYS); assertEquals(test.getBusinessDayAdjustment(), BusinessDayAdjustment.of(MODIFIED_FOLLOWING, EUTA_USNY)); }