Class CalculationTask

  • All Implemented Interfaces:
    org.joda.beans.Bean, org.joda.beans.ImmutableBean

    public final class CalculationTask
    extends Object
    implements org.joda.beans.ImmutableBean
    A single task that will be used to perform a calculation.

    This is a single unit of execution in the calculation runner. It consists of a CalculationFunction and the appropriate inputs, including a single CalculationTarget. When invoked, it will calculate a result for one or more columns in the grid of results.

    • Method Detail

      • of

        public static CalculationTask of​(CalculationTarget target,
                                         CalculationFunction<? extends CalculationTarget> function,
                                         CalculationTaskCell... cells)
        Obtains an instance that will calculate the specified cells.

        The cells must all be for the same row index and none of the column indices must overlap. The result will contain no calculation parameters.

        Parameters:
        target - the target for which the value will be calculated
        function - the function that performs the calculation
        cells - the cells to be calculated by this task
        Returns:
        the task
      • of

        public static CalculationTask of​(CalculationTarget target,
                                         CalculationFunction<? extends CalculationTarget> function,
                                         CalculationParameters parameters,
                                         List<CalculationTaskCell> cells)
        Obtains an instance that will calculate the specified cells.

        The cells must all be for the same row index and none of the column indices must overlap.

        Parameters:
        target - the target for which the value will be calculated
        function - the function that performs the calculation
        parameters - the additional parameters
        cells - the cells to be calculated by this task
        Returns:
        the task
      • getRowIndex

        public int getRowIndex()
        Gets the index of the row in the grid of results.
        Returns:
        the row index
      • getMeasures

        public Set<Measure> getMeasures()
        Gets the set of measures that will be calculated by this task.
        Returns:
        the measures
      • requirements

        public MarketDataRequirements requirements​(ReferenceData refData)
        Returns requirements specifying the market data the function needs to perform its calculations.
        Parameters:
        refData - the reference data
        Returns:
        requirements specifying the market data the function needs to perform its calculations
      • naturalCurrency

        public Currency naturalCurrency​(ReferenceData refData)
        Determines the natural currency of the target.

        This is only called for measures that are currency convertible.

        Parameters:
        refData - the reference data
        Returns:
        the natural currency
      • execute

        public CalculationResults execute​(ScenarioMarketData marketData,
                                          ReferenceData refData)
        Executes the task, performing calculations for the target using multiple sets of market data.

        This invokes the function with the correct set of market data.

        Parameters:
        marketData - the market data used in the calculation
        refData - the reference data
        Returns:
        results of the calculation, one for every scenario in the market data
      • meta

        public static org.joda.beans.TypedMetaBean<CalculationTask> meta()
        The meta-bean for CalculationTask.
        Returns:
        the meta-bean, not null
      • metaBean

        public org.joda.beans.TypedMetaBean<CalculationTask> metaBean()
        Specified by:
        metaBean in interface org.joda.beans.Bean
      • getTarget

        public CalculationTarget getTarget()
        Gets the target for which the value will be calculated. This is typically a trade.
        Returns:
        the value of the property, not null
      • getParameters

        public CalculationParameters getParameters()
        Gets the additional parameters.
        Returns:
        the value of the property, not null
      • getCells

        public List<CalculationTaskCell> getCells()
        Gets the cells to be calculated.
        Returns:
        the value of the property, not empty
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object