public void emptyAmounts() { MultiCurrencyScenarioArray array = MultiCurrencyScenarioArray.of( MultiCurrencyAmount.empty(), MultiCurrencyAmount.empty()); assertThat(array.getScenarioCount()).isEqualTo(2); assertThat(array.get(0)).isEqualTo(MultiCurrencyAmount.empty()); assertThat(array.get(1)).isEqualTo(MultiCurrencyAmount.empty()); }
public void test_currencyExposure_afterExpiry() { for (ResolvedFxSingleBarrierOption option : OPTION_ALL) { MultiCurrencyAmount computed = PRICER.currencyExposure(option, RATE_PROVIDER_AFTER, VOLS_AFTER); assertEquals(computed, MultiCurrencyAmount.empty()); } }
public void test_empty_amounts() { MultiCurrencyAmountArray array = MultiCurrencyAmountArray.of( MultiCurrencyAmount.empty(), MultiCurrencyAmount.empty()); assertThat(array.size()).isEqualTo(2); assertThat(array.get(0)).isEqualTo(MultiCurrencyAmount.empty()); assertThat(array.get(1)).isEqualTo(MultiCurrencyAmount.empty()); }
public void test_currencyExposure_atExpiry() { for (int i = 0; i < NB_STRIKES; ++i) { MultiCurrencyAmount computedCall = PRICER.currencyExposure(CALLS[i], RATES_PROVIDER_AFTER, VOLS_AFTER); assertEquals(computedCall, MultiCurrencyAmount.empty()); MultiCurrencyAmount computedPut = PRICER.currencyExposure(PUTS[i], RATES_PROVIDER_AFTER, VOLS_AFTER); assertEquals(computedPut, MultiCurrencyAmount.empty()); } }
/** * Calculates the currency exposure of the swap product. * * @param swap the product * @param provider the rates provider * @return the currency exposure of the swap product */ public MultiCurrencyAmount currencyExposure(ResolvedSwap swap, RatesProvider provider) { MultiCurrencyAmount ce = MultiCurrencyAmount.empty(); for (ResolvedSwapLeg leg : swap.getLegs()) { ce = ce.plus(legPricer.currencyExposure(leg, provider)); } return ce; }
public void test_empty() { assertMCA(MultiCurrencyAmount.empty()); }
/** * Calculates the current cash of the swap product. * * @param swap the product * @param provider the rates provider * @return the current cash of the swap product */ public MultiCurrencyAmount currentCash(ResolvedSwap swap, RatesProvider provider) { MultiCurrencyAmount ce = MultiCurrencyAmount.empty(); for (ResolvedSwapLeg leg : swap.getLegs()) { ce = ce.plus(legPricer.currentCash(leg, provider)); } return ce; }
/** * Calculates the accrued interest since the last payment. * <p> * This determines the payment period applicable at the valuation date and calculates * the accrued interest since the last payment. * * @param swap the product * @param provider the rates provider * @return the accrued interest of the swap product */ public MultiCurrencyAmount accruedInterest(ResolvedSwap swap, RatesProvider provider) { MultiCurrencyAmount result = MultiCurrencyAmount.empty(); for (ResolvedSwapLeg leg : swap.getLegs()) { result = result.plus(legPricer.accruedInterest(leg, provider)); } return result; }
public void createByFunctionEmptyAmounts() { MultiCurrencyScenarioArray test = MultiCurrencyScenarioArray.of(3, i -> MultiCurrencyAmount.empty()); assertThat(test.getScenarioCount()).isEqualTo(3); }
public void test_of_function_empty_amounts() { MultiCurrencyAmountArray test = MultiCurrencyAmountArray.of(3, i -> MultiCurrencyAmount.empty()); assertThat(test.size()).isEqualTo(3); }
public void test_currentCash_zero() { MultiCurrencyAmount computed = PRICER.currentCash(SWAP_PRODUCT, PROVIDER.getValuationDate()); assertEquals(computed, MultiCurrencyAmount.empty()); }
public void serializeSize() throws Exception { MultiCurrencyAmountArray deserialized = serializedDeserialize(VALUES_ARRAY); assertThat(deserialized.size()).isEqualTo(3); MultiCurrencyAmountArray empty = MultiCurrencyAmountArray.of( MultiCurrencyAmount.empty(), MultiCurrencyAmount.empty()); MultiCurrencyAmountArray deserializedEmpty = serializedDeserialize(empty); assertThat(deserializedEmpty.size()).isEqualTo(2); }
public void test_currentCash_zero() { MultiCurrencyAmount computed = PRICER.currentCash(FWD, PROVIDER.getValuationDate()); assertEquals(computed, MultiCurrencyAmount.empty()); }
private MultiCurrencyAmount currencyExposureEventsInternal(ResolvedSwapLeg leg, RatesProvider provider) { MultiCurrencyAmount total = MultiCurrencyAmount.empty(); for (SwapPaymentEvent event : leg.getPaymentEvents()) { if (!event.getPaymentDate().isBefore(provider.getValuationDate())) { total = total.plus(paymentEventPricer.currencyExposure(event, provider)); } } return total; }
private MultiCurrencyAmount currencyExposurePeriodsInternal(ResolvedSwapLeg leg, RatesProvider provider) { MultiCurrencyAmount total = MultiCurrencyAmount.empty(); for (SwapPaymentPeriod period : leg.getPaymentPeriods()) { if (!period.getPaymentDate().isBefore(provider.getValuationDate())) { total = total.plus(paymentPeriodPricer.currencyExposure(period, provider)); } } return total; }
public void test_presentValue_ended() { ResolvedFxSwap product = ResolvedFxSwap.ofForwardPoints( CurrencyAmount.of(USD, NOMINAL_USD), KRW, FX_RATE, FX_FWD_POINTS, PAYMENT_DATE_LONG_PAST, PAYMENT_DATE_PAST); MultiCurrencyAmount computed = PRICER.presentValue(product, PROVIDER); assertEquals(computed, MultiCurrencyAmount.empty()); // currency exposure MultiCurrencyAmount exposure = PRICER.currencyExposure(product, PROVIDER); assertEquals(exposure, computed); }
/** * Calculates the current cash. * * @param fx the product * @param valuationDate the valuation date * @return the current cash */ public MultiCurrencyAmount currentCash(ResolvedFxSingle fx, LocalDate valuationDate) { if (valuationDate.isEqual(fx.getPaymentDate())) { return MultiCurrencyAmount.of(fx.getBaseCurrencyPayment().getValue(), fx.getCounterCurrencyPayment().getValue()); } return MultiCurrencyAmount.empty(); }
public 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()); }
/** * Calculates the present value of the FX product by discounting each payment in its own currency. * * @param fx the product * @param provider the rates provider * @return the present value in the two natural currencies */ public MultiCurrencyAmount presentValue(ResolvedFxSingle fx, RatesProvider provider) { if (provider.getValuationDate().isAfter(fx.getPaymentDate())) { return MultiCurrencyAmount.empty(); } CurrencyAmount pv1 = paymentPricer.presentValue(fx.getBaseCurrencyPayment(), provider); CurrencyAmount pv2 = paymentPricer.presentValue(fx.getCounterCurrencyPayment(), provider); return MultiCurrencyAmount.of(pv1, pv2); }
/** * Calculates the currency exposure by discounting each payment in its own currency. * * @param ndf the product * @param provider the rates provider * @return the currency exposure */ public MultiCurrencyAmount currencyExposure(ResolvedFxNdf ndf, RatesProvider provider) { if (provider.getValuationDate().isAfter(ndf.getPaymentDate())) { return MultiCurrencyAmount.empty(); } Currency ccySettle = ndf.getSettlementCurrency(); CurrencyAmount notionalSettle = ndf.getSettlementCurrencyNotional(); double dfSettle = provider.discountFactor(ccySettle, ndf.getPaymentDate()); Currency ccyOther = ndf.getNonDeliverableCurrency(); double agreedRate = ndf.getAgreedFxRate().fxRate(ccySettle, ccyOther); double dfOther = provider.discountFactor(ccyOther, ndf.getPaymentDate()); return MultiCurrencyAmount.of(notionalSettle.multipliedBy(dfSettle)) .plus(CurrencyAmount.of(ccyOther, -notionalSettle.getAmount() * agreedRate * dfOther)); }