/** * 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); }
/** * Restricted copy constructor. * @param beanToCopy the bean to copy from, not null */ private Builder(ResolvedSwapTrade beanToCopy) { this.info = beanToCopy.getInfo(); this.product = beanToCopy.getProduct(); }
/** * Obtains an instance of a resolved Swap trade. * * @param info the trade info * @param product the product * @return the resolved trade */ public static ResolvedSwapTrade of(TradeInfo info, ResolvedSwap product) { return new ResolvedSwapTrade(info, product); }
public void test_of() { ResolvedSwapTrade test = ResolvedSwapTrade.of(TRADE_INFO, SWAP1); assertEquals(test.getProduct(), SWAP1); assertEquals(test.getInfo(), TRADE_INFO); }
public void test_builder() { ResolvedSwapTrade test = ResolvedSwapTrade.builder() .product(SWAP1) .build(); assertEquals(test.getInfo(), TradeInfo.empty()); assertEquals(test.getProduct(), SWAP1); }
public void test_serialization() { ResolvedSwapTrade test = ResolvedSwapTrade.builder() .info(TradeInfo.of(date(2014, 6, 30))) .product(SWAP1) .build(); assertSerialization(test); }
/** * 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); }
@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); }
@Override public ResolvedSwapTrade build() { return new ResolvedSwapTrade( info, product); }
/** * 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); }
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)); }
@Override public ResolvedSwapTrade resolve(ReferenceData refData) { return new ResolvedSwapTrade(info, product.resolve(refData)); }
/** * 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); }
/** * 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); }
/** * Calculates the forecast value of the swap trade. * <p> * The forecast value of the trade is the value on the valuation date without present value discounting. * The result is expressed using the payment currency of each leg. * * @param trade the trade * @param provider the rates provider * @return the forecast value of the swap trade */ public MultiCurrencyAmount forecastValue(ResolvedSwapTrade trade, RatesProvider provider) { return productPricer.forecastValue(trade.getProduct(), provider); }
/** * Calculates the present value of the swap trade. * <p> * The present value of the trade is the value on the valuation date. * This is the discounted forecast value. * The result is expressed using the payment currency of each leg. * * @param trade the trade * @param provider the rates provider * @return the present value of the swap trade */ public MultiCurrencyAmount presentValue(ResolvedSwapTrade trade, RatesProvider provider) { return productPricer.presentValue(trade.getProduct(), provider); }
/** * Calculates the present value of the swap trade, converted to the specified currency. * <p> * The present value of the trade is the value on the valuation date. * This is the discounted forecast value. * The result is converted to the specified currency. * * @param trade the trade * @param currency the currency to convert to * @param provider the rates provider * @return the present value of the swap trade in the specified currency */ public CurrencyAmount presentValue(ResolvedSwapTrade trade, Currency currency, RatesProvider provider) { return productPricer.presentValue(trade.getProduct(), currency, provider); }