Interface MarketData

  • All Known Implementing Classes:
    BuiltMarketData, ImmutableMarketData

    public interface MarketData
    Provides access to market data, such as curves, surfaces and time-series.

    Market data is looked up using subclasses of MarketDataId. All data is valid for a single date, defined by getValuationDate(). When performing calculations with scenarios, only the data of a single scenario is accessible.

    The standard implementation is ImmutableMarketData.

    • Method Detail

      • of

        static MarketData of​(java.time.LocalDate valuationDate,
                             java.util.Map<? extends MarketDataId<?>,​?> values)
        Obtains an instance from a valuation date and map of values.

        Each entry in the map is a single piece of market data, keyed by the matching identifier. For example, an FxRate can be looked up using an FxRateId. The caller must ensure that the each entry in the map corresponds with the parameterized type on the identifier.

        Parameters:
        valuationDate - the valuation date of the market data
        values - the market data values
        Returns:
        the market data instance containing the values in the map
        Throws:
        java.lang.ClassCastException - if a value does not match the parameterized type associated with the identifier
      • of

        static MarketData of​(java.time.LocalDate valuationDate,
                             java.util.Map<? extends MarketDataId<?>,​?> values,
                             java.util.Map<? extends ObservableId,​LocalDateDoubleTimeSeries> timeSeries)
        Obtains an instance from a valuation date, map of values and time-series.
        Parameters:
        valuationDate - the valuation date of the market data
        values - the market data values
        timeSeries - the time-series
        Returns:
        the market data instance containing the values in the map and the time-series
        Throws:
        java.lang.ClassCastException - if a value does not match the parameterized type associated with the identifier
      • empty

        static MarketData empty​(java.time.LocalDate valuationDate)
        Obtains an instance containing no market data.
        Parameters:
        valuationDate - the valuation date of the market data
        Returns:
        empty market data
      • getValuationDate

        java.time.LocalDate getValuationDate()
        Gets the valuation date of the market data.

        All values accessible through this interface have the same valuation date.

        Returns:
        the valuation date
      • containsValue

        default boolean containsValue​(MarketDataId<?> id)
        Checks if this market data contains a value for the specified identifier.
        Parameters:
        id - the identifier to find
        Returns:
        true if the market data contains a value for the identifier
      • getValue

        default <T> T getValue​(MarketDataId<T> id)
        Gets the market data value associated with the specified identifier.

        If this market data instance contains the identifier, the value will be returned. Otherwise, an exception will be thrown.

        Type Parameters:
        T - the type of the market data value
        Parameters:
        id - the identifier to find
        Returns:
        the market data value
        Throws:
        MarketDataNotFoundException - if the identifier is not found
      • findValue

        <T> java.util.Optional<T> findValue​(MarketDataId<T> id)
        Finds the market data value associated with the specified identifier.

        If this market data instance contains the identifier, the value will be returned. Otherwise, an empty optional will be returned.

        Type Parameters:
        T - the type of the market data value
        Parameters:
        id - the identifier to find
        Returns:
        the market data value, empty if not found
      • getIds

        java.util.Set<MarketDataId<?>> getIds()
        Gets the market data identifiers.
        Returns:
        the set of market data identifiers
      • findIds

        <T> java.util.Set<MarketDataId<T>> findIds​(MarketDataName<T> name)
        Finds the market data identifiers associated with the specified name.

        This returns the unique identifiers that refer to the specified name. There may be more than one identifier associated with a name as the name is not unique.

        Type Parameters:
        T - the type of the market data value
        Parameters:
        name - the name to find
        Returns:
        the set of market data identifiers, empty if name not found
      • getTimeSeriesIds

        java.util.Set<ObservableId> getTimeSeriesIds()
        Gets the time-series identifiers.
        Returns:
        the set of observable identifiers
      • getTimeSeries

        LocalDateDoubleTimeSeries getTimeSeries​(ObservableId id)
        Gets the time-series identified by the specified identifier, empty if not found.
        Parameters:
        id - the identifier to find
        Returns:
        the time-series, empty if no time-series found
      • combinedWith

        default MarketData combinedWith​(MarketData other)
        Combines this market data with another.

        The result combines both sets of market data. Values are taken from this set of market data if available, otherwise they are taken from the other set.

        The valuation dates of the sets of market data must be the same.

        Parameters:
        other - the other market data
        Returns:
        the combined market data
      • withValue

        default <T> MarketData withValue​(MarketDataId<T> id,
                                         T value)
        Returns a copy of this market data with the specified value.

        When the result is queried for the specified identifier, the specified value will be returned.

        For example, this method could be used to replace a curve with a bumped curve.

        Type Parameters:
        T - the type of the market data value
        Parameters:
        id - the identifier to find
        value - the value to associate with the identifier
        Returns:
        the derived market data with the specified identifier and value