private static IDictionary <CurveName, LoadedCurveSettings> parseCurveSettings(CharSource settingsResource)
        {
            ImmutableMap.Builder <CurveName, LoadedCurveSettings> builder = ImmutableMap.builder();
            CsvFile csv = CsvFile.of(settingsResource, true);

            foreach (CsvRow row in csv.rows())
            {
                string curveNameStr         = row.getField(SETTINGS_CURVE_NAME);
                string valueTypeStr         = row.getField(SETTINGS_VALUE_TYPE);
                string dayCountStr          = row.getField(SETTINGS_DAY_COUNT);
                string interpolatorStr      = row.getField(SETTINGS_INTERPOLATOR);
                string leftExtrapolatorStr  = row.getField(SETTINGS_LEFT_EXTRAPOLATOR);
                string rightExtrapolatorStr = row.getField(SETTINGS_RIGHT_EXTRAPOLATOR);

                if (!VALUE_TYPE_MAP.containsKey(valueTypeStr.ToLower(Locale.ENGLISH)))
                {
                    throw new System.ArgumentException(Messages.format("Unsupported {} in curve settings: {}", SETTINGS_VALUE_TYPE, valueTypeStr));
                }

                CurveName         curveName    = CurveName.of(curveNameStr);
                ValueType         valueType    = VALUE_TYPE_MAP.get(valueTypeStr.ToLower(Locale.ENGLISH));
                CurveInterpolator interpolator = CurveInterpolator.of(interpolatorStr);
                CurveExtrapolator leftExtrap   = CurveExtrapolator.of(leftExtrapolatorStr);
                CurveExtrapolator rightExtrap  = CurveExtrapolator.of(rightExtrapolatorStr);
                // ONE_ONE day count is not used
                DayCount            dayCount = LoaderUtils.parseDayCount(dayCountStr);
                LoadedCurveSettings settings = LoadedCurveSettings.of(curveName, ValueType.YEAR_FRACTION, valueType, dayCount, interpolator, leftExtrap, rightExtrap);
                builder.put(curveName, settings);
            }
            return(builder.build());
        }
コード例 #2
0
 //-----------------------------------------------------------------------
 public override bool Equals(object obj)
 {
     if (obj == this)
     {
         return(true);
     }
     if (obj != null && obj.GetType() == this.GetType())
     {
         LoadedCurveSettings other = (LoadedCurveSettings)obj;
         return(JodaBeanUtils.equal(curveName, other.curveName) && JodaBeanUtils.equal(xValueType, other.xValueType) && JodaBeanUtils.equal(yValueType, other.yValueType) && JodaBeanUtils.equal(dayCount, other.dayCount) && JodaBeanUtils.equal(interpolator, other.interpolator) && JodaBeanUtils.equal(extrapolatorLeft, other.extrapolatorLeft) && JodaBeanUtils.equal(extrapolatorRight, other.extrapolatorRight));
     }
     return(false);
 }
コード例 #3
0
        //-------------------------------------------------------------------------
        public virtual void coverage()
        {
            coverPrivateConstructor(typeof(RatesCurvesCsvLoader));
            LoadedCurveKey.meta();
            coverImmutableBean(LoadedCurveKey.of(CURVE_DATE, CurveName.of("Test")));
            LoadedCurveNode.meta();
            coverImmutableBean(LoadedCurveNode.of(CURVE_DATE, 1d, "Test"));
            LoadedCurveSettings.meta();
            LoadedCurveSettings settings1 = LoadedCurveSettings.of(CurveName.of("Test"), ValueType.YEAR_FRACTION, ValueType.ZERO_RATE, DayCounts.ACT_365F, CurveInterpolators.LINEAR, CurveExtrapolators.FLAT, CurveExtrapolators.FLAT);
            LoadedCurveSettings settings2 = LoadedCurveSettings.of(CurveName.of("Test2"), ValueType.YEAR_FRACTION, ValueType.DISCOUNT_FACTOR, DayCounts.ACT_ACT_ISDA, CurveInterpolators.LOG_LINEAR, CurveExtrapolators.LINEAR, CurveExtrapolators.LINEAR);

            coverImmutableBean(settings1);
            coverBeanEquals(settings1, settings2);
        }
        private static Multimap <LocalDate, Curve> buildCurves(IDictionary <CurveName, LoadedCurveSettings> settingsMap, IDictionary <LoadedCurveKey, IList <LoadedCurveNode> > allNodes)
        {
            ImmutableMultimap.Builder <LocalDate, Curve> results = ImmutableMultimap.builder();

            foreach (KeyValuePair <LoadedCurveKey, IList <LoadedCurveNode> > entry in allNodes.SetOfKeyValuePairs())
            {
                LoadedCurveKey      key      = entry.Key;
                LoadedCurveSettings settings = settingsMap[key.CurveName];

                if (settings == null)
                {
                    throw new System.ArgumentException(Messages.format("Missing settings for curve: {}", key));
                }
                results.put(key.CurveDate, settings.createCurve(key.CurveDate, entry.Value));
            }
            return(results.build());
        }
コード例 #5
0
        // build the curves
        private static IList <CurveDefinition> buildCurveDefinition(IDictionary <CurveName, LoadedCurveSettings> settingsMap, IDictionary <CurveName, IList <CurveNode> > allNodes)
        {
            ImmutableList.Builder <CurveDefinition> results = ImmutableList.builder();

            foreach (KeyValuePair <CurveName, IList <CurveNode> > entry in allNodes.SetOfKeyValuePairs())
            {
                CurveName           name     = entry.Key;
                LoadedCurveSettings settings = settingsMap[name];

                if (settings == null)
                {
                    throw new System.ArgumentException(Messages.format("Missing settings for curve: {}", name));
                }
                results.add(settings.createCurveDefinition(entry.Value));
            }
            return(results.build());
        }