//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public void test_test_writeCurveGroupDefinition_roundtrip() throws Exception
        public virtual void test_test_writeCurveGroupDefinition_roundtrip()
        {
            IList <RatesCurveGroupDefinition> defn = RatesCurveGroupDefinitionCsvLoader.loadCurveGroupDefinitions(ResourceLocator.of(GROUPS_1));
            File tempFile = File.createTempFile("TestCurveGroupLoading", "csv");

            tempFile.deleteOnExit();
            RatesCurveGroupDefinitionCsvLoader.writeCurveGroupDefinition(tempFile, defn[0]);
            assertEquals(RatesCurveGroupDefinitionCsvLoader.loadCurveGroupDefinitions(ResourceLocator.ofFile(tempFile)), defn);
        }
        //-------------------------------------------------------------------------
        public virtual void test_loadCurveGroupDefinition()
        {
            IList <RatesCurveGroupDefinition> defns = RatesCurveGroupDefinitionCsvLoader.loadCurveGroupDefinitions(ResourceLocator.of(GROUPS_1));

            assertEquals(defns.Count, 1);
            RatesCurveGroupDefinition defn = defns[0];

            assertEquals(defn.Entries.get(0), RatesCurveGroupEntry.builder().curveName(CurveName.of("USD-Disc")).discountCurrencies(USD).build());
            assertEquals(defn.Entries.get(1), RatesCurveGroupEntry.builder().curveName(CurveName.of("USD-3ML")).indices(USD_LIBOR_3M).build());
        }
예제 #3
0
        // parse based on pre-parsed seasonality
        private static ImmutableMap <CurveGroupName, RatesCurveGroupDefinition> parse0(CharSource groupsCharSource, CharSource settingsCharSource, IDictionary <CurveName, SeasonalityDefinition> seasonality, ICollection <CharSource> curveNodeCharSources)
        {
            // load curve groups and settings
            IList <RatesCurveGroupDefinition>            curveGroups = RatesCurveGroupDefinitionCsvLoader.parseCurveGroupDefinitions(groupsCharSource);
            IDictionary <CurveName, LoadedCurveSettings> settingsMap = RatesCurvesCsvLoader.parseCurveSettings(settingsCharSource);

            // load curve definitions
            IList <CurveDefinition> curveDefinitions = curveNodeCharSources.stream().flatMap(res => parseSingle(res, settingsMap).stream()).collect(toImmutableList());

            // Add the curve definitions to the curve group definitions
//JAVA TO C# CONVERTER TODO TASK: Most Java stream collectors are not converted by Java to C# Converter:
            return(curveGroups.Select(groupDefinition => groupDefinition.withCurveDefinitions(curveDefinitions).withSeasonalityDefinitions(seasonality)).collect(toImmutableMap(groupDefinition => groupDefinition.Name)));
        }
        public virtual void test_writeCurveGroup()
        {
            IList <RatesCurveGroup> curveGroups = RatesCurvesCsvLoader.load(CURVE_DATE, ResourceLocator.of(GROUPS_1), ResourceLocator.of(SETTINGS_1), ImmutableList.of(ResourceLocator.of(CURVES_1), ResourceLocator.of(CURVES_2)));
            Appendable underlying = new StringBuilder();

            RatesCurveGroupDefinitionCsvLoader.writeCurveGroup(underlying, curveGroups[0]);
            string created  = underlying.ToString();
            string expected = "Group Name,Curve Type,Reference,Curve Name" + Environment.NewLine +
                              "Default,discount,USD,USD-Disc" + Environment.NewLine +
                              "Default,forward,USD-LIBOR-3M,USD-3ML" + Environment.NewLine;

            assertEquals(created, expected);
        }
        //-------------------------------------------------------------------------
        public virtual void test_writeCurveGroupDefinition()
        {
            RatesCurveGroupDefinition defn = RatesCurveGroupDefinitionCsvLoader.loadCurveGroupDefinitions(ResourceLocator.of(GROUPS_1))[0];
            Appendable underlying          = new StringBuilder();

            RatesCurveGroupDefinitionCsvLoader.writeCurveGroupDefinition(underlying, defn);
            string created  = underlying.ToString();
            string expected = "Group Name,Curve Type,Reference,Curve Name" + Environment.NewLine +
                              "Default,discount,USD,USD-Disc" + Environment.NewLine +
                              "Default,forward,USD-LIBOR-3M,USD-3ML" + Environment.NewLine +
                              "Default,forward,US-CPI-U,USD-CPI" + Environment.NewLine;

            assertEquals(created, expected);
        }
예제 #6
0
        //-------------------------------------------------------------------------
        /// <summary>
        /// Parses one or more CSV format curve files for all available dates.
        /// <para>
        /// A predicate is specified that is used to filter the dates that are returned.
        /// This could match a single date, a set of dates or all dates.
        /// </para>
        /// <para>
        /// If the files contain a duplicate entry an exception will be thrown.
        ///
        /// </para>
        /// </summary>
        /// <param name="datePredicate">  the predicate used to select the dates </param>
        /// <param name="groupsCharSource">  the curve groups CSV character source </param>
        /// <param name="settingsCharSource">  the curve settings CSV character source </param>
        /// <param name="curveValueCharSources">  the CSV character sources for curves </param>
        /// <returns> the loaded curves, mapped by date and identifier </returns>
        /// <exception cref="IllegalArgumentException"> if the files contain a duplicate entry </exception>
        public static ImmutableListMultimap <LocalDate, RatesCurveGroup> parse(System.Predicate <LocalDate> datePredicate, CharSource groupsCharSource, CharSource settingsCharSource, ICollection <CharSource> curveValueCharSources)
        {
            IList <RatesCurveGroupDefinition> curveGroups = RatesCurveGroupDefinitionCsvLoader.parseCurveGroupDefinitions(groupsCharSource);
            IDictionary <LocalDate, IDictionary <CurveName, Curve> > curves = parseCurves(datePredicate, settingsCharSource, curveValueCharSources);

            ImmutableListMultimap.Builder <LocalDate, RatesCurveGroup> builder = ImmutableListMultimap.builder();

            foreach (RatesCurveGroupDefinition groupDefinition in curveGroups)
            {
                foreach (KeyValuePair <LocalDate, IDictionary <CurveName, Curve> > entry in curves.SetOfKeyValuePairs())
                {
                    RatesCurveGroup curveGroup = RatesCurveGroup.ofCurves(groupDefinition, entry.Value.values());
                    builder.put(entry.Key, curveGroup);
                }
            }
            return(builder.build());
        }