//-------------------------------------------------------------------------
        public virtual void test_load_all_curves()
        {
            ListMultimap <LocalDate, RatesCurveGroup> allGroups = RatesCurvesCsvLoader.loadAllDates(ResourceLocator.of(GROUPS_1), ResourceLocator.of(SETTINGS_1), ImmutableList.of(ResourceLocator.of(CURVES_1), ResourceLocator.of(CURVES_2), ResourceLocator.of(CURVES_3)));

            assertEquals(allGroups.size(), 2);
            assertCurves(allGroups.get(CURVE_DATE));

            IList <RatesCurveGroup> curves3 = allGroups.get(CURVE_DATE_CURVES_3);

            assertEquals(curves3.Count, 1);
            RatesCurveGroup group = curves3[0];

            // All curve points are set to 0 in test data to ensure these are really different curve instances
            Curve usdDisc = group.findDiscountCurve(Currency.USD).get();
            InterpolatedNodalCurve usdDiscNodal = (InterpolatedNodalCurve)usdDisc;

            assertEquals(usdDiscNodal.Metadata.CurveName, CurveName.of("USD-Disc"));
            assertTrue(usdDiscNodal.YValues.equalZeroWithTolerance(0d));

            Curve usd3ml = group.findForwardCurve(IborIndices.USD_LIBOR_3M).get();
            InterpolatedNodalCurve usd3mlNodal = (InterpolatedNodalCurve)usd3ml;

            assertEquals(usd3mlNodal.Metadata.CurveName, CurveName.of("USD-3ML"));
            assertTrue(usd3mlNodal.YValues.equalZeroWithTolerance(0d));
        }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test(expectedExceptions = IllegalArgumentException.class, expectedExceptionsMessageRegExp = "Missing settings for curve: .*") public void test_noSettings()
        public virtual void test_noSettings()
        {
            IList <RatesCurveGroup> curveGroups = RatesCurvesCsvLoader.load(CURVE_DATE, ResourceLocator.of(GROUPS_1), ResourceLocator.of(SETTINGS_EMPTY), ImmutableList.of(ResourceLocator.of(CURVES_1)));

            assertEquals(curveGroups.Count, 1);

            RatesCurveGroup curveGroup = Iterables.getOnlyElement(curveGroups);

            assertUsdDisc(curveGroup.findDiscountCurve(Currency.USD).get());
        }
        //-------------------------------------------------------------------------
        public virtual void test_writer_curve_settings()
        {
            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();

            RatesCurvesCsvLoader.writeCurveSettings(underlying, curveGroups[0]);
            string created  = underlying.ToString();
            string expected = "Curve Name,Value Type,Day Count,Interpolator,Left Extrapolator,Right Extrapolator" + Environment.NewLine +
                              "USD-Disc,zero,Act/Act ISDA,Linear,Flat,Flat" + Environment.NewLine +
                              "USD-3ML,zero,Act/Act ISDA,Linear,Flat,Flat" + Environment.NewLine;

            assertEquals(created, expected);
        }
Ejemplo n.º 4
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_writer_curve_nodes()
        {
            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();

            RatesCurvesCsvLoader.writeCurveNodes(underlying, CURVE_DATE, curveGroups[0]);
            string created  = underlying.ToString();
            string expected = "Valuation Date,Curve Name,Date,Value,Label" + Environment.NewLine +
                              "2009-07-31,USD-Disc,2009-11-06,0.001763775,3M" + Environment.NewLine +
                              "2009-07-31,USD-Disc,2010-02-08,0.002187884,6M" + Environment.NewLine +
                              "2009-07-31,USD-Disc,2010-08-06,0.004437206,1Y" + Environment.NewLine +
                              "2009-07-31,USD-Disc,2011-08-08,0.011476741,2Y" + Environment.NewLine +
                              "2009-07-31,USD-Disc,2012-08-08,0.017859057,3Y" + Environment.NewLine +
                              "2009-07-31,USD-Disc,2014-08-06,0.026257102,5Y" + Environment.NewLine +
                              "2009-07-31,USD-Disc,2019-08-07,0.035521988,10Y" + Environment.NewLine +
                              "2009-07-31,USD-3ML,2009-11-04,0.007596889,3M" + Environment.NewLine +
                              "2009-07-31,USD-3ML,2010-08-04,0.008091541,1Y" + Environment.NewLine +
                              "2009-07-31,USD-3ML,2011-08-04,0.015244398,2Y" + Environment.NewLine +
                              "2009-07-31,USD-3ML,2012-08-06,0.021598026,3Y" + Environment.NewLine +
                              "2009-07-31,USD-3ML,2014-08-05,0.029984216,5Y" + Environment.NewLine +
                              "2009-07-31,USD-3ML,2019-08-06,0.039245812,10Y" + Environment.NewLine;

            assertEquals(created, expected);
        }
        public virtual void test_load_curves_date_filtering()
        {
            IList <RatesCurveGroup> curves = RatesCurvesCsvLoader.load(CURVE_DATE, ResourceLocator.of(GROUPS_1), ResourceLocator.of(SETTINGS_1), ImmutableList.of(ResourceLocator.of(CURVES_1), ResourceLocator.of(CURVES_2), ResourceLocator.of(CURVES_3)));

            assertCurves(curves);
        }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test(expectedExceptions = IllegalArgumentException.class) public void test_invalid_curve_duplicate_points()
        public virtual void test_invalid_curve_duplicate_points()
        {
            RatesCurvesCsvLoader.load(CURVE_DATE, ResourceLocator.of(GROUPS_1), ResourceLocator.of(SETTINGS_1), ImmutableList.of(ResourceLocator.of(CURVES_INVALID_DUPLICATE_POINTS)));
        }
        public virtual void test_multiple_curves_multiple_files()
        {
            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)));

            assertCurves(curveGroups);
        }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test(expectedExceptions = IllegalArgumentException.class, expectedExceptionsMessageRegExp = "Rates curve loader found multiple curves with the same name: .*") public void test_single_curve_multiple_Files()
        public virtual void test_single_curve_multiple_Files()
        {
            RatesCurvesCsvLoader.load(CURVE_DATE, ResourceLocator.of(GROUPS_1), ResourceLocator.of(SETTINGS_1), ImmutableList.of(ResourceLocator.of(CURVES_1), ResourceLocator.of(CURVES_1)));
        }
 private void testGroups(string groupsResource)
 {
     RatesCurvesCsvLoader.load(CURVE_DATE, ResourceLocator.of(groupsResource), ResourceLocator.of(SETTINGS_1), ImmutableList.of(ResourceLocator.of(CURVES_1)));
 }
 private void testSettings(string settingsResource)
 {
     RatesCurvesCsvLoader.load(CURVE_DATE, ResourceLocator.of(GROUPS_1), ResourceLocator.of(settingsResource), ImmutableList.of(ResourceLocator.of(CURVES_1)));
 }