コード例 #1
0
        //-------------------------------------------------------------------------
        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));
        }
        //-------------------------------------------------------------------------
        /// <summary>
        /// Loads one or more CSV format curve files for a specific date.
        /// <para>
        /// Only those quotes that match the specified date will be loaded.
        /// </para>
        /// <para>
        /// If the files contain a duplicate entry an exception will be thrown.
        ///
        /// </para>
        /// </summary>
        /// <param name="marketDataDate">  the curve date to load </param>
        /// <param name="groupsResource">  the curve groups CSV resource </param>
        /// <param name="settingsResource">  the curve settings CSV resource </param>
        /// <param name="curveValueResources">  the CSV resources for curves </param>
        /// <returns> the loaded curves, mapped by an identifying key </returns>
        /// <exception cref="IllegalArgumentException"> if the files contain a duplicate entry </exception>
        public static ImmutableList <LegalEntityCurveGroup> load(LocalDate marketDataDate, ResourceLocator groupsResource, ResourceLocator settingsResource, ICollection <ResourceLocator> curveValueResources)
        {
            ICollection <CharSource> curveCharSources           = curveValueResources.Select(r => r.CharSource).ToList();
            ListMultimap <LocalDate, LegalEntityCurveGroup> map = parse(d => marketDataDate.Equals(d), groupsResource.CharSource, settingsResource.CharSource, curveCharSources);

            return(ImmutableList.copyOf(map.get(marketDataDate)));
        }
コード例 #3
0
        // creates the tasks for a single target
        private static IList <CalculationTask> createTargetTasks <T1>(CalculationTarget resolvedTarget, int rowIndex, CalculationFunction <T1> function, IList <Column> columns)
        {
            // create the cells and group them
            ListMultimap <CalculationParameters, CalculationTaskCell> grouped = ArrayListMultimap.create();

            for (int colIndex = 0; colIndex < columns.Count; colIndex++)
            {
                Column  column  = columns[colIndex];
                Measure measure = column.Measure;

                ReportingCurrency   reportingCurrency = column.ReportingCurrency.orElse(ReportingCurrency.NATURAL);
                CalculationTaskCell cell = CalculationTaskCell.of(rowIndex, colIndex, measure, reportingCurrency);
                // group to find cells that can be shared, with same mappings and params (minus reporting currency)
                CalculationParameters @params = column.Parameters.filter(resolvedTarget, measure);
                grouped.put(@params, cell);
            }

            // build tasks
            ImmutableList.Builder <CalculationTask> taskBuilder = ImmutableList.builder();
            foreach (CalculationParameters @params in grouped.Keys)
            {
                taskBuilder.add(CalculationTask.of(resolvedTarget, function, @params, grouped.get(@params)));
            }
            return(taskBuilder.build());
        }