//-------------------------------------------------------------------------
 /// <summary>
 /// Obtains an instance that will calculate the specified cells.
 /// <para>
 /// 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.
 ///
 /// </para>
 /// </summary>
 /// <param name="target">  the target for which the value will be calculated </param>
 /// <param name="function">  the function that performs the calculation </param>
 /// <param name="cells">  the cells to be calculated by this task </param>
 /// <returns> the task </returns>
 public static CalculationTask of <T1>(CalculationTarget target, CalculationFunction <T1> function, params CalculationTaskCell[] cells) where T1 : com.opengamma.strata.basics.CalculationTarget
 {
     return(of(target, function, CalculationParameters.empty(), ImmutableList.copyOf(cells)));
 }
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: @Override public java.util.Map<com.opengamma.strata.calc.Measure, com.opengamma.strata.collect.result.Result<?>> calculate(T target, java.util.Set<com.opengamma.strata.calc.Measure> measures, CalculationParameters parameters, com.opengamma.strata.data.scenario.ScenarioMarketData marketData, com.opengamma.strata.basics.ReferenceData refData)
        public virtual IDictionary <Measure, Result <object> > calculate(T target, ISet <Measure> measures, CalculationParameters parameters, ScenarioMarketData marketData, ReferenceData refData)
        {
            // The caller didn't ask for the derived measure so just return the measures calculated by the delegate
            Measure derivedMeasure = derivedFunction.measure();

            if (!measures.Contains(derivedMeasure))
            {
                return(@delegate.calculate(target, measures, parameters, marketData, refData));
            }
            // Add the measures required to calculate the derived measure to the measures requested by the caller
            ISet <Measure> allRequiredMeasures = Sets.union(measures, derivedFunction.requiredMeasures());
            ISet <Measure> requiredMeasures    = Sets.difference(allRequiredMeasures, ImmutableSet.of(derivedMeasure));
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: java.util.Map<com.opengamma.strata.calc.Measure, com.opengamma.strata.collect.result.Result<?>> delegateResults = delegate.calculate(target, requiredMeasures, parameters, marketData, refData);
            IDictionary <Measure, Result <object> > delegateResults = @delegate.calculate(target, requiredMeasures, parameters, marketData, refData);

            // Calculate the derived measure
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: com.opengamma.strata.collect.result.Result<?> result = calculateMeasure(target, delegateResults, parameters, marketData, refData);
            Result <object> result = calculateMeasure(target, delegateResults, parameters, marketData, refData);

            // The results containing only the requested measures and not including extra measures that were inserted above
            // Also filter out any results for calculationFunction.measure(). There will be failures from functions below
            // that don't support that measure.
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: java.util.Map<com.opengamma.strata.calc.Measure, com.opengamma.strata.collect.result.Result<?>> requestedResults = com.opengamma.strata.collect.MapStream.of(delegateResults).filterKeys(measures::contains).filterKeys(measure -> !measure.equals(derivedMeasure)).toMap();
            IDictionary <Measure, Result <object> > requestedResults = MapStream.of(delegateResults).filterKeys(measures.contains).filterKeys(measure => !measure.Equals(derivedMeasure)).toMap();

//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: return com.google.common.collect.ImmutableMap.builder<com.opengamma.strata.calc.Measure, com.opengamma.strata.collect.result.Result<?>>().put(derivedMeasure, result).putAll(requestedResults).build();
            return(ImmutableMap.builder <Measure, Result <object> >().put(derivedMeasure, result).putAll(requestedResults).build());
        }
 private CalculationTask(CalculationTarget target, CalculationFunction <CalculationTarget> function, CalculationParameters parameters, IList <CalculationTaskCell> cells)
 {
     JodaBeanUtils.notNull(target, "target");
     JodaBeanUtils.notNull(function, "function");
     JodaBeanUtils.notNull(parameters, "parameters");
     JodaBeanUtils.notEmpty(cells, "cells");
     this.target     = target;
     this.function   = function;
     this.parameters = parameters;
     this.cells      = ImmutableList.copyOf(cells);
 }
예제 #4
0
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: @Override public java.util.Map<com.opengamma.strata.calc.Measure, com.opengamma.strata.collect.result.Result<?>> calculate(TestTarget target, java.util.Set<com.opengamma.strata.calc.Measure> measures, CalculationParameters parameters, com.opengamma.strata.data.scenario.ScenarioMarketData marketData, com.opengamma.strata.basics.ReferenceData refData)
            public IDictionary <Measure, Result <object> > calculate(TestTarget target, ISet <Measure> measures, CalculationParameters parameters, ScenarioMarketData marketData, ReferenceData refData)
            {
                throw new System.NotSupportedException("calculate not implemented");
            }
예제 #5
0
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: @Override public java.util.Map<com.opengamma.strata.calc.Measure, com.opengamma.strata.collect.result.Result<?>> calculate(UnresolvableTarget target, java.util.Set<com.opengamma.strata.calc.Measure> measures, CalculationParameters parameters, com.opengamma.strata.data.scenario.ScenarioMarketData marketData, com.opengamma.strata.basics.ReferenceData refData)
        public IDictionary <Measure, Result <object> > calculate(UnresolvableTarget target, ISet <Measure> measures, CalculationParameters parameters, ScenarioMarketData marketData, ReferenceData refData)
        {
            throw new System.InvalidOperationException(Messages.format("Target '{}' cannot be resolved: {}", target.Target.GetType(), target.Message));
        }
예제 #6
0
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: @Override public java.util.Map<com.opengamma.strata.calc.Measure, com.opengamma.strata.collect.result.Result<?>> calculate(TestTarget target, java.util.Set<com.opengamma.strata.calc.Measure> measures, CalculationParameters parameters, com.opengamma.strata.data.scenario.ScenarioMarketData marketData, com.opengamma.strata.basics.ReferenceData refData)
            public IDictionary <Measure, Result <object> > calculate(TestTarget target, ISet <Measure> measures, CalculationParameters parameters, ScenarioMarketData marketData, ReferenceData refData)
            {
                Result <CurrencyScenarioArray> result = Result.success(supplier.get());

                return(ImmutableMap.of(TestingMeasures.PRESENT_VALUE, result, TestingMeasures.PRESENT_VALUE_MULTI_CCY, result));
            }
예제 #7
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @SuppressWarnings("unchecked") @Override public java.util.Map<com.opengamma.strata.calc.Measure, com.opengamma.strata.collect.result.Result<?>> calculate(TestTarget target, java.util.Set<com.opengamma.strata.calc.Measure> measures, CalculationParameters parameters, com.opengamma.strata.data.scenario.ScenarioMarketData marketData, com.opengamma.strata.basics.ReferenceData refData)
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
            public IDictionary <Measure, Result <object> > calculate(TestTarget target, ISet <Measure> measures, CalculationParameters parameters, ScenarioMarketData marketData, ReferenceData refData)
            {
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: java.util.Map<com.opengamma.strata.calc.Measure, com.opengamma.strata.collect.result.Result<?>> map = new java.util.HashMap<>();
                IDictionary <Measure, Result <object> > map = new Dictionary <Measure, Result <object> >();

                foreach (Measure measure in resultMeasures)
                {
                    map[measure] = Result.success(measures);
                }
                return(map);
            }
        /// <summary>
        /// Test that the derived measure isn't calculated unless it is requested.
        /// </summary>
        public virtual void derivedMeasureNotRequested()
        {
            TestTarget target = new TestTarget(10);
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: java.util.Map<com.opengamma.strata.calc.Measure, com.opengamma.strata.collect.result.Result<?>> delegateResults = com.google.common.collect.ImmutableMap.of(CASH_FLOWS, com.opengamma.strata.collect.result.Result.success(3), PRESENT_VALUE, com.opengamma.strata.collect.result.Result.success(7));
            IDictionary <Measure, Result <object> >             delegateResults = ImmutableMap.of(CASH_FLOWS, Result.success(3), PRESENT_VALUE, Result.success(7));
            DerivedCalculationFunctionWrapper <TestTarget, int> wrapper         = new DerivedCalculationFunctionWrapper <TestTarget, int>(new DerivedFn(), new DelegateFn(delegateResults));

            ISet <Measure> measures = ImmutableSet.of(CASH_FLOWS, PRESENT_VALUE);
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: java.util.Map<com.opengamma.strata.calc.Measure, com.opengamma.strata.collect.result.Result<?>> results = wrapper.calculate(target, measures, CalculationParameters.empty(), com.opengamma.strata.data.scenario.ScenarioMarketData.empty(), com.opengamma.strata.basics.ReferenceData.standard());
            IDictionary <Measure, Result <object> > results = wrapper.calculate(target, measures, CalculationParameters.empty(), ScenarioMarketData.empty(), ReferenceData.standard());

            assertThat(results.Keys).isEqualTo(measures);
            assertThat(results[CASH_FLOWS]).hasValue(3);
            assertThat(results[PRESENT_VALUE]).hasValue(7);
        }
        /// <summary>
        /// Test the behaviour when the underlying function doesn't support the measures required by the derived function.
        /// </summary>
        public virtual void requiredMeasuresNotSupported()
        {
            TestTarget target = new TestTarget(10);
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: java.util.Map<com.opengamma.strata.calc.Measure, com.opengamma.strata.collect.result.Result<?>> delegateResults = com.google.common.collect.ImmutableMap.of(PAR_RATE, com.opengamma.strata.collect.result.Result.success(5), PRESENT_VALUE, com.opengamma.strata.collect.result.Result.success(7));
            IDictionary <Measure, Result <object> >             delegateResults = ImmutableMap.of(PAR_RATE, Result.success(5), PRESENT_VALUE, Result.success(7));
            DerivedCalculationFunctionWrapper <TestTarget, int> wrapper         = new DerivedCalculationFunctionWrapper <TestTarget, int>(new DerivedFn(), new DelegateFn(delegateResults));

            ISet <Measure> measures = ImmutableSet.of(BUCKETED_PV01, PAR_RATE);
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: java.util.Map<com.opengamma.strata.calc.Measure, com.opengamma.strata.collect.result.Result<?>> results = wrapper.calculate(target, measures, CalculationParameters.empty(), com.opengamma.strata.data.scenario.ScenarioMarketData.empty(), com.opengamma.strata.basics.ReferenceData.standard());
            IDictionary <Measure, Result <object> > results = wrapper.calculate(target, measures, CalculationParameters.empty(), ScenarioMarketData.empty(), ReferenceData.standard());

            // The derived measure isn't supported because its required measure isn't available
            assertThat(wrapper.supportedMeasures()).isEqualTo(ImmutableSet.of(PAR_RATE, PRESENT_VALUE));
            assertThat(results.Keys).isEqualTo(measures);
            assertThat(results[BUCKETED_PV01]).hasFailureMessageMatching(".*cannot calculate the required measures.*");
            assertThat(results[PAR_RATE]).hasValue(5);
        }
예제 #10
0
 public abstract R calculate(T target, IDictionary <Measure, object> requiredMeasures, CalculationParameters parameters, com.opengamma.strata.data.scenario.ScenarioMarketData marketData, ReferenceData refData);
예제 #11
0
 public virtual FunctionRequirements requirements(T target, CalculationParameters parameters, ReferenceData refData)
 {
     return(FunctionRequirements.empty());
 }
예제 #12
0
 public FunctionRequirements requirements(Target2 target, ISet <Measure> measures, CalculationParameters parameters, ReferenceData refData)
 {
     throw new System.NotSupportedException("requirements not implemented");
 }
        public virtual FunctionRequirements requirements(T target, ISet <Measure> measures, CalculationParameters parameters, ReferenceData refData)
        {
            FunctionRequirements delegateRequirements = @delegate.requirements(target, measures, parameters, refData);
            FunctionRequirements functionRequirements = derivedFunction.requirements(target, parameters, refData);

            return(delegateRequirements.combinedWith(functionRequirements));
        }
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: private com.opengamma.strata.collect.result.Result<?> calculateMeasure(T target, java.util.Map<com.opengamma.strata.calc.Measure, com.opengamma.strata.collect.result.Result<?>> delegateResults, CalculationParameters parameters, com.opengamma.strata.data.scenario.ScenarioMarketData marketData, com.opengamma.strata.basics.ReferenceData refData)
        private Result <object> calculateMeasure <T1>(T target, IDictionary <T1> delegateResults, CalculationParameters parameters, ScenarioMarketData marketData, ReferenceData refData)
        {
            if (!requiredMeasuresSupported)
            {
                // Can't calculate the measure if the delegate can't calculate its inputs
                return(Result.failure(FailureReason.NOT_APPLICABLE, "The delegate function cannot calculate the required measures. Required measures: {}, " + "supported measures: {}, delegate {}", derivedFunction.requiredMeasures(), @delegate.supportedMeasures(), @delegate));
            }
//JAVA TO C# CONVERTER TODO TASK: There is no .NET equivalent to the java.util.Collection 'containsAll' method:
            if (!delegateResults.Keys.containsAll(derivedFunction.requiredMeasures()))
            {
                // There's a bug in the delegate function - it claims to support the required measures but didn't return
                // a result for all of them.
                return(Result.failure(FailureReason.CALCULATION_FAILED, "Delegate did not return the expected measures. Required {}, actual {}, delegate {}", derivedFunction.requiredMeasures(), delegateResults.Keys, @delegate));
            }
            // Check whether all the required measures were successfully calculated
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: java.util.List<com.opengamma.strata.collect.result.Result<?>> failures = com.opengamma.strata.collect.MapStream.of(delegateResults).filterKeys(derivedFunction.requiredMeasures()::contains).map(entry -> entry.getValue()).filter(result -> result.isFailure()).collect(toList());
            IList <Result <object> > failures = MapStream.of(delegateResults).filterKeys(derivedFunction.requiredMeasures().contains).map(entry => entry.Value).filter(result => result.Failure).collect(toList());

            if (failures.Count > 0)
            {
                return(Result.failure(failures));
            }
            // Unwrap the results before passing them to the function
            IDictionary <Measure, object> resultValues = MapStream.of(delegateResults).filterKeys(derivedFunction.requiredMeasures().contains).mapValues(result => (object)result.Value).toMap();

            return(Result.of(() => derivedFunction.calculate(target, resultValues, parameters, marketData, refData)));
        }
예제 #15
0
 public FunctionRequirements requirements(TestTarget target, ISet <Measure> measures, CalculationParameters parameters, ReferenceData refData)
 {
     return(FunctionRequirements.builder().valueRequirements(ImmutableSet.of(TestId.of("1"), TestObservableId.of("2"))).timeSeriesRequirements(TestObservableId.of("3")).observableSource(OBS_SOURCE).build());
 }
        /// <summary>
        /// Test the behaviour when the delegate function returns no value for a measure it claims to support.
        /// This is a bug in the function, it should always return a result for all measures that are supported and
        /// were requested.
        /// </summary>
        public virtual void supportedMeasureNotReturned()
        {
            TestTarget target = new TestTarget(10);
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: java.util.Map<com.opengamma.strata.calc.Measure, com.opengamma.strata.collect.result.Result<?>> delegateResults = com.google.common.collect.ImmutableMap.of(CASH_FLOWS, com.opengamma.strata.collect.result.Result.success(3), PAR_RATE, com.opengamma.strata.collect.result.Result.success(5), PRESENT_VALUE, com.opengamma.strata.collect.result.Result.success(7));
            IDictionary <Measure, Result <object> > delegateResults = ImmutableMap.of(CASH_FLOWS, Result.success(3), PAR_RATE, Result.success(5), PRESENT_VALUE, Result.success(7));

            DelegateFn delegateFn = new DelegateFnAnonymousInnerClass(this, delegateResults, target);
            DerivedCalculationFunctionWrapper <TestTarget, int> wrapper = new DerivedCalculationFunctionWrapper <TestTarget, int>(new DerivedFn(), delegateFn);

            ISet <Measure> measures = ImmutableSet.of(BUCKETED_PV01);
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: java.util.Map<com.opengamma.strata.calc.Measure, com.opengamma.strata.collect.result.Result<?>> results = wrapper.calculate(target, measures, CalculationParameters.empty(), com.opengamma.strata.data.scenario.ScenarioMarketData.empty(), com.opengamma.strata.basics.ReferenceData.standard());
            IDictionary <Measure, Result <object> > results = wrapper.calculate(target, measures, CalculationParameters.empty(), ScenarioMarketData.empty(), ReferenceData.standard());

            assertThat(results.Keys).isEqualTo(measures);
            assertThat(results[BUCKETED_PV01]).hasFailureMessageMatching(".*did not return the expected measures.*");
        }
예제 #17
0
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: @Override public java.util.Map<com.opengamma.strata.calc.Measure, com.opengamma.strata.collect.result.Result<?>> calculate(TestTarget target, java.util.Set<com.opengamma.strata.calc.Measure> measures, CalculationParameters parameters, com.opengamma.strata.data.scenario.ScenarioMarketData marketData, com.opengamma.strata.basics.ReferenceData refData)
            public IDictionary <Measure, Result <object> > calculate(TestTarget target, ISet <Measure> measures, CalculationParameters parameters, ScenarioMarketData marketData, ReferenceData refData)
            {
                ScenarioArray <string> array = ScenarioArray.of("bar");

                return(ImmutableMap.of(TestingMeasures.PRESENT_VALUE, Result.success(array)));
            }
        /// <summary>
        /// Test two derived function composed together
        /// </summary>
        public virtual void calculateMeasuresNestedDerivedClasses()
        {
            TestTarget target = new TestTarget(10);
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: java.util.Map<com.opengamma.strata.calc.Measure, com.opengamma.strata.collect.result.Result<?>> delegateResults = com.google.common.collect.ImmutableMap.of(CASH_FLOWS, com.opengamma.strata.collect.result.Result.success(3), PAR_RATE, com.opengamma.strata.collect.result.Result.success(5), PRESENT_VALUE, com.opengamma.strata.collect.result.Result.success(7));
            IDictionary <Measure, Result <object> > delegateResults = ImmutableMap.of(CASH_FLOWS, Result.success(3), PAR_RATE, Result.success(5), PRESENT_VALUE, Result.success(7));
            DerivedFn derivedFn1 = new DerivedFn(BUCKETED_PV01);
            DerivedFn derivedFn2 = new DerivedFn(PRESENT_VALUE_MULTI_CCY);
            DerivedCalculationFunctionWrapper <TestTarget, int> wrapper = new DerivedCalculationFunctionWrapper <TestTarget, int>(derivedFn1, new DelegateFn(delegateResults));

            wrapper = new DerivedCalculationFunctionWrapper <>(derivedFn2, wrapper);

            ISet <Measure> measures = ImmutableSet.of(BUCKETED_PV01, PRESENT_VALUE_MULTI_CCY, CASH_FLOWS, PAR_RATE, PRESENT_VALUE);
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: java.util.Map<com.opengamma.strata.calc.Measure, com.opengamma.strata.collect.result.Result<?>> results = wrapper.calculate(target, measures, CalculationParameters.empty(), com.opengamma.strata.data.scenario.ScenarioMarketData.empty(), com.opengamma.strata.basics.ReferenceData.standard());
            IDictionary <Measure, Result <object> > results = wrapper.calculate(target, measures, CalculationParameters.empty(), ScenarioMarketData.empty(), ReferenceData.standard());

            assertThat(wrapper.supportedMeasures()).isEqualTo(measures);
            assertThat(wrapper.targetType()).isEqualTo(typeof(TestTarget));
            assertThat(results.Keys).isEqualTo(measures);
            assertThat(results[BUCKETED_PV01]).hasValue(35);
            assertThat(results[PRESENT_VALUE_MULTI_CCY]).hasValue(35);
            assertThat(results[CASH_FLOWS]).hasValue(3);
            assertThat(results[PAR_RATE]).hasValue(5);
            assertThat(results[PRESENT_VALUE]).hasValue(7);
        }
예제 #19
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @SuppressWarnings("unchecked") @Override public java.util.Map<com.opengamma.strata.calc.Measure, com.opengamma.strata.collect.result.Result<?>> calculate(TestTarget target, java.util.Set<com.opengamma.strata.calc.Measure> measures, CalculationParameters parameters, com.opengamma.strata.data.scenario.ScenarioMarketData marketData, com.opengamma.strata.basics.ReferenceData refData)
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
            public IDictionary <Measure, Result <object> > calculate(TestTarget target, ISet <Measure> measures, CalculationParameters parameters, ScenarioMarketData marketData, ReferenceData refData)
            {
                T obj = supplier.get();

//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: if (obj instanceof com.opengamma.strata.collect.result.Result<?>)
                if (obj is Result <object> )
                {
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: return com.google.common.collect.ImmutableMap.of(com.opengamma.strata.calc.TestingMeasures.PRESENT_VALUE, (com.opengamma.strata.collect.result.Result<?>) obj);
                    return(ImmutableMap.of(TestingMeasures.PRESENT_VALUE, (Result <object>)obj));
                }
                ScenarioArray <object> array = ScenarioArray.of(obj);

                return(ImmutableMap.of(TestingMeasures.PRESENT_VALUE, Result.success(array)));
            }
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: @Override public java.util.Map<com.opengamma.strata.calc.Measure, com.opengamma.strata.collect.result.Result<?>> calculate(com.opengamma.strata.calc.runner.CalculationTaskTest.TestTarget target, java.util.Set<com.opengamma.strata.calc.Measure> measures, CalculationParameters parameters, com.opengamma.strata.data.scenario.ScenarioMarketData marketData, com.opengamma.strata.basics.ReferenceData refData)
            public IDictionary <Measure, Result <object> > calculate(TestTarget target, ISet <Measure> measures, CalculationParameters parameters, ScenarioMarketData marketData, ReferenceData refData)
            {
                return(ImmutableMap.of(measure, Result.success(result)));
            }
예제 #21
0
 public FunctionRequirements requirements(TestTarget target, ISet <Measure> measures, CalculationParameters parameters, ReferenceData refData)
 {
     return(FunctionRequirements.builder().outputCurrencies(GBP, EUR, USD).observableSource(OBS_SOURCE).build());
 }
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: @Override public java.util.Map<com.opengamma.strata.calc.Measure, com.opengamma.strata.collect.result.Result<?>> calculate(com.opengamma.strata.calc.runner.CalculationTaskTest.TestTarget target, java.util.Set<com.opengamma.strata.calc.Measure> measures, CalculationParameters parameters, com.opengamma.strata.data.scenario.ScenarioMarketData marketData, com.opengamma.strata.basics.ReferenceData refData)
            public IDictionary <Measure, Result <object> > calculate(TestTarget target, ISet <Measure> measures, CalculationParameters parameters, ScenarioMarketData marketData, ReferenceData refData)
            {
                while (true)
                {
                    if (Thread.CurrentThread.Interrupted)
                    {
                        throw new Exception("Runtime interrupted");
                    }
                    started = true;
                }
            }
예제 #23
0
 public FunctionRequirements requirements(UnresolvableTarget target, ISet <Measure> measures, CalculationParameters parameters, ReferenceData refData)
 {
     return(FunctionRequirements.empty());
 }
        /// <summary>
        /// Obtains an instance that will calculate the specified cells.
        /// <para>
        /// The cells must all be for the same row index and none of the column indices must overlap.
        ///
        /// </para>
        /// </summary>
        /// <param name="target">  the target for which the value will be calculated </param>
        /// <param name="function">  the function that performs the calculation </param>
        /// <param name="parameters">  the additional parameters </param>
        /// <param name="cells">  the cells to be calculated by this task </param>
        /// <returns> the task </returns>
        public static CalculationTask of <T1>(CalculationTarget target, CalculationFunction <T1> function, CalculationParameters parameters, IList <CalculationTaskCell> cells) where T1 : com.opengamma.strata.basics.CalculationTarget
        {
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @SuppressWarnings("unchecked") CalculationFunction<com.opengamma.strata.basics.CalculationTarget> functionCast = (CalculationFunction<com.opengamma.strata.basics.CalculationTarget>) function;
            CalculationFunction <CalculationTarget> functionCast = (CalculationFunction <CalculationTarget>)function;

            return(new CalculationTask(target, functionCast, parameters, cells));
        }
        public virtual void test_with_add()
        {
            CalculationParameters test = CalculationParameters.of(PARAM).with(PARAM2);

            assertEquals(test.Parameters.size(), 2);
        }
예제 #26
0
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: @Override public java.util.Map<com.opengamma.strata.calc.Measure, com.opengamma.strata.collect.result.Result<?>> calculate(com.opengamma.strata.basics.CalculationTarget target, java.util.Set<com.opengamma.strata.calc.Measure> measures, CalculationParameters parameters, com.opengamma.strata.data.scenario.ScenarioMarketData marketData, com.opengamma.strata.basics.ReferenceData refData)
        public IDictionary <Measure, Result <object> > calculate(CalculationTarget target, ISet <Measure> measures, CalculationParameters parameters, ScenarioMarketData marketData, ReferenceData refData)
        {
            throw new System.InvalidOperationException(Messages.format("No function configured for measures {} on '{}'", measures, target.GetType().Name));
        }