/** * Gets the currency of the payment. * <p> * This simply returns {@code getValue().getCurrency()}. * * @return the currency of the payment */ public Currency getCurrency() { return value.getCurrency(); }
/** * Gets the currency of this payment. * * @return the payment currency */ public Currency getCurrency() { return value.getCurrency(); }
/** * Converts an amount to a string. * * @param currencyAmount the amount * @return the string form */ public static String amount(CurrencyAmount currencyAmount) { return amount(currencyAmount.getCurrency(), currencyAmount.getAmount()); }
public void test_presentValue_afterPay() { CurrencyAmount computedCaplet = PRICER.presentValue(CAPLET_LONG, RATES_AFTER_PAY, VOLS_AFTER_PAY); CurrencyAmount computedFloorlet = PRICER.presentValue(FLOORLET_SHORT, RATES_AFTER_PAY, VOLS_AFTER_PAY); assertEquals(computedCaplet.getCurrency(), EUR); assertEquals(computedCaplet.getAmount(), 0d, NOTIONAL * TOL); assertEquals(computedFloorlet.getCurrency(), EUR); assertEquals(computedFloorlet.getAmount(), 0d, NOTIONAL * TOL); }
public void test_presentValueTheta_afterFix() { CurrencyAmount computedCaplet = PRICER.presentValueTheta(CAPLET_LONG, RATES_AFTER_FIX, VOLS_AFTER_FIX); CurrencyAmount computedFloorlet = PRICER.presentValueTheta(FLOORLET_SHORT, RATES_AFTER_FIX, VOLS_AFTER_FIX); assertEquals(computedCaplet.getCurrency(), EUR); assertEquals(computedCaplet.getAmount(), 0d, TOL); assertEquals(computedFloorlet.getCurrency(), EUR); assertEquals(computedFloorlet.getAmount(), 0d, TOL); }
public void test_presentValue_afterPay() { CurrencyAmount computedCaplet = PRICER.presentValue(CAPLET_LONG, RATES_AFTER_PAY, VOLS_AFTER_PAY); CurrencyAmount computedFloorlet = PRICER.presentValue(FLOORLET_SHORT, RATES_AFTER_PAY, VOLS_AFTER_PAY); assertEquals(computedCaplet.getCurrency(), EUR); assertEquals(computedCaplet.getAmount(), 0d, NOTIONAL * TOL); assertEquals(computedFloorlet.getCurrency(), EUR); assertEquals(computedFloorlet.getAmount(), 0d, NOTIONAL * TOL); }
public void test_presentValueTheta_afterFix() { CurrencyAmount computedCaplet = PRICER.presentValueTheta(CAPLET_LONG, RATES_AFTER_FIX, VOLS_AFTER_FIX); CurrencyAmount computedFloorlet = PRICER.presentValueTheta(FLOORLET_SHORT, RATES_AFTER_FIX, VOLS_AFTER_FIX); assertEquals(computedCaplet.getCurrency(), EUR); assertEquals(computedCaplet.getAmount(), 0d, TOL); assertEquals(computedFloorlet.getCurrency(), EUR); assertEquals(computedFloorlet.getAmount(), 0d, TOL); }
@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"); } }
public void test_currentCash() { CurrencyAmount capComputed = PRICER.currentCash(CAP, RATES, VOLS); CurrencyAmount floorComputed = PRICER.currentCash(FLOOR, RATES, VOLS); assertEquals(capComputed.getCurrency(), EUR); assertEquals(capComputed.getAmount(), 0d); assertEquals(floorComputed.getCurrency(), EUR); assertEquals(floorComputed.getAmount(), 0d); }
public void test_currentCash() { CurrencyAmount capComputed = PRICER.currentCash(CAP, RATES, VOLS); CurrencyAmount floorComputed = PRICER.currentCash(FLOOR, RATES, VOLS); assertEquals(capComputed.getCurrency(), EUR); assertEquals(capComputed.getAmount(), 0d); assertEquals(floorComputed.getCurrency(), EUR); assertEquals(floorComputed.getAmount(), 0d); }
public void test_presentValueTheta_onFix() { CurrencyAmount computedCaplet = PRICER.presentValueTheta(CAPLET_LONG, RATES_ON_FIX, VOLS_ON_FIX); CurrencyAmount computedFloorlet = PRICER.presentValueTheta(FLOORLET_SHORT, RATES_ON_FIX, VOLS_ON_FIX); double expectedCaplet = 0d; double expectedFloorlet = 0d; assertEquals(computedCaplet.getCurrency(), EUR); assertEquals(computedCaplet.getAmount(), expectedCaplet, TOL); assertEquals(computedFloorlet.getCurrency(), EUR); assertEquals(computedFloorlet.getAmount(), expectedFloorlet, TOL); }
public void test_presentValue_afterFix() { CurrencyAmount computedCaplet = PRICER.presentValue(CAPLET_LONG, RATES_AFTER_FIX, VOLS_AFTER_FIX); CurrencyAmount computedFloorlet = PRICER.presentValue(FLOORLET_SHORT, RATES_AFTER_FIX, VOLS_AFTER_FIX); double payoff = (OBS_INDEX - STRIKE) * PRICER_COUPON.presentValue(FIXED_COUPON_UNIT, RATES_AFTER_FIX); assertEquals(computedCaplet.getCurrency(), EUR); assertEquals(computedCaplet.getAmount(), payoff, NOTIONAL * TOL); assertEquals(computedFloorlet.getCurrency(), EUR); assertEquals(computedFloorlet.getAmount(), 0d, NOTIONAL * TOL); }
public void test_presentValue_afterFix() { CurrencyAmount computedCaplet = PRICER.presentValue(CAPLET_LONG, RATES_AFTER_FIX, VOLS_AFTER_FIX); CurrencyAmount computedFloorlet = PRICER.presentValue(FLOORLET_SHORT, RATES_AFTER_FIX, VOLS_AFTER_FIX); double payoff = (OBS_INDEX - STRIKE) * PRICER_COUPON.presentValue(FIXED_COUPON_UNIT, RATES_AFTER_FIX); assertEquals(computedCaplet.getCurrency(), EUR); assertEquals(computedCaplet.getAmount(), payoff, NOTIONAL * TOL); assertEquals(computedFloorlet.getCurrency(), EUR); assertEquals(computedFloorlet.getAmount(), 0d, NOTIONAL * TOL); }
public void test_presentValueDelta_onFix() { CurrencyAmount computedCaplet = PRICER.presentValueDelta(CAPLET_LONG, RATES_ON_FIX, VOLS_ON_FIX); CurrencyAmount computedFloorlet = PRICER.presentValueDelta(FLOORLET_SHORT, RATES_ON_FIX, VOLS_ON_FIX); double expectedCaplet = PRICER_COUPON.presentValue(FIXED_COUPON_UNIT, RATES_ON_FIX); double expectedFloorlet = 0d; assertEquals(computedCaplet.getCurrency(), EUR); assertEquals(computedCaplet.getAmount(), expectedCaplet, TOL); assertEquals(computedFloorlet.getCurrency(), EUR); assertEquals(computedFloorlet.getAmount(), expectedFloorlet, TOL); }
public void test_presentValue() { CurrencyAmount computed = OPTION_TRADE_PRICER.presentValue(OPTION_TRADE, RATE_PROVIDER, VOLS, REFERENCE_PRICE); double expected = (OPTION_PRODUCT_PRICER.price(OPTION_PRODUCT, RATE_PROVIDER, VOLS) - REFERENCE_PRICE) * NOTIONAL * QUANTITY; assertEquals(computed.getCurrency(), Currency.EUR); assertEquals(computed.getAmount(), expected, TOL * NOTIONAL * QUANTITY); }
public void test_explainPresentValue_provider_ended() { ExplainMap explain = PRICER.explainPresentValue(PAYMENT_PAST, PROVIDER); Currency currency = PAYMENT_PAST.getCurrency(); assertEquals(explain.get(ExplainKey.ENTRY_TYPE).get(), "Payment"); assertEquals(explain.get(ExplainKey.PAYMENT_DATE).get(), PAYMENT_PAST.getDate()); assertEquals(explain.get(ExplainKey.PAYMENT_CURRENCY).get(), currency); assertEquals(explain.get(ExplainKey.FORECAST_VALUE).get().getCurrency(), currency); assertEquals(explain.get(ExplainKey.FORECAST_VALUE).get().getAmount(), 0, TOL); assertEquals(explain.get(ExplainKey.PRESENT_VALUE).get().getCurrency(), currency); assertEquals(explain.get(ExplainKey.PRESENT_VALUE).get().getAmount(), 0, TOL); }
public void test_presentValue_afterPay() { CurrencyAmount computed = LEG_PRICER.presentValue(FLOOR_LEG, RATES_PROVIDER_AFTER_PERIOD, VOLATILITIES_AFTER_PERIOD); double expected = 0d; List<CmsPeriod> cms = FLOOR_LEG.getCmsPeriods(); int size = cms.size(); for (int i = 1; i < size; ++i) { expected += PERIOD_PRICER.presentValue( cms.get(i), RATES_PROVIDER_AFTER_PERIOD, VOLATILITIES_AFTER_PERIOD).getAmount(); } assertEquals(computed.getCurrency(), EUR); assertEquals(computed.getAmount(), expected, NOTIONAL_VALUE_0 * TOL); }
public void present_value_theta_formula() { double forward = PRICER_SWAP.parRate(RSWAP_REC, MULTI_USD); double pvbp = PRICER_SWAP.getLegPricer().pvbp(RSWAP_REC.getLegs(SwapLegType.FIXED).get(0), MULTI_USD); double volatility = BLACK_VOLS_USD_STD.volatility(SWAPTION_LONG_REC.getExpiry(), SWAP_TENOR_YEAR, STRIKE, forward); double expiry = BLACK_VOLS_USD_STD.relativeTime(SWAPTION_LONG_REC.getExpiry()); double pvThetaExpected = BlackFormulaRepository.driftlessTheta(forward, STRIKE, expiry, volatility) * Math.abs(pvbp); CurrencyAmount pvThetaComputed = PRICER_SWAPTION_BLACK.presentValueTheta(SWAPTION_LONG_REC, MULTI_USD, BLACK_VOLS_USD_STD); assertEquals(pvThetaComputed.getCurrency(), USD); assertEquals(pvThetaComputed.getAmount(), pvThetaExpected, TOLERANCE_PV); }
public void test_presentValue_inverse() { CurrencyAmount computed = PRICER.presentValue(NDF_INVERSE, PROVIDER); double dscUsd = PROVIDER.discountFactor(USD, NDF_INVERSE.getPaymentDate()); double dscKrw = PROVIDER.discountFactor(KRW, NDF_INVERSE.getPaymentDate()); double expected = NOMINAL_USD * FX_RATE * (dscKrw - dscUsd * 1 / FX_RATE / PROVIDER.fxRate(CurrencyPair.of(KRW, USD))); assertEquals(computed.getCurrency(), KRW); assertEquals(computed.getAmount(), expected, NOMINAL_USD * FX_RATE * TOL); }
public void test_presentValueFromCleanPrice() { double cleanPrice = 0.985; CurrencyAmount computed = TRADE_PRICER.presentValueFromCleanPrice(TRADE, PROVIDER, REF_DATA, cleanPrice); LocalDate standardSettlement = PRODUCT.getSettlementDateOffset().adjust(VAL_DATE, REF_DATA); double df = ZeroRateDiscountFactors.of(EUR, VAL_DATE, CURVE_REPO).discountFactor(standardSettlement); double accruedInterest = PRODUCT_PRICER.accruedInterest(PRODUCT, standardSettlement); double pvPayment = PRICER_NOMINAL .presentValue(UPFRONT_PAYMENT, ZeroRateDiscountFactors.of(EUR, VAL_DATE, CURVE_REPO)).getAmount(); double expected = QUANTITY * (cleanPrice * df * NOTIONAL + accruedInterest * df) + pvPayment; assertEquals(computed.getCurrency(), EUR); assertEquals(computed.getAmount(), expected, NOTIONAL * QUANTITY * TOL); }