@Override public MarketData combinedWith(MarketData other) { if (!(other instanceof ImmutableMarketData)) { return MarketData.super.combinedWith(other); } else { return combinedWith((ImmutableMarketData) other); } }
@Override public ImmutableMarketData build() { return new ImmutableMarketData( valuationDate, values, timeSeries); }
/** * 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(); }
private static ImmutableMarketData baseData2() { return ImmutableMarketData.builder(VAL_DATE) .addValue(ID1, VAL1) .addTimeSeriesMap(ImmutableMap.of(ID4, TIME_SERIES)) .build(); }
private static MarketDataFxRateProvider provider2() { Map<FxRateId, FxRate> marketDataMap = ImmutableMap.of(FxRateId.of(EUR, USD), FxRate.of(EUR, USD, EUR_USD), FxRateId.of(EUR, BEF), FxRate.of(EUR, BEF, EUR_BEF), FxRateId.of(GBP, USD), FxRate.of(GBP, USD, GBP_USD)); MarketData marketData = ImmutableMarketData.of(VAL_DATE, marketDataMap); return MarketDataFxRateProvider.of(marketData, ObservableSource.NONE, GBP); }
@Override @SuppressWarnings("unchecked") public <R> Set<MarketDataId<R>> findIds(MarketDataName<R> name) { Set<MarketDataId<R>> ids = underlying.findIds(name); if (id instanceof NamedMarketDataId) { NamedMarketDataId<?> named = (NamedMarketDataId<?>) id; if (named.getMarketDataName().equals(name)) { return ImmutableSet.<MarketDataId<R>>builder().addAll(ids).add((MarketDataId<R>) id).build(); } } return ids; }
/** * Obtains an instance which takes FX rates from the market data. * * @param marketData market data used for looking up FX rates * @return the provider */ public static MarketDataFxRateProvider of(MarketData marketData) { return of(marketData, ObservableSource.NONE); }
@Override public Set<ObservableId> getTimeSeriesIds() { return underlying.getTimeSeriesIds(); }
@SuppressWarnings("unchecked") @Override public <T> T getValue(MarketDataId<T> id) { // overridden for performance // no type check against id.getMarketDataType() as checked in factory @SuppressWarnings("unchecked") T value = (T) values.get(id); if (value == null) { throw new MarketDataNotFoundException(msgValueNotFound(id)); } return value; }
@Override public CurrencyParameterSensitivities parameterSensitivity(InflationRateSensitivity pointSensitivity) { throw new MarketDataNotFoundException("Unable to create sensitivity for historic index " + index); }
@Override @SuppressWarnings("unchecked") public <T> Set<MarketDataId<T>> findIds(MarketDataName<T> name) { return underlying.findIds(name); }
/** * Obtains an instance representing the FX rate for a currency pair, specifying the source. * * @param currencyPair a currency pair * @param observableSource the source of the observable market data used to create the rate * @return an ID for the FX rate for the currency pair */ public static FxRateId of(CurrencyPair currencyPair, ObservableSource observableSource) { return new FxRateId(currencyPair, observableSource); }
/** * Creates a builder that can be used to build an instance of {@code MarketData}. * * @param valuationDate the valuation date * @return the builder, not null */ public static ImmutableMarketDataBuilder builder(LocalDate valuationDate) { return new ImmutableMarketDataBuilder(valuationDate); }
/** * Obtains an instance representing an FX matrix, specifying the source. * * @param observableSource the source of the observable market data used to create the rate * @return an identifier for the FX matrix */ public static FxMatrixId of(ObservableSource observableSource) { return new FxMatrixId(observableSource); }
@Override public BeanBuilder<? extends ImmutableMarketData> builder() { return new ImmutableMarketData.Builder(); }
@Override public PointSensitivityBuilder periodRatePointSensitivity( OvernightIndexObservation startDateObservation, LocalDate endDate) { throw new MarketDataNotFoundException("Unable to query forward rate sensitivity for historic index " + index); }
/** * Returns a set of market data built from the data in this builder. * * @return a set of market data built from the data in this builder */ public ImmutableMarketData build() { return new ImmutableMarketData(valuationDate, values, timeSeries); }
/** * Obtains an instance representing the FX rate for a currency pair. * * @param currencyPair a currency pair * @return an ID for the FX rate for the currency pair */ public static FxRateId of(CurrencyPair currencyPair) { return new FxRateId(currencyPair, ObservableSource.NONE); }
/** * Returns a builder populated with the same data as this instance. * * @return the mutable builder, not null */ public ImmutableMarketDataBuilder toBuilder() { return new ImmutableMarketDataBuilder(valuationDate, values, timeSeries); }