Пример #1
0
        public virtual void of_list()
        {
            CalculationFunctions test = CalculationFunctions.of(ImmutableList.of(TARGET));

            assertEquals(test.getFunction(new TestTarget()), TARGET);
            assertEquals(test.findFunction(new TestTarget()), TARGET);
        }
Пример #2
0
        public virtual void of_map()
        {
            CalculationFunctions test = CalculationFunctions.of(ImmutableMap.of(typeof(TestTarget), TARGET));

            assertEquals(test.getFunction(new TestTarget()), TARGET);
            assertEquals(test.findFunction(new TestTarget()), TARGET);
        }
Пример #3
0
        //-------------------------------------------------------------------------
        public virtual void test_requirements()
        {
            CalculationFunctions functions        = CalculationFunctions.of(ImmutableMap.of(typeof(TestTarget), new TestFunction()));
            CalculationRules     calculationRules = CalculationRules.of(functions, USD);
            IList <TestTarget>   targets          = ImmutableList.of(TARGET1);
            IList <Column>       columns          = ImmutableList.of(Column.of(TestingMeasures.PRESENT_VALUE));

            CalculationTasks test = CalculationTasks.of(calculationRules, targets, columns);

            MarketDataRequirements requirements = test.requirements(REF_DATA);
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: java.util.Set<? extends com.opengamma.strata.data.MarketDataId<?>> nonObservables = requirements.getNonObservables();
            ISet <MarketDataId <object> > nonObservables = requirements.NonObservables;
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: com.google.common.collect.ImmutableSet<? extends com.opengamma.strata.data.ObservableId> observables = requirements.getObservables();
            ImmutableSet <ObservableId> observables = requirements.Observables;
            ImmutableSet <ObservableId> timeSeries  = requirements.TimeSeries;

            assertThat(nonObservables).hasSize(1);
            assertThat(nonObservables.GetEnumerator().next()).isEqualTo(TestId.of("1"));

//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: com.opengamma.strata.data.MarketDataId<?> observableId = com.opengamma.strata.calc.marketdata.TestObservableId.of("2", CalculationTaskTest.OBS_SOURCE);
            MarketDataId <object> observableId = TestObservableId.of("2", CalculationTaskTest.OBS_SOURCE);

            assertThat(observables).hasSize(1);
            assertThat(observables.GetEnumerator().next()).isEqualTo(observableId);

//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: com.opengamma.strata.data.MarketDataId<?> timeSeriesId = com.opengamma.strata.calc.marketdata.TestObservableId.of("3", CalculationTaskTest.OBS_SOURCE);
            MarketDataId <object> timeSeriesId = TestObservableId.of("3", CalculationTaskTest.OBS_SOURCE);

            assertThat(timeSeries).hasSize(1);
            assertThat(timeSeries.GetEnumerator().next()).isEqualTo(timeSeriesId);
        }
Пример #4
0
        public virtual void of_array()
        {
            CalculationFunctions test = CalculationFunctions.of(TARGET);

            assertEquals(test.getFunction(new TestTarget()), TARGET);
            assertEquals(test.findFunction(new TestTarget()), TARGET);
        }
Пример #5
0
        //-------------------------------------------------------------------------
        public virtual void test_of()
        {
            CalculationFunctions functions        = CalculationFunctions.of(ImmutableMap.of(typeof(TestTarget), new TestFunction()));
            IList <TestTarget>   targets          = ImmutableList.of(TARGET1, TARGET2);
            IList <Column>       columns          = ImmutableList.of(Column.of(TestingMeasures.PRESENT_VALUE), Column.of(TestingMeasures.PAR_RATE));
            CalculationRules     calculationRules = CalculationRules.of(functions, USD);

            CalculationTasks test = CalculationTasks.of(calculationRules, targets, columns);

            assertThat(test.Targets).hasSize(2);
            assertThat(test.Targets).containsExactly(TARGET1, TARGET2);
            assertThat(test.Columns).hasSize(2);
            assertThat(test.Columns).containsExactly(Column.of(TestingMeasures.PRESENT_VALUE), Column.of(TestingMeasures.PAR_RATE));
            assertThat(test.Tasks).hasSize(2);
            assertThat(test.Tasks[0].Target).isEqualTo(TARGET1);
            assertThat(test.Tasks[0].Cells.size()).isEqualTo(2);
            assertThat(test.Tasks[0].Cells.get(0).RowIndex).isEqualTo(0);
            assertThat(test.Tasks[0].Cells.get(0).ColumnIndex).isEqualTo(0);
            assertThat(test.Tasks[0].Cells.get(0).Measure).isEqualTo(TestingMeasures.PRESENT_VALUE);
            assertThat(test.Tasks[0].Cells.get(1).RowIndex).isEqualTo(0);
            assertThat(test.Tasks[0].Cells.get(1).ColumnIndex).isEqualTo(1);
            assertThat(test.Tasks[0].Cells.get(1).Measure).isEqualTo(TestingMeasures.PAR_RATE);

            assertThat(test.Tasks[1].Target).isEqualTo(TARGET2);
            assertThat(test.Tasks[1].Cells.size()).isEqualTo(2);
            assertThat(test.Tasks[1].Cells.get(0).RowIndex).isEqualTo(1);
            assertThat(test.Tasks[1].Cells.get(0).ColumnIndex).isEqualTo(0);
            assertThat(test.Tasks[1].Cells.get(0).Measure).isEqualTo(TestingMeasures.PRESENT_VALUE);
            assertThat(test.Tasks[1].Cells.get(1).RowIndex).isEqualTo(1);
            assertThat(test.Tasks[1].Cells.get(1).ColumnIndex).isEqualTo(1);
            assertThat(test.Tasks[1].Cells.get(1).Measure).isEqualTo(TestingMeasures.PAR_RATE);

            coverImmutableBean(test);
            assertNotNull(CalculationTasks.meta());
        }
Пример #6
0
        public virtual void compose()
        {
            Fn1 fn1a = new Fn1();
            Fn1 fn1b = new Fn1();
            Fn2 fn2  = new Fn2();

            CalculationFunctions fns1     = CalculationFunctions.of(fn1a);
            CalculationFunctions fns2     = CalculationFunctions.of(fn1b, fn2);
            CalculationFunctions composed = fns1.composedWith(fns2);

            assertEquals(composed.getFunction(new Target1()), fn1a);
            assertEquals(composed.getFunction(new Target2()), fn2);
        }
        public virtual void oneDerivedFunction()
        {
//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));
            IDictionary <Measure, Result <object> > delegateResults = ImmutableMap.of(CASH_FLOWS, Result.success(3), PAR_RATE, Result.success(5));
            DelegateFn           delegateFn           = new DelegateFn(delegateResults);
            DerivedFn            derivedFn            = new DerivedFn();
            CalculationFunctions calculationFunctions = CalculationFunctions.of(delegateFn);
            CalculationFunctions derivedFunctions     = calculationFunctions.composedWith(derivedFn);
            TestTarget           target = new TestTarget(42);
//JAVA TO C# CONVERTER TODO TASK: There is no .NET equivalent to the Java 'super' constraint:
//ORIGINAL LINE: CalculationFunction<? super TestTarget> function = derivedFunctions.getFunction(target);
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
            CalculationFunction <object> function = derivedFunctions.getFunction(target);

            ImmutableSet <Measure> expectedMeasures = ImmutableSet.of(BUCKETED_PV01, CASH_FLOWS, PAR_RATE);

            assertThat(function.supportedMeasures()).isEqualTo(expectedMeasures);
        }
        /// <summary>
        /// Test that multiple derived functions for the same target type are correctly combined when one derived function
        /// depends on another.
        /// </summary>
        public virtual void multipleDerivedFunctionsForSameTargetTypeWithDependencyBetweenDerivedFunctions()
        {
//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));
            IDictionary <Measure, Result <object> > delegateResults = ImmutableMap.of(CASH_FLOWS, Result.success(3), PAR_RATE, Result.success(5));
            DelegateFn delegateFn = new DelegateFn(delegateResults);
            DerivedFn  derivedFn1 = new DerivedFn();
            // This depends on the measure calculated by derivedFn1
            DerivedFn derivedFn2 = new DerivedFn(PRESENT_VALUE_MULTI_CCY, ImmutableSet.of(BUCKETED_PV01));

            CalculationFunctions calculationFunctions = CalculationFunctions.of(delegateFn);
            // The derived functions must be specified in the correct order.
            // The function higher up the dependency chain must come second
            CalculationFunctions derivedFunctions = calculationFunctions.composedWith(derivedFn1, derivedFn2);
            TestTarget           target           = new TestTarget(42);
//JAVA TO C# CONVERTER TODO TASK: There is no .NET equivalent to the Java 'super' constraint:
//ORIGINAL LINE: CalculationFunction<? super TestTarget> function = derivedFunctions.getFunction(target);
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
            CalculationFunction <object> function = derivedFunctions.getFunction(target);

            ImmutableSet <Measure> expectedMeasures = ImmutableSet.of(BUCKETED_PV01, CASH_FLOWS, PAR_RATE, PRESENT_VALUE_MULTI_CCY);

            assertThat(function.supportedMeasures()).isEqualTo(expectedMeasures);
        }
Пример #9
0
 //-----------------------------------------------------------------------------------------------------------
 private static CalculationFunctions functions()
 {
     return(CalculationFunctions.of(ImmutableMap.of(typeof(SwapTrade), new SwapTradeCalculationFunction(), typeof(FraTrade), new FraTradeCalculationFunction())));
 }