@Override public CurrencyPair getCurrencyPair() { return index.getCurrencyPair().toConventional(); }
/** * Returns an FX rate object representing the market convention rate between the two currencies. * <p> * If the currency pair is the market convention pair, this method returns {@code this}, otherwise * it returns an {@code FxRate} with the inverse currency pair and reciprocal rate. * * @return an FX rate object representing the market convention rate between the two currencies */ public FxRate toConventional() { return pair.isConventional() ? this : FxRate.of(pair.toConventional(), 1 / rate); }
/** * Gets the currency pair in conventional order. * * @return the currency pair */ @Override public CurrencyPair getCurrencyPair() { return getNearLeg().getCurrencyPair().toConventional(); }
@ImmutableConstructor private FxRateId(CurrencyPair currencyPair, ObservableSource observableSource) { ArgChecker.notNull(currencyPair, "currencyPair"); ArgChecker.notNull(observableSource, "observableSource"); this.pair = currencyPair.toConventional(); this.observableSource = observableSource; }
return Optional.of(of(base, other.counter).toConventional()); return Optional.of(of(base, other.base).toConventional()); return Optional.of(of(counter, other.counter).toConventional()); return Optional.of(of(counter, other.base).toConventional());
public void test_toConventional() { assertEquals(CurrencyPair.of(GBP, USD).toConventional(), CurrencyPair.of(GBP, USD)); assertEquals(CurrencyPair.of(USD, GBP).toConventional(), CurrencyPair.of(GBP, USD)); assertEquals(CurrencyPair.of(GBP, BRL).toConventional(), CurrencyPair.of(GBP, BRL)); assertEquals(CurrencyPair.of(BRL, GBP).toConventional(), CurrencyPair.of(GBP, BRL)); assertEquals(CurrencyPair.of(BHD, BRL).toConventional(), CurrencyPair.of(BHD, BRL)); assertEquals(CurrencyPair.of(BRL, BHD).toConventional(), CurrencyPair.of(BHD, BRL)); }
@ImmutablePreBuild private static void preBuild(Builder builder) { if (builder.template != null) { if (builder.label == null) { builder.label = builder.template.getTenor().toString(); } if (builder.fxRateId == null) { builder.fxRateId = FxRateId.of(builder.template.getCurrencyPair()); } else { ArgChecker.isTrue( builder.fxRateId.getPair().toConventional().equals(builder.template.getCurrencyPair().toConventional()), "FxRateId currency pair '{}' must match that of the template '{}'", builder.fxRateId.getPair(), builder.template.getCurrencyPair()); } } }
@ImmutablePreBuild private static void preBuild(Builder builder) { if (builder.template != null) { if (builder.label == null) { builder.label = Tenor.of(builder.template.getPeriodToFar()).toString(); } if (builder.fxRateId == null) { builder.fxRateId = FxRateId.of(builder.template.getCurrencyPair()); } else { ArgChecker.isTrue( builder.fxRateId.getPair().toConventional().equals(builder.template.getCurrencyPair().toConventional()), "FxRateId currency pair '{}' must match that of the template '{}'", builder.fxRateId.getPair(), builder.template.getCurrencyPair()); } } }
"FxRate '{}' and CurrencyAmount '{}' must have a currency in common", nearRate, amount)); if (!nearRate.getPair().toConventional().equals(farRate.getPair().toConventional())) { throw new IllegalArgumentException(Messages.format( "FxRate '{}' and FxRate '{}' must contain the same currencies", nearRate, farRate));
"FxRate '{}' and CurrencyAmount '{}' must have a currency in common", nearRate, amount)); if (!nearRate.getPair().toConventional().equals(farRate.getPair().toConventional())) { throw new IllegalArgumentException(Messages.format( "FxRate '{}' and FxRate '{}' must contain the same currencies", nearRate, farRate));