示例#1
0
        static IsdaCompliantIndexCurveCalibratorTest()
        {
            ImmutableList.Builder <StandardId> legalEntityIdsbuilder = ImmutableList.builder();
            ImmutableMarketDataBuilder         marketDataBuilder     = ImmutableMarketData.builder(VALUATION_DATE);
            ImmutableMarketDataBuilder         marketDataPsBuilder   = ImmutableMarketData.builder(VALUATION_DATE);

            for (int?i = 0; i.Value < INDEX_SIZE; ++i)
            {
                StandardId             legalEntityId = StandardId.of("OG", "ABC" + i.ToString());
                LegalEntityInformation information   = DEFAULTED_NAMES.contains(i) ? LegalEntityInformation.isDefaulted(legalEntityId) : LegalEntityInformation.isNotDefaulted(legalEntityId);
                legalEntityIdsbuilder.add(legalEntityId);
                marketDataBuilder.addValue(LegalEntityInformationId.of(legalEntityId), information);
                marketDataPsBuilder.addValue(LegalEntityInformationId.of(legalEntityId), information);
            }
            LEGAL_ENTITIES = legalEntityIdsbuilder.build();
            ImmutableList.Builder <CdsIndexIsdaCreditCurveNode> curveNodesBuilder   = ImmutableList.builder();
            ImmutableList.Builder <CdsIndexIsdaCreditCurveNode> curveNodesPsBuilder = ImmutableList.builder();
            for (int i = 0; i < NUM_PILLARS; ++i)
            {
                QuoteId     id   = QuoteId.of(StandardId.of("OG", INDEX_TENORS[i].ToString()));
                CdsTemplate temp = TenorCdsTemplate.of(INDEX_TENORS[i], CONVENTION);
                curveNodesBuilder.add(CdsIndexIsdaCreditCurveNode.ofPointsUpfront(temp, id, INDEX_ID, LEGAL_ENTITIES, COUPON));
                curveNodesPsBuilder.add(CdsIndexIsdaCreditCurveNode.ofParSpread(temp, id, INDEX_ID, LEGAL_ENTITIES));
                marketDataBuilder.addValue(id, PUF_QUOTES[i]);
                marketDataPsBuilder.addValue(id, PS_QUOTES[i]);
            }
            CURVE_NODES    = curveNodesBuilder.build();
            MARKET_DATA    = marketDataBuilder.build();
            CURVE_NODES_PS = curveNodesPsBuilder.build();
            MARKET_DATA_PS = marketDataPsBuilder.build();
        }
示例#2
0
        //-------------------------------------------------------------------------
        // parses the file in grid format
        private void parseGridFormat(CsvIterator csv, ListMultimap <string, CurveSensitivities> parsed, IList <FailureItem> failures)
        {
            // find the applicable reference columns
            IDictionary <string, CurveName> references = new LinkedHashMap <string, CurveName>();

            foreach (string header in csv.headers())
            {
                string headerLowerCase = header.ToLower(Locale.ENGLISH);
                if (!REF_HEADERS.contains(headerLowerCase) && !resolver.isInfoColumn(headerLowerCase))
                {
                    references[header] = CurveName.of(header);
                }
            }

            // loop around all rows, peeking to match batches with the same identifier
            // no exception catch at this level to avoid infinite loops
            while (csv.hasNext())
            {
                CsvRow            peekedRow = csv.peek();
                PortfolioItemInfo info      = parseInfo(peekedRow);
//JAVA TO C# CONVERTER TODO TASK: Method reference arbitrary object instance method syntax is not converted by Java to C# Converter:
                string id = info.Id.map(StandardId::toString).orElse("");

                // process in batches, where the ID is the same
                CurveSensitivitiesBuilder builder   = CurveSensitivities.builder(info);
                IList <CsvRow>            batchRows = csv.nextBatch(r => matchId(r, id));
                foreach (CsvRow batchRow in batchRows)
                {
                    try
                    {
                        ParameterMetadata      metadata = parseMetadata(batchRow, true);
                        CurveSensitivitiesType type     = batchRow.findValue(TYPE_HEADER).map(str => CurveSensitivitiesType.of(str)).orElse(CurveSensitivitiesType.ZERO_RATE_DELTA);
                        foreach (KeyValuePair <string, CurveName> entry in references.SetOfKeyValuePairs())
                        {
                            CurveName reference         = entry.Value;
                            CurveName resolvedCurveName = resolver.checkCurveName(reference);
                            string    valueStr          = batchRow.getField(entry.Key);
                            Currency  currency          = parseCurrency(batchRow, reference);
                            if (valueStr.Length > 0)
                            {
                                double value = LoaderUtils.parseDouble(valueStr);
                                builder.add(type, resolvedCurveName, currency, metadata, value);
                            }
                        }
                    }
                    catch (System.ArgumentException ex)
                    {
                        failures.Add(FailureItem.of(PARSING, "CSV file could not be parsed at line {}: {}", batchRow.lineNumber(), ex.Message));
                    }
                }
                CurveSensitivities sens = builder.build();
                if (!sens.TypedSensitivities.Empty)
                {
                    parsed.put(sens.Id.map(object.toString).orElse(""), sens);
                }
            }
        }
示例#3
0
        protected internal override bool subdirectoryExists(string subdirectoryName)
        {
            // classpath resources are forward-slash separated
            string resolvedName = subdirectoryName.StartsWith("/", StringComparison.Ordinal) ? subdirectoryName.Substring(1) : subdirectoryName;

            if (!resolvedName.EndsWith("/", StringComparison.Ordinal))
            {
                resolvedName += "/";
            }
            return(entries.contains(resolvedName));
        }