public virtual void test_parSpread_ended() { ResolvedFxSingle fwd = ResolvedFxSingle.of(CurrencyAmount.of(USD, NOMINAL_USD), FxRate.of(USD, KRW, FX_RATE), PAYMENT_DATE_PAST); double spread = PRICER.parSpread(fwd, PROVIDER); assertEquals(spread, 0d, TOL); }
/// <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 virtual void test_presentValue_ended() { ResolvedFxSingle fwd = ResolvedFxSingle.of(CurrencyAmount.of(USD, NOMINAL_USD), FxRate.of(USD, KRW, FX_RATE), PAYMENT_DATE_PAST); MultiCurrencyAmount computed = PRICER.presentValue(fwd, PROVIDER); assertEquals(computed, MultiCurrencyAmount.empty()); }
/// <summary> /// Calculates the current cash. /// </summary> /// <param name="fx"> the product </param> /// <param name="valuationDate"> the valuation date </param> /// <returns> the current cash </returns> public virtual MultiCurrencyAmount currentCash(ResolvedFxSingle fx, LocalDate valuationDate) { if (valuationDate.isEqual(fx.PaymentDate)) { return(MultiCurrencyAmount.of(fx.BaseCurrencyPayment.Value, fx.CounterCurrencyPayment.Value)); } return(MultiCurrencyAmount.empty()); }
public virtual void test_parSpread() { double spread = PRICER.parSpread(FWD, PROVIDER); ResolvedFxSingle fwdSp = ResolvedFxSingle.of(CurrencyAmount.of(USD, NOMINAL_USD), FxRate.of(USD, KRW, FX_RATE + spread), PAYMENT_DATE); MultiCurrencyAmount pv = PRICER.presentValue(fwdSp, PROVIDER); assertEquals(pv.convertedTo(USD, PROVIDER).Amount, 0d, NOMINAL_USD * TOL); }
//------------------------------------------------------------------------- /// <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)); }
//------------------------------------------------------------------------- /// <summary> /// Calculates the par spread. /// <para> /// This is the spread that should be added to the FX points to have a zero value. /// /// </para> /// </summary> /// <param name="fx"> the product </param> /// <param name="provider"> the rates provider </param> /// <returns> the spread </returns> public virtual double parSpread(ResolvedFxSingle fx, RatesProvider provider) { Payment basePayment = fx.BaseCurrencyPayment; Payment counterPayment = fx.CounterCurrencyPayment; MultiCurrencyAmount pv = presentValue(fx, provider); double pvCounterCcy = pv.convertedTo(counterPayment.Currency, provider).Amount; double dfEnd = provider.discountFactor(counterPayment.Currency, fx.PaymentDate); double notionalBaseCcy = basePayment.Amount; return(pvCounterCcy / (notionalBaseCcy * dfEnd)); }
/// <summary> /// Calculates the present value curve sensitivity of the FX product. /// <para> /// The present value sensitivity of the product is the sensitivity of the present value to /// the underlying curves. /// /// </para> /// </summary> /// <param name="fx"> the product </param> /// <param name="provider"> the rates provider </param> /// <returns> the point sensitivity of the present value </returns> public virtual PointSensitivities presentValueSensitivity(ResolvedFxSingle fx, RatesProvider provider) { if (provider.ValuationDate.isAfter(fx.PaymentDate)) { return(PointSensitivities.empty()); } PointSensitivityBuilder pvcs1 = paymentPricer.presentValueSensitivity(fx.BaseCurrencyPayment, provider); PointSensitivityBuilder pvcs2 = paymentPricer.presentValueSensitivity(fx.CounterCurrencyPayment, provider); return(pvcs1.combinedWith(pvcs2).build()); }
//------------------------------------------------------------------------- /// <summary> /// Calculates the present value of the FX product by discounting each payment in its own currency. /// </summary> /// <param name="fx"> the product </param> /// <param name="provider"> the rates provider </param> /// <returns> the present value in the two natural currencies </returns> public virtual MultiCurrencyAmount presentValue(ResolvedFxSingle fx, RatesProvider provider) { if (provider.ValuationDate.isAfter(fx.PaymentDate)) { return(MultiCurrencyAmount.empty()); } CurrencyAmount pv1 = paymentPricer.presentValue(fx.BaseCurrencyPayment, provider); CurrencyAmount pv2 = paymentPricer.presentValue(fx.CounterCurrencyPayment, provider); return(MultiCurrencyAmount.of(pv1, pv2)); }
static VannaVolgaFxVanillaOptionProductPricerTest() { for (int i = 0; i < NB_STRIKES; ++i) { double strike = STRIKE_MIN + i * STRIKE_RANGE / (NB_STRIKES - 1d); CurrencyAmount eurAmount = CurrencyAmount.of(EUR, NOTIONAL); CurrencyAmount usdAmount = CurrencyAmount.of(USD, -NOTIONAL * strike); UNDERLYING[i] = ResolvedFxSingle.of(eurAmount, usdAmount, PAY); CALLS[i] = ResolvedFxVanillaOption.builder().longShort(LONG).expiry(EXPIRY).underlying(UNDERLYING[i]).build(); PUTS[i] = ResolvedFxVanillaOption.builder().longShort(SHORT).expiry(EXPIRY).underlying(UNDERLYING[i].inverse()).build(); } }
//------------------------------------------------------------------------- /// <summary> /// Calculates the currency exposure by discounting each payment in its own currency. /// </summary> /// <param name="product"> the product </param> /// <param name="provider"> the rates provider </param> /// <returns> the currency exposure </returns> public virtual MultiCurrencyAmount currencyExposure(ResolvedFxSingle product, RatesProvider provider) { return(presentValue(product, provider)); }