// resolve the FX rate sensitivity from the FX reset private PointSensitivityBuilder fxRateSensitivity(RatePaymentPeriod paymentPeriod, RatesProvider provider) { if (paymentPeriod.FxReset.Present) { FxReset fxReset = paymentPeriod.FxReset.get(); FxIndexRates rates = provider.fxIndexRates(fxReset.Observation.Index); return(rates.ratePointSensitivity(fxReset.Observation, fxReset.ReferenceCurrency)); } return(PointSensitivityBuilder.none()); }
//------------------------------------------------------------------------- // resolve the FX rate from the FX reset, returning an FX rate of 1 if not applicable private double fxRate(RatePaymentPeriod paymentPeriod, RatesProvider provider) { // inefficient to use Optional.orElse because double primitive type would be boxed if (paymentPeriod.FxReset.Present) { FxReset fxReset = paymentPeriod.FxReset.get(); FxIndexRates rates = provider.fxIndexRates(fxReset.Observation.Index); return(rates.rate(fxReset.Observation, fxReset.ReferenceCurrency)); } else { return(1d); } }
//------------------------------------------------------------------------- public virtual MultiCurrencyAmount currencyExposure(FxResetNotionalExchange @event, RatesProvider provider) { LocalDate fixingDate = @event.Observation.FixingDate; FxIndexRates rates = provider.fxIndexRates(@event.Observation.Index); double df = provider.discountFactor(@event.Currency, @event.PaymentDate); if (!fixingDate.isAfter(provider.ValuationDate) && rates.Fixings.get(fixingDate).HasValue) { double fxRate = rates.rate(@event.Observation, @event.ReferenceCurrency); return(MultiCurrencyAmount.of(CurrencyAmount.of(@event.Currency, @event.Notional * df * fxRate))); } LocalDate maturityDate = @event.Observation.MaturityDate; double fxRateSpotSensitivity = rates.FxForwardRates.rateFxSpotSensitivity(@event.ReferenceCurrency, maturityDate); return(MultiCurrencyAmount.of(CurrencyAmount.of(@event.ReferenceCurrency, @event.Notional * df * fxRateSpotSensitivity))); }
//------------------------------------------------------------------------- public virtual MultiCurrencyAmount currencyExposure(RatePaymentPeriod period, RatesProvider provider) { double df = provider.discountFactor(period.Currency, period.PaymentDate); if (period.FxReset.Present) { FxReset fxReset = period.FxReset.get(); LocalDate fixingDate = fxReset.Observation.FixingDate; FxIndexRates rates = provider.fxIndexRates(fxReset.Observation.Index); if (!fixingDate.isAfter(provider.ValuationDate) && rates.Fixings.get(fixingDate).HasValue) { double fxRate = rates.rate(fxReset.Observation, fxReset.ReferenceCurrency); return(MultiCurrencyAmount.of(period.Currency, accrualWithNotional(period, period.Notional * fxRate * df, provider))); } double fxRateSpotSensitivity = rates.FxForwardRates.rateFxSpotSensitivity(fxReset.ReferenceCurrency, fxReset.Observation.MaturityDate); return(MultiCurrencyAmount.of(fxReset.ReferenceCurrency, accrualWithNotional(period, period.Notional * fxRateSpotSensitivity * df, provider))); } return(MultiCurrencyAmount.of(period.Currency, accrualWithNotional(period, period.Notional * df, provider))); }
public virtual PointSensitivityBuilder forecastValueSensitivity(FxResetNotionalExchange @event, RatesProvider provider) { FxIndexRates rates = provider.fxIndexRates(@event.Observation.Index); return(rates.ratePointSensitivity(@event.Observation, @event.ReferenceCurrency).multipliedBy(@event.Notional)); }
// obtains the FX rate private double fxRate(FxResetNotionalExchange @event, RatesProvider provider) { FxIndexRates rates = provider.fxIndexRates(@event.Observation.Index); return(rates.rate(@event.Observation, @event.ReferenceCurrency)); }