Example #1
0
  /**
   * Obtains an instance from a valuation date, map of values and time-series.
   *
   * @param valuationDate the valuation date of the market data
   * @param values the market data values
   * @param timeSeries the time-series
   * @return the market data instance containing the values in the map and the time-series
   * @throws ClassCastException if a value does not match the parameterized type associated with the
   *     identifier
   */
  public static MarketData of(
      LocalDate valuationDate,
      Map<? extends MarketDataId<?>, ?> values,
      Map<? extends ObservableId, LocalDateDoubleTimeSeries> timeSeries) {

    return ImmutableMarketData.builder(valuationDate).values(values).timeSeries(timeSeries).build();
  }
Example #2
0
 /**
  * Obtains an instance containing no market data.
  *
  * @param valuationDate the valuation date of the market data
  * @return empty market data
  */
 public static MarketData empty(LocalDate valuationDate) {
   return ImmutableMarketData.builder(valuationDate).build();
 }
Example #3
0
 /**
  * Obtains an instance from a valuation date and map of values.
  *
  * <p>Each entry in the map is a single piece of market data, keyed by the matching identifier.
  * For example, an {@link FxRate} can be looked up using an {@link FxRateId}. The caller must
  * ensure that the each entry in the map corresponds with the parameterized type on the
  * identifier.
  *
  * @param valuationDate the valuation date of the market data
  * @param values the market data values
  * @return the market data instance containing the values in the map
  * @throws ClassCastException if a value does not match the parameterized type associated with the
  *     identifier
  */
 public static MarketData of(LocalDate valuationDate, Map<? extends MarketDataId<?>, ?> values) {
   return ImmutableMarketData.of(valuationDate, values);
 }
 private static ImmutableMarketData data() {
   Map<? extends MarketDataKey<?>, Object> dataMap = ImmutableMap.of(KEY1, 123d);
   Map<ObservableKey, LocalDateDoubleTimeSeries> timeSeriesMap =
       ImmutableMap.of(KEY2, TIME_SERIES);
   return ImmutableMarketData.builder().values(dataMap).timeSeries(timeSeriesMap).build();
 }
 public void getTimeSeries() {
   assertThat(DATA.getTimeSeries(KEY1)).isEqualTo(LocalDateDoubleTimeSeries.empty());
   assertThat(DATA.getTimeSeries(KEY2)).isEqualTo(TIME_SERIES);
 }
 public void getValue() {
   assertThat(DATA.getValue(KEY1)).isEqualTo(123d);
   assertThrowsIllegalArg(() -> DATA.getValue(KEY2));
 }
 public void containsTimeSeries() {
   assertThat(DATA.containsTimeSeries(KEY1)).isFalse();
   assertThat(DATA.containsTimeSeries(KEY2)).isTrue();
 }
 public void containsValue() {
   assertThat(DATA.containsValue(KEY1)).isTrue();
   assertThat(DATA.containsValue(KEY2)).isFalse();
 }