/** * Explains the present value of the swap trade. * <p> * This returns explanatory information about the calculation. * * @param trade the trade * @param provider the rates provider * @return the explanatory information */ public ExplainMap explainPresentValue(ResolvedSwapTrade trade, RatesProvider provider) { return productPricer.explainPresentValue(trade.getProduct(), provider); }
/** * Calculates the par spread of the swap trade. * <p> * This is spread to be added to the fixed rate to have a present value of 0. * * @param trade the trade * @param provider the rates provider * @return the par spread */ public double parSpread(ResolvedSwapTrade trade, RatesProvider provider) { return productPricer.parSpread(trade.getProduct(), provider); }
/** * Calculates the current cash of the swap trade. * * @param trade the trade * @param provider the rates provider * @return the current cash of the swap trade */ public MultiCurrencyAmount currentCash(ResolvedSwapTrade trade, RatesProvider provider) { return productPricer.currentCash(trade.getProduct(), provider); }
/** * Calculates the currency exposure of the swap trade. * * @param trade the trade * @param provider the rates provider * @return the currency exposure of the swap trade */ public MultiCurrencyAmount currencyExposure(ResolvedSwapTrade trade, RatesProvider provider) { return productPricer.currencyExposure(trade.getProduct(), provider); }
/** * Calculates the future cash flows of the swap trade. * <p> * Each expected cash flow is added to the result. * This is based on {@link #forecastValue(ResolvedSwapTrade, RatesProvider)}. * * @param trade the trade * @param provider the rates provider * @return the cash flows */ public CashFlows cashFlows(ResolvedSwapTrade trade, RatesProvider provider) { return productPricer.cashFlows(trade.getProduct(), provider); }
/** * 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 trade the trade * @param provider the rates provider * @return the accrued interest */ public MultiCurrencyAmount accruedInterest(ResolvedSwapTrade trade, RatesProvider provider) { return productPricer.accruedInterest(trade.getProduct(), provider); }
/** * Restricted copy constructor. * @param beanToCopy the bean to copy from, not null */ private Builder(ResolvedSwapTrade beanToCopy) { this.info = beanToCopy.getInfo(); this.product = beanToCopy.getProduct(); }
/** * Calculates the par rate of the swap trade. * <p> * The par rate is the rate for which the swap present value is 0. * * @param trade the trade * @param provider the rates provider * @return the par rate */ public double parRate(ResolvedSwapTrade trade, RatesProvider provider) { return productPricer.parRate(trade.getProduct(), provider); }
@Override protected Object propertyGet(Bean bean, String propertyName, boolean quiet) { switch (propertyName.hashCode()) { case 3237038: // info return ((ResolvedSwapTrade) bean).getInfo(); case -309474065: // product return ((ResolvedSwapTrade) bean).getProduct(); } return super.propertyGet(bean, propertyName, quiet); }
/** * Calculates the present value sensitivity of the swap trade. * <p> * The present value sensitivity of the trade is the sensitivity of the present value to * the underlying curves. * * @param trade the trade * @param provider the rates provider * @return the present value curve sensitivity of the swap trade */ public PointSensitivities presentValueSensitivity(ResolvedSwapTrade trade, RatesProvider provider) { return productPricer.presentValueSensitivity(trade.getProduct(), provider).build(); }
/** * Calculates the par rate curve sensitivity of the swap trade. * <p> * The par rate curve sensitivity of the product is the sensitivity of the par rate to * the underlying curves. * * @param trade the trade * @param provider the rates provider * @return the par rate sensitivity */ public PointSensitivities parRateSensitivity(ResolvedSwapTrade trade, RatesProvider provider) { return productPricer.parRateSensitivity(trade.getProduct(), provider).build(); }
/** * Calculates the forecast value sensitivity of the swap trade. * <p> * The forecast value sensitivity of the trade is the sensitivity of the forecast value to * the underlying curves. * * @param trade the trade * @param provider the rates provider * @return the forecast value curve sensitivity of the swap trade */ public PointSensitivities forecastValueSensitivity(ResolvedSwapTrade trade, RatesProvider provider) { return productPricer.forecastValueSensitivity(trade.getProduct(), provider).build(); }
/** * Calculates the par spread curve sensitivity of the swap trade. * <p> * The par spread curve sensitivity of the product is the sensitivity of the par spread to * the underlying curves. * * @param trade the trade * @param provider the rates provider * @return the par spread sensitivity */ public PointSensitivities parSpreadSensitivity(ResolvedSwapTrade trade, RatesProvider provider) { return productPricer.parSpreadSensitivity(trade.getProduct(), provider).build(); }
public void test_of() { ResolvedSwapTrade test = ResolvedSwapTrade.of(TRADE_INFO, SWAP1); assertEquals(test.getProduct(), SWAP1); assertEquals(test.getInfo(), TRADE_INFO); }
public void test_resolve() { SwapTrade test = SwapTrade.of(TRADE_INFO, SWAP1); assertEquals(test.resolve(REF_DATA).getInfo(), TRADE_INFO); assertEquals(test.resolve(REF_DATA).getProduct(), SWAP1.resolve(REF_DATA)); }
public void test_builder() { ResolvedSwapTrade test = ResolvedSwapTrade.builder() .product(SWAP1) .build(); assertEquals(test.getInfo(), TradeInfo.empty()); assertEquals(test.getProduct(), SWAP1); }
public void test_parSpreadSensitivity_fixedInflation() { ResolvedSwapTrade tradeZc = SWAP_GBP_ZC_INFLATION_5Y.resolve(REF_DATA); PointSensitivities point = SWAP_PRODUCT_PRICER.parSpreadSensitivity(tradeZc.getProduct(), RATES_GBP_INFLATION).build(); CurrencyParameterSensitivities prAd = RATES_GBP_INFLATION.parameterSensitivity(point); CurrencyParameterSensitivities prFd = FINITE_DIFFERENCE_CALCULATOR.sensitivity( RATES_GBP_INFLATION, p -> CurrencyAmount.of(GBP, SWAP_PRODUCT_PRICER.parSpread(tradeZc.getProduct(), p))); assertTrue(prAd.equalWithTolerance(prFd, TOLERANCE_RATE_DELTA)); // trade v product DiscountingSwapTradePricer pricerTrade = DiscountingSwapTradePricer.DEFAULT; DiscountingSwapProductPricer pricerSwap = DiscountingSwapProductPricer.DEFAULT; assertEquals( pricerTrade.parSpreadSensitivity(tradeZc, RATES_GBP_INFLATION), pricerSwap.parSpreadSensitivity(tradeZc.getProduct(), RATES_GBP_INFLATION).build()); }
public void test_parSpread_fixedInflation() { ResolvedSwapTrade tradeZc = SWAP_GBP_ZC_INFLATION_5Y.resolve(REF_DATA); double ps = SWAP_PRODUCT_PRICER.parSpread(tradeZc.getProduct(), RATES_GBP_INFLATION); SwapTrade swap0 = FixedInflationSwapConventions.GBP_FIXED_ZC_GB_RPI .createTrade(VAL_DATE_INFLATION, TENOR_5Y, BUY, NOTIONAL_SWAP, FIXED_RATE + ps, REF_DATA); CurrencyAmount pv0 = SWAP_PRODUCT_PRICER.presentValue(swap0.getProduct().resolve(REF_DATA), GBP, RATES_GBP_INFLATION); assertEquals(pv0.getAmount(), 0, TOLERANCE_PV); }
public void test_parSpreadSensitivity_iborCmpIbor_1Period() { ResolvedSwap swap = USD_LIBOR_3M_LIBOR_6M .createTrade(MULTI_USD.getValuationDate(), Tenor.TENOR_6M, BUY, NOTIONAL_SWAP, SPREAD, REF_DATA).resolve(REF_DATA).getProduct(); PointSensitivities point = SWAP_PRODUCT_PRICER.parSpreadSensitivity(swap, MULTI_USD).build(); CurrencyParameterSensitivities prAd = MULTI_USD.parameterSensitivity(point); CurrencyParameterSensitivities prFd = FINITE_DIFFERENCE_CALCULATOR.sensitivity( MULTI_USD, p -> CurrencyAmount.of(USD, SWAP_PRODUCT_PRICER.parSpread(swap, p))); assertTrue(prAd.equalWithTolerance(prFd, TOLERANCE_RATE_DELTA)); }
public void test_parSpreadSensitivity_iborCmpIbor() { ResolvedSwap swap = USD_LIBOR_3M_LIBOR_6M .createTrade(MULTI_USD.getValuationDate(), TENOR_5Y, BUY, NOTIONAL_SWAP, SPREAD, REF_DATA).resolve(REF_DATA).getProduct(); PointSensitivities point = SWAP_PRODUCT_PRICER.parSpreadSensitivity(swap, MULTI_USD).build(); CurrencyParameterSensitivities prAd = MULTI_USD.parameterSensitivity(point); CurrencyParameterSensitivities prFd = FINITE_DIFFERENCE_CALCULATOR.sensitivity( MULTI_USD, p -> CurrencyAmount.of(USD, SWAP_PRODUCT_PRICER.parSpread(swap, p))); assertTrue(prAd.equalWithTolerance(prFd, TOLERANCE_RATE_DELTA)); }