Exemplo n.º 1
0
        //-------------------------------------------------------------------------
        public virtual void test_getValue_fxIdentity()
        {
            BuiltScenarioMarketData test = BuiltScenarioMarketData.builder(MarketDataBox.ofSingleValue(VAL_DATE)).build();

            assertEquals(test.ScenarioCount, 1);
            assertEquals(test.getValue(FxRateId.of(GBP, GBP)), MarketDataBox.ofSingleValue(FxRate.of(GBP, GBP, 1)));
        }
Exemplo n.º 2
0
        /// <summary>
        /// Tests building a tree of requirements using market data functions.
        /// </summary>
        public virtual void buildDependencyTree()
        {
            MarketDataNode expected = rootNode(observableNode(new TestIdA(this, "1")), valueNode(new TestIdB(this, "2"), valueNode(new TestIdB(this, "4"), observableNode(new TestIdA(this, "5"))), timeSeriesNode(new TestIdA(this, "3"))), timeSeriesNode(new TestIdA(this, "6")));

            // The requirements for the data directly used by the calculations
            MarketDataRequirements requirements = MarketDataRequirements.builder().addValues(new TestIdA(this, "1"), new TestIdB(this, "2")).addTimeSeries(new TestIdA(this, "6")).build();

            // Requirements for each item in the tree - used to initialize the functions
            MarketDataRequirements id2Reqs = MarketDataRequirements.builder().addTimeSeries(new TestIdA(this, "3")).addValues(new TestIdB(this, "4")).build();

            MarketDataRequirements id4Reqs = MarketDataRequirements.builder().addValues(new TestIdA(this, "5")).build();

            ImmutableMap <TestIdB, MarketDataRequirements> reqsMap = ImmutableMap.of(new TestIdB(this, "2"), id2Reqs, new TestIdB(this, "4"), id4Reqs);

            TestMarketDataFunctionA builderA = new TestMarketDataFunctionA();
            TestMarketDataFunctionB builderB = new TestMarketDataFunctionB(reqsMap);

//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: com.google.common.collect.ImmutableMap<Class, MarketDataFunction<?, ?>> functions = com.google.common.collect.ImmutableMap.of(TestIdA.class, builderA, TestIdB.class, builderB);
            ImmutableMap <Type, MarketDataFunction <object, ?> > functions = ImmutableMap.of(typeof(TestIdA), builderA, typeof(TestIdB), builderB);

            MarketDataNode root = MarketDataNode.buildDependencyTree(requirements, BuiltScenarioMarketData.empty(), MarketDataConfig.empty(), functions);

            assertThat(root).isEqualTo(expected);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Tests that supplied data is in a leaf node and the functions aren't asked for dependencies for supplied data.
        /// </summary>
        public virtual void noDependenciesForSuppliedData()
        {
            MarketDataNode expected1 = rootNode(valueNode(new TestIdB(this, "1"), observableNode(new TestIdA(this, "2"))), valueNode(new TestIdB(this, "3"), valueNode(new TestIdB(this, "4"))));

            MarketDataRequirements requirements = MarketDataRequirements.builder().addValues(new TestIdB(this, "1"), new TestIdB(this, "3")).build();

            MarketDataRequirements id1Reqs = MarketDataRequirements.builder().addValues(new TestIdA(this, "2")).build();

            MarketDataRequirements id3Reqs = MarketDataRequirements.builder().addValues(new TestIdB(this, "4")).build();

            ImmutableMap <TestIdB, MarketDataRequirements> reqsMap = ImmutableMap.of(new TestIdB(this, "1"), id1Reqs, new TestIdB(this, "3"), id3Reqs);

            TestMarketDataFunctionB builder = new TestMarketDataFunctionB(reqsMap);

//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: com.google.common.collect.ImmutableMap<Class, MarketDataFunction<?, ?>> functions = com.google.common.collect.ImmutableMap.of(TestIdB.class, builder);
            ImmutableMap <Type, MarketDataFunction <object, ?> > functions = ImmutableMap.of(typeof(TestIdB), builder);

            MarketDataNode root1 = MarketDataNode.buildDependencyTree(requirements, BuiltScenarioMarketData.empty(), MarketDataConfig.empty(), functions);

            assertThat(root1).isEqualTo(expected1);

            BuiltScenarioMarketData suppliedData = BuiltScenarioMarketData.builder(date(2011, 3, 8)).addValue(new TestIdB(this, "1"), new TestMarketDataB()).addValue(new TestIdB(this, "3"), new TestMarketDataB()).build();

            MarketDataNode root2 = MarketDataNode.buildDependencyTree(requirements, suppliedData, MarketDataConfig.empty(), functions);

            MarketDataNode expected2 = rootNode(valueNode(new TestIdB(this, "1")), valueNode(new TestIdB(this, "3")));

            assertThat(root2).isEqualTo(expected2);
        }
Exemplo n.º 4
0
        public virtual void test_getValue_withUnknownFailure()
        {
            BuiltScenarioMarketData test = BuiltScenarioMarketData.builder(MarketDataBox.ofSingleValue(VAL_DATE)).build();

            assertEquals(test.ValuationDate, MarketDataBox.ofSingleValue(VAL_DATE));
            assertEquals(test.containsValue(ID), false);
            assertEquals(test.Ids, ImmutableSet.of());
            assertEquals(test.findValue(ID), null);
            assertThrows(() => test.getValue(ID), typeof(MarketDataNotFoundException));
        }
Exemplo n.º 5
0
        public virtual void test_getValue_withKnownFailure()
        {
            string failureMessage        = "Something went wrong";
            BuiltScenarioMarketData test = BuiltScenarioMarketData.builder(MarketDataBox.ofSingleValue(VAL_DATE)).addResult(ID, Result.failure(FailureReason.ERROR, failureMessage)).build();

            assertEquals(test.ValuationDate, MarketDataBox.ofSingleValue(VAL_DATE));
            assertEquals(test.containsValue(ID), false);
            assertEquals(test.Ids, ImmutableSet.of());
            assertEquals(test.findValue(ID), null);
            assertThrows(() => test.getValue(ID), typeof(FailureException), failureMessage);
        }
Exemplo n.º 6
0
            public override Builder set(string propertyName, object newValue)
            {
                switch (propertyName.GetHashCode())
                {
                case -1770633379:         // underlying
                    this.underlying = (BuiltScenarioMarketData)newValue;
                    break;

                default:
                    throw new NoSuchElementException("Unknown property: " + propertyName);
                }
                return(this);
            }
Exemplo n.º 7
0
        /// <summary>
        /// Test a node with no children is added when there is no market data function for an ID.
        /// </summary>
        public virtual void noMarketDataBuilder()
        {
            MarketDataNode expected = rootNode(valueNode(new TestIdC("1")), valueNode(new TestIdB(this, "2"), valueNode(new TestIdC("3"))));

            MarketDataRequirements requirements = MarketDataRequirements.builder().addValues(new TestIdC("1"), new TestIdB(this, "2")).build();

            MarketDataRequirements id2Reqs = MarketDataRequirements.builder().addValues(new TestIdC("3")).build();

            TestMarketDataFunctionB builder = new TestMarketDataFunctionB(ImmutableMap.of(new TestIdB(this, "2"), id2Reqs));
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: com.google.common.collect.ImmutableMap<Class, MarketDataFunction<?, ?>> functions = com.google.common.collect.ImmutableMap.of(TestIdB.class, builder);
            ImmutableMap <Type, MarketDataFunction <object, ?> > functions = ImmutableMap.of(typeof(TestIdB), builder);
            // Build the tree without providing a market data function to handle TestId3
            MarketDataNode root = MarketDataNode.buildDependencyTree(requirements, BuiltScenarioMarketData.empty(), MarketDataConfig.empty(), functions);

            assertThat(root).isEqualTo(expected);
        }
Exemplo n.º 8
0
 /// <summary>
 /// Creates an instance. </summary>
 /// <param name="underlying">  the value of the property, not null </param>
 internal BuiltMarketData(BuiltScenarioMarketData underlying)
 {
     JodaBeanUtils.notNull(underlying, "underlying");
     this.underlying = underlying;
 }
Exemplo n.º 9
0
 //-------------------------------------------------------------------------
 public virtual void coverage()
 {
     coverImmutableBean(BuiltScenarioMarketData.empty());
 }