@Override
 public ScenarioResult<T> execute(TermDepositTrade trade, CalculationMarketData marketData) {
   ExpandedTermDeposit product = trade.getProduct().expand();
   return IntStream.range(0, marketData.getScenarioCount())
       .mapToObj(index -> new SingleCalculationMarketData(marketData, index))
       .map(MarketDataRatesProvider::new)
       .map(provider -> execute(product, provider))
       .collect(toScenarioResult(isConvertCurrencies()));
 }
  @Override
  public FunctionRequirements requirements(TermDepositTrade trade) {
    TermDeposit deposit = trade.getProduct();

    Set<DiscountCurveKey> discountCurveKeys =
        ImmutableSet.of(DiscountCurveKey.of(deposit.getCurrency()));

    return FunctionRequirements.builder()
        .singleValueRequirements(discountCurveKeys)
        .timeSeriesRequirements()
        .outputCurrencies(deposit.getCurrency())
        .build();
  }
Пример #3
0
 public void test_trade() {
   TermDepositCurveNode node = TermDepositCurveNode.of(TEMPLATE, QUOTE_ID, SPREAD);
   double rate = 0.035;
   MarketData marketData = ImmutableMarketData.builder(VAL_DATE).addValue(QUOTE_ID, rate).build();
   TermDepositTrade trade = node.trade(1d, marketData, REF_DATA);
   LocalDate startDateExpected = PLUS_TWO_DAYS.adjust(VAL_DATE, REF_DATA);
   LocalDate endDateExpected = startDateExpected.plus(DEPOSIT_PERIOD);
   TermDeposit depositExpected =
       TermDeposit.builder()
           .buySell(BuySell.BUY)
           .currency(EUR)
           .dayCount(ACT_360)
           .startDate(startDateExpected)
           .endDate(endDateExpected)
           .notional(1.0d)
           .businessDayAdjustment(BDA_MOD_FOLLOW)
           .rate(rate + SPREAD)
           .build();
   TradeInfo tradeInfoExpected = TradeInfo.builder().tradeDate(VAL_DATE).build();
   assertEquals(trade.getProduct(), depositExpected);
   assertEquals(trade.getInfo(), tradeInfoExpected);
 }
 @Override
 public Optional<Currency> defaultReportingCurrency(TermDepositTrade target) {
   return Optional.of(target.getProduct().getCurrency());
 }