/// <summary> /// Calculates the sensitivity of the forward exchange rate to the spot rate. /// <para> /// The returned value is based on the direction of the FX product. /// /// </para> /// </summary> /// <param name="fx"> the product </param> /// <param name="provider"> the rates provider </param> /// <returns> the sensitivity to spot </returns> public virtual double forwardFxRateSpotSensitivity(ResolvedFxSingle fx, RatesProvider provider) { FxForwardRates fxForwardRates = provider.fxForwardRates(fx.CurrencyPair); double forwardRateSpotSensitivity = fxForwardRates.rateFxSpotSensitivity(fx.ReceiveCurrencyAmount.Currency, fx.PaymentDate); return(forwardRateSpotSensitivity); }
//------------------------------------------------------------------------- public FxIndexRates fxIndexRates(FxIndex index) { LocalDateDoubleTimeSeries fixings = timeSeries(index); FxForwardRates fxForwardRates = this.fxForwardRates(index.CurrencyPair); return(ForwardFxIndexRates.of(index, fxForwardRates, fixings)); }
//------------------------------------------------------------------------- /// <summary> /// Calculates the forward exchange rate. /// </summary> /// <param name="fx"> the product </param> /// <param name="provider"> the rates provider </param> /// <returns> the forward rate </returns> public virtual FxRate forwardFxRate(ResolvedFxSingle fx, RatesProvider provider) { FxForwardRates fxForwardRates = provider.fxForwardRates(fx.CurrencyPair); Payment basePayment = fx.BaseCurrencyPayment; Payment counterPayment = fx.CounterCurrencyPayment; double forwardRate = fxForwardRates.rate(basePayment.Currency, fx.PaymentDate); return(FxRate.of(basePayment.Currency, counterPayment.Currency, forwardRate)); }
private ForwardFxIndexRates(FxIndex index, FxForwardRates fxForwardRates, LocalDateDoubleTimeSeries fixings) { JodaBeanUtils.notNull(index, "index"); JodaBeanUtils.notNull(fxForwardRates, "fxForwardRates"); JodaBeanUtils.notNull(fixings, "fixings"); this.index = index; this.fxForwardRates = fxForwardRates; this.fixings = fixings; validate(); }
public override Builder set(string propertyName, object newValue) { switch (propertyName.GetHashCode()) { case 100346066: // index this.index = (FxIndex)newValue; break; case -1002932800: // fxForwardRates this.fxForwardRates = (FxForwardRates)newValue; break; case -843784602: // fixings this.fixings = (LocalDateDoubleTimeSeries)newValue; break; default: throw new NoSuchElementException("Unknown property: " + propertyName); } return(this); }
/// <summary> /// Obtains an instance based on discount factors and historic fixings. /// <para> /// The instance is based on the discount factors for each currency. /// /// </para> /// </summary> /// <param name="index"> the index </param> /// <param name="fxForwardRates"> the underlying forward FX rates </param> /// <param name="fixings"> the time-series of fixings </param> /// <returns> the rates instance </returns> public static ForwardFxIndexRates of(FxIndex index, FxForwardRates fxForwardRates, LocalDateDoubleTimeSeries fixings) { return(new ForwardFxIndexRates(index, fxForwardRates, fixings)); }
//------------------------------------------------------------------------- /// <summary> /// Obtains an instance based on discount factors with no historic fixings. /// <para> /// The instance is based on the discount factors for each currency. /// /// </para> /// </summary> /// <param name="index"> the index </param> /// <param name="fxForwardRates"> the underlying forward FX rates </param> /// <returns> the rates instance </returns> public static ForwardFxIndexRates of(FxIndex index, FxForwardRates fxForwardRates) { return(of(index, fxForwardRates, LocalDateDoubleTimeSeries.empty())); }
//------------------------------------------------------------------------- /// <summary> /// Returns a new instance with different FX forward rates. /// </summary> /// <param name="fxForwardRates"> the new FX forward rates </param> /// <returns> the new instance </returns> public ForwardFxIndexRates withFxForwardRates(FxForwardRates fxForwardRates) { return(new ForwardFxIndexRates(index, fxForwardRates, fixings)); }