/** * Gets the currency pair of the FX index. * * @return the currency pair of the index */ public CurrencyPair getCurrencyPair() { return index.getCurrencyPair(); }
@Override public CurrencyPair getCurrencyPair() { return index.getCurrencyPair().toConventional(); }
@ImmutableValidator private void validate() { if (!index.getCurrencyPair().equals(fxForwardRates.getCurrencyPair())) { throw new IllegalArgumentException("Underlying FxForwardRates must have same currency pair"); } }
/** * Gets the non-deliverable currency. * <p> * Returns the currency that is not the settlement currency. * * @return the currency that is not to be settled */ public Currency getNonDeliverableCurrency() { FxIndex index = getIndex(); return index.getCurrencyPair().getBase().equals(getSettlementCurrency()) ? index.getCurrencyPair().getCounter() : index.getCurrencyPair().getBase(); }
@ImmutableValidator private void validate() { if (!index.getCurrencyPair().contains(referenceCurrency)) { throw new IllegalArgumentException( Messages.format("Reference currency {} must be one of those in the FxIndex {}", referenceCurrency, index)); } }
@Override public FxIndexRates fxIndexRates(FxIndex index) { LocalDateDoubleTimeSeries fixings = timeSeries(index); FxForwardRates fxForwardRates = fxForwardRates(index.getCurrencyPair()); return ForwardFxIndexRates.of(index, fxForwardRates, fixings); }
@ImmutableValidator private void validate() { FxIndex index = observation.getIndex(); if (!index.getCurrencyPair().contains(referenceCurrency)) { throw new IllegalArgumentException( Messages.format("Reference currency {} must be one of those in the FxIndex {}", referenceCurrency, index)); } }
/** * Gets the payment currency. * <p> * This returns the currency that the payment is made in. * ISDA refers to this as the <i>variable currency</i>. * * @return the payment currency */ @Override public Currency getCurrency() { FxIndex index = observation.getIndex(); Currency indexBase = index.getCurrencyPair().getBase(); Currency indexCounter = index.getCurrencyPair().getCounter(); return (getReferenceCurrency().equals(indexBase) ? indexCounter : indexBase); }
private double forwardRate(FxIndexObservation observation) { return fxForwardRates.rate(index.getCurrencyPair().getBase(), observation.getMaturityDate()); }
@ImmutableValidator private void validate() { CurrencyPair pair = index.getCurrencyPair(); if (!pair.contains(settlementCurrencyNotional.getCurrency())) { throw new IllegalArgumentException("FxIndex and settlement notional currency are incompatible"); } if (!(pair.equals(agreedFxRate.getPair()) || pair.isInverse(agreedFxRate.getPair()))) { throw new IllegalArgumentException("FxIndex and agreed FX rate are incompatible"); } }
@ImmutableValidator private void validate() { CurrencyPair pair = observation.getIndex().getCurrencyPair(); if (!pair.contains(settlementCurrencyNotional.getCurrency())) { throw new IllegalArgumentException("FxIndex and settlement notional currency are incompatible"); } if (!(pair.equals(agreedFxRate.getPair()) || pair.isInverse(agreedFxRate.getPair()))) { throw new IllegalArgumentException("FxIndex and agreed FX rate are incompatible"); } }
@ImmutableValidator private void validate() { FxIndex index = observation.getIndex(); if (!index.getCurrencyPair().contains(notionalAmount.getCurrency())) { throw new IllegalArgumentException( Messages.format( "Reference currency {} must be one of those in the FxIndex {}", notionalAmount.getCurrency(), index)); } }
@Override public double rate(FxIndexObservation observation, Currency baseCurrency) { ArgChecker.isTrue( index.getCurrencyPair().contains(baseCurrency), "Currency {} invalid for FxIndex {}", baseCurrency, index); LocalDate fixingDate = observation.getFixingDate(); double fxIndexRate = !fixingDate.isAfter(getValuationDate()) ? historicRate(observation) : forwardRate(observation); boolean inverse = baseCurrency.equals(index.getCurrencyPair().getCounter()); return (inverse ? 1d / fxIndexRate : fxIndexRate); }
@ImmutableValidator private void validate() { if (fxReset != null) { Currency notionalCcy = fxReset.getReferenceCurrency(); if (fxReset.getReferenceCurrency().equals(currency)) { throw new IllegalArgumentException(Messages.format( "Payment currency {} must not equal notional currency {} when FX reset applies", currency, notionalCcy)); } if (!fxReset.getIndex().getCurrencyPair().contains(currency)) { throw new IllegalArgumentException(Messages.format( "Payment currency {} must be one of those in the FxReset index {}", currency, fxReset.getIndex())); } } }
public void test_of() { FxIndexObservation test = FxIndexObservation.of(GBP_USD_WM, FIXING_DATE, REF_DATA); assertEquals(test.getIndex(), GBP_USD_WM); assertEquals(test.getFixingDate(), FIXING_DATE); assertEquals(test.getMaturityDate(), MATURITY_DATE); assertEquals(test.getCurrencyPair(), GBP_USD_WM.getCurrencyPair()); assertEquals(test.toString(), "FxIndexObservation[GBP/USD-WM on 2016-02-22]"); }
@ImmutableValidator private void validate() { if (fxReset != null) { if (fxReset.getReferenceCurrency().equals(currency)) { throw new IllegalArgumentException( Messages.format("Currency {} must not equal FxResetCalculation reference currency {}", currency, fxReset.getReferenceCurrency())); } if (!fxReset.getIndex().getCurrencyPair().contains(currency)) { throw new IllegalArgumentException( Messages.format("Currency {} must be one of those in the FxResetCalculation index {}", currency, fxReset.getIndex())); } if (!(initialExchange || intermediateExchange || finalExchange)) { throw new IllegalArgumentException( Messages.format( "FxResetCalculation index {} was specified but schedule does not include any notional exchanges", fxReset.getIndex())); } } }
@ImmutableValidator private void validate() { // check for unadjusted must be after firstNonNull ArgChecker.inOrderNotEqual(startDate, endDate, "startDate", "endDate"); ArgChecker.inOrderNotEqual(unadjustedStartDate, unadjustedEndDate, "unadjustedStartDate", "unadjustedEndDate"); Currency payCcy = payment.getCurrency(); Currency notionalCcy = notionalAmount.getCurrency(); if (fxResetObservation != null) { if (notionalCcy.equals(payCcy)) { throw new IllegalArgumentException(Messages.format( "Payment currency {} must not equal notional currency {} when FX reset applies", payCcy, notionalCcy)); } if (!fxResetObservation.getIndex().getCurrencyPair().contains(payCcy)) { throw new IllegalArgumentException(Messages.format( "Payment currency {} must be one of those in the FxReset index {}", payCcy, fxResetObservation.getIndex())); } if (!fxResetObservation.getIndex().getCurrencyPair().contains(notionalCcy)) { throw new IllegalArgumentException(Messages.format( "Notional currency {} must be one of those in the FxReset index {}", notionalCcy, fxResetObservation.getIndex())); } } else { if (!notionalCcy.equals(payCcy)) { throw new IllegalArgumentException(Messages.format( "Payment currency {} must equal notional currency {}", payCcy, notionalCcy)); } } }
private IntFunction<CurrencyAmount> getNotionalSupplierFunction( NotionalSchedule notionalSchedule, DoubleArray notionals, PayReceive payReceive) { boolean hasInitialFxNotional = notionalSchedule.getFxReset().isPresent() && notionalSchedule.getFxReset().get().getInitialNotionalValue().isPresent(); return index -> { if (hasInitialFxNotional && index == 0) { FxResetCalculation fxReset = notionalSchedule.getFxReset().get(); //If Fx reset leg with fixed initial notional then return the fixed amount in the payment currency double notional = payReceive.normalize(fxReset.getInitialNotionalValue().getAsDouble()); Currency currency = fxReset.getIndex().getCurrencyPair().other(fxReset.getReferenceCurrency()); return CurrencyAmount.of(currency, notional); } else { double notional = payReceive.normalize(notionals.get(index)); return CurrencyAmount.of(notionalSchedule.getCurrency(), notional); } }; }
FxResetCalculation.Builder fxResetBuilder = FxResetCalculation.builder(); fxResetBuilder.index(fxIndex); fxResetBuilder.referenceCurrency(notionalCurrencyOpt.orElse(fxIndex.getCurrencyPair().other(currency))); fxFixingRelativeToOpt.ifPresent(v -> fxResetBuilder.fixingRelativeTo(v)); fxResetAdjOpt.ifPresent(v -> fxResetBuilder.fixingDateOffset(v));
@Override public PointSensitivityBuilder ratePointSensitivity(FxIndexObservation observation, Currency baseCurrency) { ArgChecker.isTrue( index.getCurrencyPair().contains(baseCurrency), "Currency {} invalid for FxIndex {}", baseCurrency, index); LocalDate fixingDate = observation.getFixingDate(); if (fixingDate.isBefore(getValuationDate()) || (fixingDate.equals(getValuationDate()) && fixings.get(fixingDate).isPresent())) { return PointSensitivityBuilder.none(); } return FxIndexSensitivity.of(observation, baseCurrency, 1d); }