예제 #1
0
        //-------------------------------------------------------------------------
        // loads a single curves CSV file
        // requestedDate can be null, meaning load all dates
        private static IList <CurveDefinition> parseSingle(CharSource resource, IDictionary <CurveName, LoadedCurveSettings> settingsMap)
        {
            CsvFile csv = CsvFile.of(resource, true);
            IDictionary <CurveName, IList <CurveNode> > allNodes = new Dictionary <CurveName, IList <CurveNode> >();

            foreach (CsvRow row in csv.rows())
            {
                string curveNameStr      = row.getField(CURVE_NAME);
                string label             = row.getField(CURVE_LABEL);
                string symbologyQuoteStr = row.getField(CURVE_SYMBOLOGY_QUOTE);
                string tickerQuoteStr    = row.getField(CURVE_TICKER_QUOTE);
                string fieldQuoteStr     = row.getField(CURVE_FIELD_QUOTE);
                string typeStr           = row.getField(CURVE_TYPE);
                string conventionStr     = row.getField(CURVE_CONVENTION);
                string timeStr           = row.getField(CURVE_TIME);
                string dateStr           = row.findField(CURVE_DATE).orElse("");
                string minGapStr         = row.findField(CURVE_MIN_GAP).orElse("");
                string clashActionStr    = row.findField(CURVE_CLASH_ACTION).orElse("");
                string spreadStr         = row.findField(CURVE_SPREAD).orElse("");

                CurveName          curveName       = CurveName.of(curveNameStr);
                StandardId         quoteStandardId = StandardId.of(symbologyQuoteStr, tickerQuoteStr);
                FieldName          quoteField      = fieldQuoteStr.Length == 0 ? FieldName.MARKET_VALUE : FieldName.of(fieldQuoteStr);
                QuoteId            quoteId         = QuoteId.of(quoteStandardId, quoteField);
                double             spread          = spreadStr.Length == 0 ? 0d : double.Parse(spreadStr);
                CurveNodeDate      date            = parseDate(dateStr);
                CurveNodeDateOrder order           = parseDateOrder(minGapStr, clashActionStr);

                IList <CurveNode> curveNodes = allNodes.computeIfAbsent(curveName, k => new List <CurveNode>());
                curveNodes.Add(createCurveNode(typeStr, conventionStr, timeStr, label, quoteId, spread, date, order));
            }
            return(buildCurveDefinition(settingsMap, allNodes));
        }
예제 #2
0
            public override Builder set(string propertyName, object newValue)
            {
                switch (propertyName.GetHashCode())
                {
                case -1321546630:         // template
                    this.template_Renamed = (FxSwapTemplate)newValue;
                    break;

                case -1054985843:         // fxRateId
                    this.fxRateId_Renamed = (FxRateId)newValue;
                    break;

                case -566044884:         // farForwardPointsId
                    this.farForwardPointsId_Renamed = (ObservableId)newValue;
                    break;

                case 102727412:         // label
                    this.label_Renamed = (string)newValue;
                    break;

                case 3076014:         // date
                    this.date_Renamed = (CurveNodeDate)newValue;
                    break;

                case -263699392:         // dateOrder
                    this.dateOrder_Renamed = (CurveNodeDateOrder)newValue;
                    break;

                default:
                    throw new NoSuchElementException("Unknown property: " + propertyName);
                }
                return(this);
            }
예제 #3
0
            public override Builder set(string propertyName, object newValue)
            {
                switch (propertyName.GetHashCode())
                {
                case -1321546630:         // template
                    this.template_Renamed = (FixedIborSwapTemplate)newValue;
                    break;

                case -938107365:         // rateId
                    this.rateId_Renamed = (ObservableId)newValue;
                    break;

                case 291232890:         // additionalSpread
                    this.additionalSpread_Renamed = (double?)newValue.Value;
                    break;

                case 102727412:         // label
                    this.label_Renamed = (string)newValue;
                    break;

                case 3076014:         // date
                    this.date_Renamed = (CurveNodeDate)newValue;
                    break;

                case -263699392:         // dateOrder
                    this.dateOrder_Renamed = (CurveNodeDateOrder)newValue;
                    break;

                default:
                    throw new NoSuchElementException("Unknown property: " + propertyName);
                }
                return(this);
            }
예제 #4
0
 /// <summary>
 /// Restricted copy constructor. </summary>
 /// <param name="beanToCopy">  the bean to copy from, not null </param>
 internal Builder(FixedIborSwapCurveNode beanToCopy)
 {
     this.template_Renamed         = beanToCopy.Template;
     this.rateId_Renamed           = beanToCopy.RateId;
     this.additionalSpread_Renamed = beanToCopy.AdditionalSpread;
     this.label_Renamed            = beanToCopy.Label;
     this.date_Renamed             = beanToCopy.Date;
     this.dateOrder_Renamed        = beanToCopy.DateOrder;
 }
예제 #5
0
 /// <summary>
 /// Restricted copy constructor. </summary>
 /// <param name="beanToCopy">  the bean to copy from, not null </param>
 internal Builder(FxSwapCurveNode beanToCopy)
 {
     this.template_Renamed           = beanToCopy.Template;
     this.fxRateId_Renamed           = beanToCopy.FxRateId;
     this.farForwardPointsId_Renamed = beanToCopy.FarForwardPointsId;
     this.label_Renamed     = beanToCopy.Label;
     this.date_Renamed      = beanToCopy.Date;
     this.dateOrder_Renamed = beanToCopy.DateOrder;
 }
 /// <summary>
 /// Restricted copy constructor. </summary>
 /// <param name="beanToCopy">  the bean to copy from, not null </param>
 internal Builder(XCcyIborIborSwapCurveNode beanToCopy)
 {
     this.template_Renamed         = beanToCopy.Template;
     this.fxRateId_Renamed         = beanToCopy.FxRateId;
     this.spreadId_Renamed         = beanToCopy.SpreadId;
     this.additionalSpread_Renamed = beanToCopy.AdditionalSpread;
     this.label_Renamed            = beanToCopy.Label;
     this.date_Renamed             = beanToCopy.Date;
     this.dateOrder_Renamed        = beanToCopy.DateOrder;
 }
 private IborFixingDepositCurveNode(IborFixingDepositTemplate template, ObservableId rateId, double additionalSpread, string label, CurveNodeDate date, CurveNodeDateOrder dateOrder)
 {
     JodaBeanUtils.notNull(template, "template");
     JodaBeanUtils.notNull(rateId, "rateId");
     JodaBeanUtils.notEmpty(label, "label");
     JodaBeanUtils.notNull(dateOrder, "dateOrder");
     this.template         = template;
     this.rateId           = rateId;
     this.additionalSpread = additionalSpread;
     this.label            = label;
     this.date_Renamed     = date;
     this.dateOrder        = dateOrder;
 }
예제 #8
0
 private FxSwapCurveNode(FxSwapTemplate template, FxRateId fxRateId, ObservableId farForwardPointsId, string label, CurveNodeDate date, CurveNodeDateOrder dateOrder)
 {
     JodaBeanUtils.notNull(template, "template");
     JodaBeanUtils.notNull(fxRateId, "fxRateId");
     JodaBeanUtils.notNull(farForwardPointsId, "farForwardPointsId");
     JodaBeanUtils.notEmpty(label, "label");
     JodaBeanUtils.notNull(dateOrder, "dateOrder");
     this.template           = template;
     this.fxRateId           = fxRateId;
     this.farForwardPointsId = farForwardPointsId;
     this.label        = label;
     this.date_Renamed = date;
     this.dateOrder    = dateOrder;
 }
 private XCcyIborIborSwapCurveNode(XCcyIborIborSwapTemplate template, FxRateId fxRateId, ObservableId spreadId, double additionalSpread, string label, CurveNodeDate date, CurveNodeDateOrder dateOrder)
 {
     JodaBeanUtils.notNull(template, "template");
     JodaBeanUtils.notNull(fxRateId, "fxRateId");
     JodaBeanUtils.notNull(spreadId, "spreadId");
     JodaBeanUtils.notEmpty(label, "label");
     JodaBeanUtils.notNull(dateOrder, "dateOrder");
     this.template         = template;
     this.fxRateId         = fxRateId;
     this.spreadId         = spreadId;
     this.additionalSpread = additionalSpread;
     this.label            = label;
     this.date_Renamed     = date;
     this.dateOrder        = dateOrder;
 }
예제 #10
0
        // parse date order
        private static CurveNodeDateOrder parseDateOrder(string minGapStr, string clashActionStr)
        {
            CurveNodeClashAction clashAction = clashActionStr.Length == 0 ? CurveNodeClashAction.EXCEPTION : CurveNodeClashAction.of(clashActionStr);

            if (minGapStr.Length == 0)
            {
                return(CurveNodeDateOrder.of(1, clashAction));
            }
            Matcher matcher = SIMPLE_DAYS_REGEX.matcher(minGapStr.ToUpper(Locale.ENGLISH));

            if (!matcher.matches())
            {
                throw new System.ArgumentException(Messages.format("Invalid days format for minimum gap, should be 2D or P2D: {}", minGapStr));
            }
            Period minGap = Period.parse("P" + matcher.group(1));

            return(CurveNodeDateOrder.of(minGap.Days, clashAction));
        }
예제 #11
0
        private static CurveNode curveFixedInflationCurveNode(string conventionStr, string timeStr, string label, QuoteId quoteId, double spread, CurveNodeDate date, CurveNodeDateOrder order)
        {
            Matcher matcher = SIMPLE_YM_TIME_REGEX.matcher(timeStr.ToUpper(Locale.ENGLISH));

            if (!matcher.matches())
            {
                throw new System.ArgumentException(Messages.format("Invalid time format for Fixed-Inflation swap: {}", timeStr));
            }
            Period periodToEnd = Period.parse("P" + matcher.group(1));
            FixedInflationSwapConvention convention = FixedInflationSwapConvention.of(conventionStr);
            FixedInflationSwapTemplate   template   = FixedInflationSwapTemplate.of(Tenor.of(periodToEnd), convention);

            return(FixedInflationSwapCurveNode.builder().template(template).rateId(quoteId).additionalSpread(spread).label(label).date(date).dateOrder(order).build());
        }
예제 #12
0
        private static CurveNode curveFxSwapCurveNode(string conventionStr, string timeStr, string label, QuoteId quoteId, double spread, CurveNodeDate date, CurveNodeDateOrder order)
        {
            if (!DoubleMath.fuzzyEquals(spread, 0d, 1e-10d))
            {
                throw new System.ArgumentException("Additional spread must be zero for FX swaps");
            }
            Matcher matcher = SIMPLE_YMD_TIME_REGEX.matcher(timeStr.ToUpper(Locale.ENGLISH));

            if (!matcher.matches())
            {
                throw new System.ArgumentException(Messages.format("Invalid time format for FX swap: {}", timeStr));
            }
            Period           periodToEnd = Period.parse("P" + matcher.group(1));
            FxSwapConvention convention  = FxSwapConvention.of(conventionStr);
            FxSwapTemplate   template    = FxSwapTemplate.of(periodToEnd, convention);

            return(FxSwapCurveNode.builder().template(template).farForwardPointsId(quoteId).label(label).date(date).dateOrder(order).build());
        }
예제 #13
0
        private static CurveNode curveFraCurveNode(string conventionStr, string timeStr, string label, QuoteId quoteId, double spread, CurveNodeDate date, CurveNodeDateOrder order)
        {
            Matcher matcher = FRA_TIME_REGEX.matcher(timeStr.ToUpper(Locale.ENGLISH));

            if (!matcher.matches())
            {
                throw new System.ArgumentException(Messages.format("Invalid time format for FRA: {}", timeStr));
            }
            Period periodToStart = Period.parse("P" + matcher.group(1) + "M");
            Period periodToEnd   = Period.parse("P" + matcher.group(2) + "M");

            FraConvention convention = FraConvention.of(conventionStr);
            FraTemplate   template   = FraTemplate.of(periodToStart, periodToEnd, convention);

            return(FraCurveNode.builder().template(template).rateId(quoteId).additionalSpread(spread).label(label).date(date).dateOrder(order).build());
        }
예제 #14
0
        private static CurveNode curveIborFixingDepositCurveNode(string conventionStr, string label, QuoteId quoteId, double spread, CurveNodeDate date, CurveNodeDateOrder order)
        {
            IborFixingDepositConvention convention = IborFixingDepositConvention.of(conventionStr);
            IborFixingDepositTemplate   template   = IborFixingDepositTemplate.of(convention.Index.Tenor.Period, convention);

            return(IborFixingDepositCurveNode.builder().template(template).rateId(quoteId).additionalSpread(spread).label(label).date(date).dateOrder(order).build());
        }
예제 #15
0
 //-------------------------------------------------------------------------
 // create the curve node
 private static CurveNode createCurveNode(string typeStr, string conventionStr, string timeStr, string label, QuoteId quoteId, double spread, CurveNodeDate date, CurveNodeDateOrder order)
 {
     if ("DEP".Equals(typeStr, StringComparison.OrdinalIgnoreCase) || "TermDeposit".Equals(typeStr, StringComparison.OrdinalIgnoreCase))
     {
         return(curveTermDepositCurveNode(conventionStr, timeStr, label, quoteId, spread, date, order));
     }
     if ("FIX".Equals(typeStr, StringComparison.OrdinalIgnoreCase) || "IborFixingDeposit".Equals(typeStr, StringComparison.OrdinalIgnoreCase))
     {
         return(curveIborFixingDepositCurveNode(conventionStr, label, quoteId, spread, date, order));
     }
     if ("FRA".Equals(typeStr, StringComparison.OrdinalIgnoreCase))
     {
         return(curveFraCurveNode(conventionStr, timeStr, label, quoteId, spread, date, order));
     }
     if ("IFU".Equals(typeStr, StringComparison.OrdinalIgnoreCase) || "IborFuture".Equals(typeStr, StringComparison.OrdinalIgnoreCase))
     {
         return(curveIborFutureCurveNode(conventionStr, timeStr, label, quoteId, spread, date, order));
     }
     if ("OIS".Equals(typeStr, StringComparison.OrdinalIgnoreCase) || "FixedOvernightSwap".Equals(typeStr, StringComparison.OrdinalIgnoreCase))
     {
         return(curveFixedOvernightCurveNode(conventionStr, timeStr, label, quoteId, spread, date, order));
     }
     if ("IRS".Equals(typeStr, StringComparison.OrdinalIgnoreCase) || "FixedIborSwap".Equals(typeStr, StringComparison.OrdinalIgnoreCase))
     {
         return(curveFixedIborCurveNode(conventionStr, timeStr, label, quoteId, spread, date, order));
     }
     if ("BAS".Equals(typeStr, StringComparison.OrdinalIgnoreCase) || "IborIborSwap".Equals(typeStr, StringComparison.OrdinalIgnoreCase))
     {
         return(curveIborIborCurveNode(conventionStr, timeStr, label, quoteId, spread, date, order));
     }
     if ("BS3".Equals(typeStr, StringComparison.OrdinalIgnoreCase) || "ThreeLegBasisSwap".Equals(typeStr, StringComparison.OrdinalIgnoreCase))
     {
         return(curveThreeLegBasisCurveNode(conventionStr, timeStr, label, quoteId, spread, date, order));
     }
     if ("ONI".Equals(typeStr, StringComparison.OrdinalIgnoreCase) || "OvernightIborBasisSwap".Equals(typeStr, StringComparison.OrdinalIgnoreCase))
     {
         return(curveOvernightIborCurveNode(conventionStr, timeStr, label, quoteId, spread, date, order));
     }
     if ("XCS".Equals(typeStr, StringComparison.OrdinalIgnoreCase) || "XCcyIborIborSwap".Equals(typeStr, StringComparison.OrdinalIgnoreCase))
     {
         return(curveXCcyIborIborCurveNode(conventionStr, timeStr, label, quoteId, spread, date, order));
     }
     if ("FXS".Equals(typeStr, StringComparison.OrdinalIgnoreCase) || "FxSwap".Equals(typeStr, StringComparison.OrdinalIgnoreCase))
     {
         return(curveFxSwapCurveNode(conventionStr, timeStr, label, quoteId, spread, date, order));
     }
     if ("INF".Equals(typeStr, StringComparison.OrdinalIgnoreCase) || "FixedInflationSwap".Equals(typeStr, StringComparison.OrdinalIgnoreCase))
     {
         return(curveFixedInflationCurveNode(conventionStr, timeStr, label, quoteId, spread, date, order));
     }
     throw new System.ArgumentException(Messages.format("Invalid curve node type: {}", typeStr));
 }
예제 #16
0
 /// <summary>
 /// Sets the date order rules, used to ensure that the dates in the curve are in order.
 /// If not specified, this will default to <seealso cref="CurveNodeDateOrder#DEFAULT"/>. </summary>
 /// <param name="dateOrder">  the new value, not null </param>
 /// <returns> this, for chaining, not null </returns>
 public Builder dateOrder(CurveNodeDateOrder dateOrder)
 {
     JodaBeanUtils.notNull(dateOrder, "dateOrder");
     this.dateOrder_Renamed = dateOrder;
     return(this);
 }
예제 #17
0
        private static CurveNode curveIborFutureCurveNode(string conventionStr, string timeStr, string label, QuoteId quoteId, double spread, CurveNodeDate date, CurveNodeDateOrder order)
        {
            Matcher matcher = FUT_TIME_REGEX.matcher(timeStr.ToUpper(Locale.ENGLISH));

            if (matcher.matches())
            {
                Period periodToStart            = Period.parse("P" + matcher.group(1));
                int    sequenceNumber           = int.Parse(matcher.group(2));
                IborFutureConvention convention = IborFutureConvention.of(conventionStr);
                IborFutureTemplate   template   = IborFutureTemplate.of(periodToStart, sequenceNumber, convention);
                return(IborFutureCurveNode.builder().template(template).rateId(quoteId).additionalSpread(spread).label(label).date(date).dateOrder(order).build());
            }
            Matcher matcher2 = FUT_MONTH_REGEX.matcher(timeStr.ToUpper(Locale.ENGLISH));

            if (matcher2.matches())
            {
                YearMonth            yearMonth  = YearMonth.parse(matcher2.group(1), YM_FORMATTER);
                IborFutureConvention convention = IborFutureConvention.of(conventionStr);
                IborFutureTemplate   template   = IborFutureTemplate.of(yearMonth, convention);
                return(IborFutureCurveNode.builder().template(template).rateId(quoteId).additionalSpread(spread).label(label).date(date).dateOrder(order).build());
            }
            throw new System.ArgumentException(Messages.format("Invalid time format for Ibor Future: {}", timeStr));
        }