Process a line of a CRIF file and return true if valid line or false if an invalid line
336 {
337 CrifRecord cr;
338
339 if (entries.size() <= maxIndex) {
340 WLOG(
"Line number: " << currentLine <<
". Expected at least " << maxIndex + 1 <<
" entries but got only "
341 << entries.size());
342 return false;
343 }
344
345
346
347 auto loadOptionalString = [&entries, this](int column) {
349 };
350 auto loadOptionalReal = [&entries, this](int column) -> QuantLib::Real{
352 return QuantLib::Null<QuantLib::Real>();
353 } else{
355
358 }
359 };
360
361 string tradeId, tradeType, imModel;
362 try {
363 tradeId = loadOptionalString(0);
364 tradeType = loadOptionalString(15);
365 imModel = loadOptionalString(16);
366
367 cr.tradeId = tradeId;
368 cr.tradeType = tradeType;
369 cr.imModel = imModel;
373
374
375
377 if ((cr.riskType == RiskType::IRCurve || cr.riskType == RiskType::IRVol || cr.riskType == RiskType::FX) &&
378 cr.qualifier.size() == 3) {
379 string ccyUpper = boost::to_upper_copy(cr.qualifier);
380
381
382
383
385 cr.qualifier = ccyUpper;
386 } else if (cr.riskType == RiskType::FXVol && (cr.qualifier.size() == 6 || cr.qualifier.size() == 7)) {
387
388
389 const string ccyPairDelimiters = "/.,-_|;: ";
391
392
393 string ccy1Upper = ccyPair.first.code();
394 string ccy2Upper = ccyPair.second.code();
395
396 cr.qualifier = ccy1Upper + ccy2Upper;
397 }
398
399
401 if (boost::to_lower_copy(cr.bucket) == "residual")
402 cr.bucket = "Residual";
403
404
408 if (boost::to_lower_copy(cr.label1) == boost::to_lower_copy(l))
409 cr.label1 = l;
410 }
411 }
412
416 if (boost::to_lower_copy(cr.label2) == boost::to_lower_copy(l))
417 cr.label2 = l;
418 }
419 }
420
421
422
423
424 cr.amountCurrency = loadOptionalString(8);
425 string amountCcyUpper = boost::to_upper_copy(cr.amountCurrency);
427 cr.amountCurrency = amountCcyUpper;
428
429 cr.amount = loadOptionalReal(9);
430 cr.amountUsd = loadOptionalReal(10);
431
432
433 cr.agreementType = loadOptionalString(11);
434 cr.callType = loadOptionalString(12);
435 cr.initialMarginType = loadOptionalString(13);
436 cr.legalEntityId = loadOptionalString(14);
437 cr.nettingSetDetails = NettingSetDetails(cr.portfolioId, cr. agreementType, cr.callType, cr.initialMarginType,
438 cr.legalEntityId);
439 cr.postRegulations = loadOptionalString(17);
440 cr.collectRegulations = loadOptionalString(18);
441 cr.endDate = loadOptionalString(19);
442 cr.label3 = loadOptionalString(20);
443 cr.creditQuality = loadOptionalString(21);
444 cr.longShortInd = loadOptionalString(22);
445 cr.coveredBondInd = loadOptionalString(23);
446 cr.trancheThickness = loadOptionalString(24);
447 cr.bb_rw = loadOptionalString(25);
448
449
450 try {
452 } catch (...) {
453
454
455 }
456
457
459 std::string
value = loadOptionalString(additionalField.first);
461 cr.additionalFields[*additionalField.second.begin()] =
value;
462 }
463
464
466 } catch (const exception& e) {
468 "Line number: " +
to_string(currentLine) +
469 ". Error processing CRIF line, so skipping it. Error: " +
to_string(e.what()))
471 return false;
472 }
473
474 return true;
475}
QuantLib::ext::shared_ptr< SimmConfiguration > configuration_
Simm configuration that is used during loading of CRIF records.
void addRecordToCrif(Crif &crif, CrifRecord &&recordToAdd) const
SafeStack< ValueType > value
pair< Currency, Currency > parseCurrencyPair(const string &s, const string &delimiters)
Real parseReal(const string &s)
bool checkCurrency(const string &code)
SimmConfiguration::IMModel parseIMModel(const string &model)
CrifRecord::RiskType parseRiskType(const string &rt)
CrifRecord::ProductClass parseProductClass(const string &pc)
std::string to_string(const LocationInfo &l)