コード例 #1
0
ファイル: MarketDataUtils.java プロジェクト: nssales/Strata
  /**
   * Creates a rates provider from a set of market data containing a single discounting curve, and
   * forward curves and fixing series for a given set of indices. All curves are overridden by a
   * given replacement.
   *
   * @param marketData the market data
   * @param currency the currency of the discounting curve
   * @param indices the indices
   * @param curveOverride the curve override
   * @return the rates provider
   */
  public static RatesProvider toSingleCurveRatesProvider(
      SingleCalculationMarketData marketData,
      Currency currency,
      Set<? extends Index> indices,
      NodalCurve curveOverride) {

    // TODO - we should be able to replace curves more easily than having to pick out all the
    // market data into a new rates provider.

    return ImmutableRatesProvider.builder()
        .valuationDate(marketData.getValuationDate())
        .discountCurves(ImmutableMap.of(currency, curveOverride))
        .indexCurves(
            indices.stream().collect(toImmutableMap(Function.identity(), k -> curveOverride)))
        .timeSeries(
            indices
                .stream()
                .collect(
                    toImmutableMap(
                        Function.identity(), k -> marketData.getTimeSeries(IndexRateKey.of(k)))))
        .build();
  }
コード例 #2
0
  public void coverage_functions() {
    Currency ccy1 = TRADE.getProduct().getNonDeliverableCurrency();
    Currency ccy2 = TRADE.getProduct().getSettlementCurrency();
    LocalDate valDate = TRADE.getProduct().getPaymentDate().plusDays(7);
    Curve df = ConstantNodalCurve.of(Curves.discountFactors("Test", ACT_360), 0.99);
    FxRate fxRate = FxRate.of(ccy1, ccy2, 1.6d);
    TestMarketDataMap md =
        new TestMarketDataMap(
            valDate,
            ImmutableMap.of(
                DiscountCurveKey.of(ccy1), df,
                DiscountCurveKey.of(ccy2), df,
                FxRateKey.of(ccy1, ccy2), fxRate),
            ImmutableMap.of(
                IndexRateKey.of(GBP_USD_WM),
                LocalDateDoubleTimeSeries.of(date(2015, 3, 17), 1.45d)));

    assertNotNull(new FxNdfBucketedPv01Function().execute(TRADE, md));
    assertNotNull(new FxNdfCurrencyExposureFunction().execute(TRADE, md));
    assertNotNull(new FxNdfForwardFxRateFunction().execute(TRADE, md));
    assertNotNull(new FxNdfPv01Function().execute(TRADE, md));
    assertNotNull(new FxNdfPvFunction().execute(TRADE, md));
  }