#!/opt/perl/5.8.0/bin/perl
#ident "%W%"
$run_time = ×tamp();
#$asof = substr($run_time, 0,
;
$asof = $ARGV[0];
$default_stale_cutoff = $ARGV[1];
$default_stale_cutoff = 30 if $default_stale_cutoff <= 0;
$light_yellow="#FFFF88";
$light_red="#FC8E8E";
$orange="#FFA500";
$emct_subord_map->{"SENIOR_UNSECURED"} = "sen";
$emct_subord_map->{"SENIOR_SECURED"} = "sensec";
$emct_subord_map->{"SUBORDINATE"} = "sub";
$ca_subord_map->{"SENIOR_UNSECURED"} = "sen";
$ca_subord_map->{"SENIOR_SECURED"} = "sensec";
$ca_subord_map->{"SUBORDINATE"} = "sub";
$tennor_map->{"3M"} = "3M";
$tennor_map->{"6M"} = "6M";
$tennor_map->{"1Y"} = "1Y";
$tennor_map->{"2Y"} = "2Y";
$tennor_map->{"3Y"} = "3Y";
$tennor_map->{"4Y"} = "4Y";
$tennor_map->{"5Y"} = "5Y";
$tennor_map->{"7Y"} = "7Y";
$tennor_map->{"10Y"} = "10Y";
$tennor_map->{"15Y"} = "15Y";
$tennor_map->{"20Y"} = "20Y";
$tennor_map->{"30Y"} = "30Y";
# load excluded list
$basedir = $ENV{"GCDR_BASEDIR"};
open(EX_FILE, "< $basedir/config/excluded.txt");
print "open file $basedir/config/excluded.txt\n";
while ($line = <EX_FILE>)
{
chomp($line);
# remove heading etc
if ($line =~ /^(-|\s|\|)*$|^\(.*rows affected\)$|^\(return status =.*\)$/)
{next;}
if ($line =~ /^\|exclude_type\s*\|ticker\s*\|reason\s*\|/)
{next;}
($dummy,
$excluded_type,
$ticker,
$reason) = split (/\s*\|\s*|\|/, $line);
$excluded_list->{$excluded_type}->{$ticker} = $reason;
}
close(EX_FILE);
open(MAP_FILE, "< subord_map_$asof.txt");
while ($line = <MAP_FILE>)
{
chomp($line);
# remove heading etc
if ($line =~ /^(-|\s|\|)*$|^\(.*rows affected\)$|^\(return status =.*\)$/)
{next;}
if ($line =~ /^\|code\s*\|name\s*\|/)
{next;}
($dummy,
$code,
$name) = split (/\s*\|\s*|\|/, $line);
$subord_map->{$code} = $name;
}
close(MAP_FILE);
open(MAP_FILE, "< curve_type_map_$asof.txt");
while ($line = <MAP_FILE>)
{
chomp($line);
# remove heading etc
if ($line =~ /^(-|\s|\|)*$|^\(.*rows affected\)$|^\(return status =.*\)$/)
{next;}
if ($line =~ /^\|type\s*\|name\s*\|/)
{next;}
($dummy,
$type,
$name) = split (/\s*\|\s*|\|/, $line);
$curve_type_map->{$type} = $name;
}
close(MAP_FILE);
open(MAP_FILE, "< desk_map_$asof.txt");
while ($line = <MAP_FILE>)
{
chomp($line);
# remove heading etc
if ($line =~ /^(-|\s|\|)*$|^\(.*rows affected\)$|^\(return status =.*\)$/)
{next;}
if ($line =~ /^\|owner_code\s*\|label\s*\|/)
{next;}
($dummy,
$desk,
$label) = split (/\s*\|\s*|\|/, $line);
$desk_map->{$desk} = $label;
}
close(MAP_FILE);
open(MAP_FILE, "< sector_map_$asof.txt");
while ($line = <MAP_FILE>)
{
chomp($line);
# remove heading etc
if ($line =~ /^(-|\s|\|)*$|^\(.*rows affected\)$|^\(return status =.*\)$/)
{next;}
if ($line =~ /^\|sector_id\s*\|owner_code\s*\|label\s*\|/)
{next;}
($dummy,
$sector_id, $desk, $label) = split (/\s*\|\s*|\|/, $line);
$sector_map->{$sector_id}->{desk} = $desk;
$sector_map->{$sector_id}->{label} = $label;
}
close(MAP_FILE);
open(USER_FILE, "< user_file_${asof}.txt");
while ($line = <USER_FILE>)
{
chomp($line);
# remove heading etc
if ($line =~ /^(-|\s|\|)*$|^\(.*rows affected\)$|^\(return status =.*\)$/)
{next;}
if ($line =~ /^username/)
{next;}
($dummy, $user_id, $name) = split (/\s*\|\s*|\|/, $line);
$username_map->{$user_id} = $name;
}
close(USER_FILE);
open(ISSUER_FILE, "< issuer_map_${asof}.txt");
while ($line = <ISSUER_FILE>)
{
chomp($line);
# remove heading etc
if ($line =~ /^(-|\s|\|)*$|^\(.*rows affected\)$|^\(return status =.*\)$/)
{next;}
if ($line =~ /^issuer_id/)
{next;}
($dummy, $issuer_id, $ticker, $name, $sector_id) = split (/\s*\|\s*|\|/, $line);
$issuer_sector_map->{$issuer_id} = $sector_id;
}
close(ISSUER_FILE);
open(SNAP_FILE, "< stale_snapshot_${asof}.txt");
while ($line = <SNAP_FILE>)
{
chomp($line);
# remove heading etc
if ($line =~ /^(-|\s|\|)*$|^\(.*rows affected\)$|^\(return status =.*\)$/)
{next;}
if ($line =~ /^curve_id/)
{next;}
($curve_id, $last_date) = split (/\s*\|\s*|\|/, $line);
$last_change_date->{$curve_id} = $last_date;
}
close(SNAP_FILE);
open(BLOTTER_FILE, "< blotter_file_${asof}.txt");
while ($line = <BLOTTER_FILE>)
{
chomp($line);
# remove heading etc
if ($line =~ /^(-|\s|\|)*$|^\(.*rows affected\)$|^\(return status =.*\)$/)
{next;}
if ($line =~ /^instrument_id/)
{next;}
($dummy, $curve_id, $owner_code) = split (/\s*\|\s*|\|/, $line);
$blotter_id_sector_map->{$curve_id} = $owner_code;
}
close(BLOTTER_FILE);
open(CURVE_FILE, "< GCDR.curves_${asof}_1830.revised") or print "Cannot open GCDR.curves_${asof}_1830.revised\n";
while ($line = <CURVE_FILE>)
{
chomp($line);
# remove heading etc
if ($line =~ /^issuerName\|issuerShortCode/)
{next;}
($issuerName, $issuerShortCode, $curveCurrency, $curveSubord, $docClause, $curveId, $curveSource, $curveRecovery, $countryName, $issuerId, $curveLastModTime,
$curveRollType, $curveMaturity, $countryIsoCode, $curveType, $curveStatus, $moodyIndustry, $moodyRating, $moodyWatch, $snpRating,
$snpWatch, $moodyOutlook, $snpOutlook, $isin, $cbCurveId, $sourceLabel, $curveExternalName,
$curvePath, $curveShortCode, $curveEnteredUser, $issuerLegalName) = split (/\s*\|\s*|\|/, $line);
if ($curveStatus ne "ok") {next;}
#AP
$gcdr_curves->{$issuerShortCode}->{$curveCurrency}->{$curveSubord}->{$docClause}->{$curveType}->{$curveSource} = $curveId;
if ($curveSource eq "pc") {
$pc_map_list->{$issuerShortCode}->{$curveCurrency}->{$curveSubord}->{$docClause}->{$curveType} = $curveId;
$issuer_map->{$curveId}->{ticker} = $issuerShortCode;
$issuer_map->{$curveId}->{subord} = $curveSubord;
$issuer_sector_id = $issuer_sector_map->{$issuerId};
$ticker_sector_map->{$issuerShortCode} = &get_sector_label($issuer_sector_id);
} elsif ($curveExternalName ne "NULL") {
$src_id_to_name->{$curveId} = $curveExternalName;
$src_name_to_ticker->{$curveSource}->{$curveExternalName} = $issuerShortCode;
$src_name_to_subord->{$curveSource}->{$curveExternalName} = $curveSubord;
}
if ($curveSource eq "blotter") {
$src_id_to_name->{$curveId} = $curveShortCode;
}
}
close(CURVE_FILE);
open(CURVE_FILE, "< GCDR.curves_${asof}_1830.revised");
while ($line = <CURVE_FILE>)
{
chomp($line);
# remove heading etc
if ($line =~ /^issuerName\|issuerShortCode/)
{next;}
($issuerName, $issuerShortCode, $curveCurrency, $curveSubord, $docClause, $curveId, $curveSource, $curveRecovery, $countryName, $issuerId, $curveLastModTime,
$curveRollType, $curveMaturity, $countryIsoCode, $curveType, $curveStatus, $moodyIndustry, $moodyRating, $moodyWatch, $snpRating,
$snpWatch, $moodyOutlook, $snpOutlook, $isin, $cbCurveId, $sourceLabel, $curveExternalName,
$curvePath, $curveShortCode, $curveEnteredUser, $issuerLegalName) = split (/\s*\|\s*|\|/, $line);
if ($curveStatus ne "ok") {next;}
if ($curveSource ne "pc" && $curveExternalName ne "NULL") {
$prc_curve_id = $pc_map_list->{$issuerShortCode}->{$curveCurrency}->{$curveSubord}->{$docClause}->{$curveType};
$src_name_to_pc_id->{$curveSource}->{$curveExternalName} = $prc_curve_id;
}
}
close(CURVE_FILE);
open(LEVEL_FILE, "< GCDR.levels_${asof}_1830.roll");
while ($line = <LEVEL_FILE>)
{
chomp($line);
# remove heading etc
if ($line =~ /^curve_id\|roll/)
{next;}
($curve_id, $roll, $type, $tag, $roll_date, $date, $maturity, $maturity_string, $bid, $ask, $entered_date, $entered_user) = split (/\s*\|\s*|\|/, $line);
if ($type eq "close" && $tag eq "") {
$last_close_date->{$curve_id} = $date;
$last_close_user->{$curve_id} = $entered_user;
#AP - load mid levels
$gcdr_levels->{$curve_id}->{$tennor_map->{$maturity_string}} = ($bid + $ask)/2;
#print "$curve_id|$tennor_map->{$maturity_string}|$gcdr_levels->{$curve_id}->{$tennor_map->{$maturity_string}}\n";
}
}
close(LEVEL_FILE);
open (PCFILE, "< pc_file_$asof.txt");
while ($line = <PCFILE>)
{
chomp($line);
# remove heading etc
if ($line =~ /curve_id\b|^(-|\s|\|)*$|^\(.*rows affected\)$|^\(return status =.*\)$/)
{next;}
($dummy,
$prc_curve_id,
$prc_source,
$prc_ref_id
) = split (/\s*\|\s*|\|/, $line);
$pc_source_map->{$prc_curve_id} = $prc_source;
$pc_ref_id_map->{$prc_curve_id} = $prc_ref_id;
}
close (PCFILE);
open(PT_FILE, "< curves.csv_$asof");
while (<PT_FILE>) {
chomp;
($creditRiskId,
$issuerId,
$curveId,
$issuerNameAndSubord,
$date,
$currency,
$frequency,
$daycount,
$calendar,
$rollingConvention,
$industry,
$recovery,
$accrue,
$numPoints,
@levels) = split /,/;
$recovery *= 100.0 if $recovery != 0;
# if (defined($recovery)) {
$pt_recovery_list->{$curveId}->{$recovery} = $curveId;
# }
$prc_ticker = $issuer_map->{$curveId}->{ticker};
$prc_subord = $issuer_map->{$curveId}->{subord};
$pt_rating_list->{$prc_ticker}->{$prc_subord}->{"//"} = $curveId;
for ($i = 0; $i < $numPoints; $i++) {
$t_str = $levels[2 * $i];
$l = $levels[2 * $i + 1];
if ($t_str =~ /(\d+)Y\b/) {
$t = $1 . ".000000";
$pt_level_list->{$curveId}->{$t} = $l;
} elsif ($t_str =~ /(\d+)M\b/) {
$t = sprintf("%8.6f", $1 / 12.0);
$pt_level_list->{$curveId}->{$t} = $l;
}
}
}
close(PT_FILE);
@storm_trade_files = `ls mkt_tmapp_NY_STORM.*$asof*`;
foreach $storm_trade_file (@storm_trade_files) {
$storm_db = "";
open(STORM_TRADE_FILE, "< $storm_trade_file");
while ($line = <STORM_TRADE_FILE>) {
if ($line =~ /^#/) {
if ($line =~ /\|DATABASE=(\w+)\|/) {
$storm_db = $1;
}
} else {
chomp($line);
($storm_trade_id,
$oasys_id,
$type,
$description,
$curve) = split (/\|/, $line);
$storm_active_list->{"$storm_db/$curve"}->{$type} += 1;
}
}
close(STORM_TRADE_FILE);
}
open(GK_FILE, "< gk_curve_$asof.txt");
while (<GK_FILE>) {
chomp;
@fields = split /\s*\|\s*|\|/;
if ($fields[4] =~ /^Z/ && $fields[25] =~ /Default Swap/ && defined($fields[22]) && $fields[20] ne "") {
$gk_curve = "$fields[7]/$fields[20]";
$gk_recovery = $fields[22];
$prc_curve_id = $src_name_to_pc_id->{"gk"}->{$gk_curve};
if (defined($prc_curve_id)) {
$gk_recovery_list->{$prc_curve_id}->{$gk_recovery} = $gk_curve;
} else {
# Unmapped GK curve
}
}
}
close(GK_FILE);
open (STORM_FILE, "< storm_curves_$asof.txt");
while ($line = <STORM_FILE>)
{
chomp($line);
# remove heading etc
if ($line =~ /source\b|^(-|\s|\|)*$|^\(.*rows affected\)$|^\(return status =.*\)$/)
{next;}
($dummy,
$storm_db,
$storm_curve,
$storm_recovery,
$storm_mdy,
$storm_snp) = split (/\s*\|\s*|\|/, $line);
$storm_recovery = "" if $storm_recovery eq "NULL";
# Rating
##$storm_mdy = "-" if $storm_mdy =~ /^N|^\s*$/;
##$storm_snp = "-" if $storm_snp =~ /^N|^\s*$/;
$storm_mdy = "-" if $storm_mdy =~ /^NotRa|^\s*$/;
$storm_snp = "-" if $storm_snp =~ /^NotRa|^\s*$/;
$prc_curve_id = $src_name_to_pc_id->{"storm"}->{$storm_curve};
$prc_ticker = $src_name_to_ticker->{"storm"}->{$storm_curve};
$prc_subord = $src_name_to_subord->{"storm"}->{$storm_curve};
if (defined($storm_active_list->{"$storm_db/$storm_curve"})) {
$storm_recovery_list->{$prc_curve_id}->{$storm_recovery} = "$storm_db/$storm_curve";
$storm_rating_list->{$prc_ticker}->{$prc_subord}->{"$storm_snp/$storm_mdy/"} = "$storm_db/$storm_curve";
}
$all_storm_recovery_list->{$storm_curve}->{$storm_db} = $storm_recovery;
$all_storm_db_list->{$storm_db} = 1;
}
close(STORM_FILE);
open (MARKIT_FILE, "< markit_file_$asof.txt");
while ($line = <MARKIT_FILE>)
{
chomp($line);
# remove heading etc
if ($line =~ /instrument_id\b|^(-|\s|\|)*$|^\(.*rows affected\)$|^\(return status =.*\)$/)
{next;}
($dummy,
$markit_curve,
$markit_recovery,
$prc_curve_id,
$markit_composite) = split (/\s*\|\s*|\|/, $line);
$markit_recovery = "" if $markit_recovery eq "NULL";
$markit_curve = "" if $markit_curve eq "NULL";
$markit_composite = "" if $markit_composite eq "NULL";
$markit_composite *= 100.0 if $markit_composite != 0;
$markit_recovery_list->{$prc_curve_id}->{$markit_recovery} = $markit_curve;
$markit_comp_list->{$prc_curve_id}->{$markit_recovery} = $markit_composite;
}
close(MARKIT_FILE);
@emct_trade_files = `ls EMCT.*.$asof`;
foreach $emct_file (@emct_trade_files) {
read_emct_file($emct_file);
}
$emct_recovery_list = &read_calypso_curve_file("EMCTCurveRecoveryRate_${asof}.txt", $emct_curve_list);
@calypso_trade_files = `ls solarfeed.*.$asof`;
foreach $calypso_file (@calypso_trade_files) {
read_calypso_file($calypso_file);
}
$ca_recovery_list = &read_calypso_curve_file("FlowCurveRecoveryRate_${asof}.txt", $ca_curve_list);
open (CFILE, "< GCDR.curves_${asof}_1830.revised");
open (UFILE, "> pc_usage.csv");
open (UMAP_FILE, "> calypso_umapped.txt");
open (EUMAP_FILE, "> emct_umapped.txt");
while ($line = <CFILE>)
{
chomp($line);
# remove heading etc
if ($line =~ /^issuerName\|issuerShortCode/)
{next;}
($issuerName, $issuerShortCode, $curveCurrency, $curveSubord, $docClause, $curveId, $curveSource, $curveRecovery, $countryName, $issuerId, $curveLastModTime,
$curveRollType, $curveMaturity, $countryIsoCode, $curveType, $curveStatus, $moodyIndustry, $moodyRating, $moodyWatch, $snpRating,
$snpWatch, $moodyOutlook, $snpOutlook, $isin, $cbCurveId, $sourceLabel, $curveExternalName,
$curvePath, $curveShortCode, $curveEnteredUser, $issuerLegalName) = split (/\s*\|\s*|\|/, $line);
if ($curveStatus ne "ok") {next;}
if ($curveSource eq "pc") {
#print "Processing PC ".$curveId;
process_recovery($curveId, $issuerId, $issuerName, $issuerShortCode, $curveCurrency, $curveSubord, $docClause, $curveType, $curveRecovery)
}
}
close (CFILE);
close (UFILE);
foreach $emct_curve (sort keys %$emct_cr01_list) {
print EUMAP_FILE "$emct_curve,$emct_cr01_list->{$emct_curve}\n";
}
close (EUMAP_FILE);
foreach $ca_curve (sort keys %$ca_cr01_list) {
print UMAP_FILE "$ca_curve,$ca_cr01_list->{$ca_curve}\n";
}
close (UMAP_FILE);
@all_storm_db = sort keys %$all_storm_db_list;
open(OFILE, "> recovery_recon.${asof}.xls");
open(OSFILE, "> storm_recon.${asof}.xls");
print OFILE <<EOF;
<html>
<head>
<title>Recovery Recon Report</title>
</head>
<body>
<p>Report Date: $asof</p>
EOF
print OSFILE <<EOF;
<html>
<head>
<title>Storm Recon Report</title>
</head>
<body>
<p>Report Date: $asof</p>
<table border="1" cellpadding="0" cellspacing="0">
<tr>
<td bgcolor="$light_yellow"><b>Action</b></td>
<td bgcolor="$light_yellow"><b>Owner</b></td>
<td bgcolor="$light_yellow"><b>Marx Ticker</b></td>
<td bgcolor="$light_yellow"><b>Marx Issuer Name</b></td>
<td bgcolor="$light_yellow"><b>CCY</b></td>
<td bgcolor="$light_yellow"><b>Subord</b></td>
<td bgcolor="$light_yellow"><b>Doc Clause</b></td>
<td bgcolor="$light_yellow"><b>Type</b></td>
<td bgcolor="$light_yellow"><b>Pricing Source</b></td>
<td bgcolor="$light_yellow"><b>Pricing Curve ID</b></td>
<td bgcolor="$light_yellow"><b>Marx Recovery</b></td>
<td bgcolor="$light_yellow"><b>Storm Curve</b></td>
EOF
foreach $storm_db (@all_storm_db) {
print OSFILE <<EOF;
<td bgcolor="$light_yellow"><b>$storm_db</b></td>
EOF
}
print OSFILE " </tr>\n";
open(SUM_FILE, "> summary_$asof.txt");
print_recovery_report("Recovery Rate Reconciliation Report", \@recovery_recon_report, 0);
print_mismatch_summary("Recovery Rate Reconciliation Report");
print_recovery_report("Zero Recovery in Marx", \@zero_report, 1);
print_recovery_report("Senior Unsecured Recovery not Valid in Marx", \@senior_not_40_report, 1);
print_recovery_report("Subordinated Recovery not Valid in Marx", \@sub_not_25_report, 1);
print_excluded_report(\@recovery_excluded_report, "recovery");
close(SUM_FILE);
print OFILE <<EOF;
</body>
</html>
EOF
print OSFILE <<EOF;
</table>
</body>
</html>
EOF
close (OFILE);
close (OSFILE);
open(SUM_FILE, "> stale_summary_$asof.txt");
print_stale_report(\@stale_report);
print_excluded_report(\@stale_excluded_report, "stale");
close(SUM_FILE);
print_prod_cntrl_report(\@stale_report_prod_ctrl);
open (RFILE, "< GCDR.issuer_ratings.data.$asof");
while ($line = <RFILE>) {
chomp($line);
if ($line =~ /^issuer_id\|ticker/)
{next;}
($issuer_id, $ticker, $name, $equity_ticker, $red, $country, $region, $industry, $sub, $subord, $mdy_rating, $snp_rating, $rni_rating, $fch_rating,
$mdy_watch, $snp_watch, $rni_watch, $fch_watch, $issuer_type) = split (/\s*\|\s*|\|/, $line);
process_rating($ticker, $name, $equity_ticker, $red, $sub, $subord, $snp_rating, $mdy_rating, $fch_rating);
}
close(RFILE);
open(SUM_FILE, "> rating_summary_$asof.txt");
open(SFILE, "> rating_recon.${asof}.xls");
print SFILE <<EOF;
<html>
<head>
<title>Issuer Rating Report</title>
</head>
<body>
<p>Report Date: $asof</p>
EOF
###print_rating_report("Issuer Rating Recon Report", \@rating_report);
print_rating_report("Missing rating everywhere", \@blank_rating_report2);
print_rating_report("Missing rating in Marx but present in another", \@blank_rating_report1);
print_rating_report("Rating Mismatch", \@rating_report);
print SFILE <<EOF;
</body>
</html>
EOF
close (SFILE);
print_rating_excluded_report(\@rating_excluded_report, "rating");
close(SUM_FILE);
###########################################################################
sub read_emct_file() {
my($fname) = @_;
open(EMCT_FILE, "< $fname") or return;
while (<EMCT_FILE>) {
@fields = split /\|/;
if ($fields[0] !~ /^\*/) {
$ops_file = $fields[4];
$firm_acct = $fields[10];
$trade_type = $fields[11];
$ticker = $fields[17];
$subord = $fields[18];
$snp= $fields[19];
$mdy = $fields[20];
$fch= $fields[21];
$term_date = $fields[23];
$emct_curve = $fields[42];
$emct_recovery = $fields[43];
$ccy = $fields[45];
$cr01 = $fields[76];
$dv01 = $fields[77];
$rr01 = $fields[80];
if ($emct_curve ne "") {
$emct_cr01_list->{"$emct_curve,$firm_acct"} += $cr01;
$emct_rr01_list->{"$emct_curve,$firm_acct"} += $rr01;
} elsif ($cr01 != 0.0) {
# print "No Curve: $ticker, $cr01\n";
}
if ($trade_type eq "CreditDefaultSwap" && $term_date eq "" &&
$emct_curve =~ /^(\S+)-pc-(.+)$/) {
@tail = split /-/, $emct_curve;
$prc_curve_id = $tail[-1];
if ($prc_curve_id ne "") {
#$curve_recovery = $emct_curve_recovery_list->{$prc_curve_id};
#if (!defined($curve_recovery)) {
# $curve_recovery = $emct_recovery;
#}
#$emct_recovery_list->{$prc_curve_id}->{$curve_recovery} = $emct_curve;
$emct_curve_list->{$prc_curve_id} = $emct_curve;
# Rating
#$mdy = "-" if $mdy =~ /^N|^W|^\s*$/;
#$snp = "-" if $snp =~ /^N|^W|^\s*$/;
#$fch = "-" if $fch =~ /^N|^W|^\s*$/;
$emct_rating_list->{$ticker}->{$emct_subord_map->{$subord}}->{"$snp/$mdy/$fch"} = $emct_curve;
}
}
}
}
close(EMCT_FILE);
}
sub read_calypso_file() {
my($fname) = @_;
open(CA_FILE, "< $fname") or return;
while (<CA_FILE>) {
@fields = split /\|/;
if ($fields[0] !~ /^\*/) {
$ops_file = $fields[4];
$firm_acct = $fields[10];
$trade_type = $fields[11];
$ticker = $fields[17];
$subord = $fields[18];
$snp= $fields[19];
$mdy = $fields[20];
$fch= $fields[21];
$term_date = $fields[23];
$ca_curve = $fields[42];
$ca_recovery = $fields[43];
$ccy = $fields[45];
$cr01 = $fields[76];
$dv01 = $fields[77];
$rr01 = $fields[80];
if ($ca_curve ne "") {
$ca_cr01_list->{"$ca_curve,$firm_acct"} += $cr01;
$ca_rr01_list->{"$ca_curve,$firm_acct"} += $rr01;
} elsif ($cr01 != 0.0) {
# print "No Curve: $ticker, $cr01\n";
}
if ($trade_type eq "CreditDefaultSwap" && $term_date eq "" &&
$ca_curve =~ /^(\S+)-pc-(.+)$/) {
# AMCOR-pc-USD-SEN-MR-19965
# 03072STM7-pc-USD-SEN-mbs-64213
# 437084CE4-pc-USD-SEN-mbs-NA-71570
@tail = split /-/, $ca_curve;
$prc_curve_id = $tail[-1];
if ($prc_curve_id ne "") {
#$curve_recovery = $ca_curve_recovery_list->{$prc_curve_id};
#if (!defined($curve_recovery)) {
# $curve_recovery = $ca_recovery;
#}
#$ca_recovery_list->{$prc_curve_id}->{$curve_recovery} = $ca_curve;
$ca_curve_list->{$prc_curve_id} = $ca_curve;
# Rating
#$mdy = "-" if $mdy =~ /^N|^W|^\s*$/;
#$snp = "-" if $snp =~ /^N|^W|^\s*$/;
#$fch = "-" if $fch =~ /^N|^W|^\s*$/;
$ca_rating_list->{$ticker}->{$ca_subord_map->{$subord}}->{"$snp/$mdy/$fch"} = $ca_curve;
}
}
}
}
close(CA_FILE);
}
sub read_calypso_curve_file() {
my($fname, $curve_list) = @_;
my($curve_recovery_list) = {};
open(CA_FILE, "< $fname") or return;
while ($line = <CA_FILE>) {
chomp($line);
if ($line =~ /^ticker_name\|/)
{next;}
my ($ca_curve, $ca_recovery) = split(/\|/, $line);
if ($ca_curve =~ /^(\S+)-pc-(.+)$/) {
# AMCOR-pc-USD-SEN-MR-19965
# 03072STM7-pc-USD-SEN-mbs-64213
# 437084CE4-pc-USD-SEN-mbs-NA-71570
@tail = split /-/, $ca_curve;
$prc_curve_id = $tail[-1];
if ($prc_curve_id ne "") {
$ca_curve = $curve_list->{$prc_curve_id};
if (defined($ca_curve)) {
$curve_recovery = $ca_recovery*100.0;
$curve_recovery_list->{$prc_curve_id}->{$curve_recovery} = $ca_curve;
}
}
}
}
close(CA_FILE);
return $curve_recovery_list;
}
sub print_recovery_report() {
my($rpt_title, $rpt, $print_sector_summary) = @_;
$num_curves = scalar @$rpt;
print OFILE <<EOF;
<p><b>$rpt_title</b> ($num_curves curves)</p>
<table border="1" cellpadding="0" cellspacing="0">
<tr>
<td bgcolor="$light_yellow"><b>Action</b></td>
<td bgcolor="$light_yellow"><b>Owner</b></td>
<td bgcolor="$light_yellow"><b>Marx Ticker</b></td>
<td bgcolor="$light_yellow"><b>Marx Issuer Name</b></td>
<td bgcolor="$light_yellow"><b>CCY</b></td>
<td bgcolor="$light_yellow"><b>Subord</b></td>
<td bgcolor="$light_yellow"><b>Doc Clause</b></td>
<td bgcolor="$light_yellow"><b>Type</b></td>
<td bgcolor="$light_yellow"><b>Pricing Source</b></td>
<td bgcolor="$light_yellow"><b>Pricing Curve ID</b></td>
<td bgcolor="$light_yellow"><b>Last Close Date</b></td>
<td bgcolor="$light_yellow"><b>Username</b></td>
<td bgcolor="$light_yellow"><b>Marx Recovery</b></td>
<td bgcolor="$light_yellow"><b>Mark-It Name</b></td>
<td bgcolor="$light_yellow"><b>Mark-It Composite</b></td>
<td bgcolor="$light_yellow"><b>Mark-It Recovery</b></td>
<td bgcolor="$light_yellow"><b>EMCT Name</b></td>
<td bgcolor="$light_yellow"><b>EMCT Recovery</b></td>
<td bgcolor="$light_yellow"><b>Calypso Name</b></td>
<td bgcolor="$light_yellow"><b>Calypso Recovery</b></td>
<td bgcolor="$light_yellow"><b>PT Recovery</b></td>
<td bgcolor="$light_yellow"><b>Storm Name</b></td>
<td bgcolor="$light_yellow"><b>Storm Recovery</b></td>
<td bgcolor="$light_yellow"><b>GK Name</b></td>
<td bgcolor="$light_yellow"><b>GK Recovery</b></td>
</tr>
EOF
my($sector_summary) = {};
foreach $rec (sort {$a->{prc_sector} cmp $b->{prc_sector} || $a->{prc_source} cmp $b->{prc_source} || $a->{prc_ticker} cmp $b->{prc_ticker} || $a->{prc_currency} cmp $b->{prc_currency} || $a->{prc_subord} cmp $b->{prc_subord} || $a->{prc_doc_id} cmp $b->{prc_doc_id}} @$rpt) {
$desk = &get_summary_desk($rec->{prc_sector});
$sector_summary->{$desk} += 1;
print OFILE <<EOF;
<tr>
<td>$rec->{prc_action}</td>
<td>$rec->{prc_sector}</td>
<td>$rec->{prc_ticker}</td>
<td>$rec->{prc_iname}</td>
<td>$rec->{prc_currency}</td>
<td>$rec->{prc_subord}</td>
<td>$rec->{prc_doc_id}</td>
<td>$rec->{prc_type}</td>
<td>$rec->{prc_source}</td>
<td>$rec->{prc_curve_id}</td>
<td>$rec->{prc_last_date}</td>
<td>$rec->{prc_last_user}</td>
<td $rec->{prc_color}>$rec->{prc_recovery}</td>
<td>$rec->{markit_id}</td>
<td>$rec->{markit_comp}</td>
<td $rec->{markit_color}>$rec->{markit_recovery}</td>
<td>$rec->{emct_id}</td>
<td $rec->{emct_color}>$rec->{emct_recovery}</td>
<td>$rec->{ca_id}</td>
<td $rec->{ca_color}>$rec->{ca_recovery}</td>
<td $rec->{pt_color}>$rec->{pt_recovery}</td>
<td>$rec->{storm_id}</td>
<td $rec->{storm_color}>$rec->{storm_recovery}</td>
<td>$rec->{gk_id}</td>
<td $rec->{gk_color}>$rec->{gk_recovery}</td>
</tr>
EOF
if ($rec->{storm_id} ne "" || $rec->{prc_source} eq "storm") {
if ($rec->{storm_id} eq "" && $rec->{prc_source} eq "storm") {
$storm_curve = $src_id_to_name->{$rec->{prc_ref_id}}
} else {
$storm_curve = $rec->{storm_id};
$storm_curve =~ s/^.*\///;
}
print OSFILE <<EOF;
<tr>
<td>$rec->{prc_action}</td>
<td>$rec->{prc_sector}</td>
<td>$rec->{prc_ticker}</td>
<td>$rec->{prc_iname}</td>
<td>$rec->{prc_currency}</td>
<td>$rec->{prc_subord}</td>
<td>$rec->{prc_doc_id}</td>
<td>$rec->{prc_type}</td>
<td>$rec->{prc_source}</td>
<td>$rec->{prc_curve_id}</td>
<td $rec->{prc_color}>$rec->{prc_recovery}</td>
<td>$storm_curve</td>
EOF
foreach $storm_db (@all_storm_db) {
$storm_recovery = $all_storm_recovery_list->{$storm_curve}->{$storm_db};
$storm_color = (defined($storm_recovery) && $storm_recovery != $rec->{prc_recovery})?"bgcolor=\"$light_red\"":"";
print OSFILE <<EOF;
<td $storm_color>$storm_recovery</td>
EOF
}
print OSFILE " </tr>\n";
}
}
print OFILE <<EOF;
</table>
EOF
if ($print_sector_summary) {
print SUM_FILE "$rpt_title\n\n";
if (keys %$sector_summary > 0) {
foreach $desk (sort keys %$sector_summary) {
$n_mismatch = $sector_summary->{$desk};
print SUM_FILE sprintf "\t%35s%6d\n", ($desk,$n_mismatch);
}
} else {
print SUM_FILE sprintf "\t%35s\n", ("None");
}
print SUM_FILE "\n";
}
}
sub process_recovery() {
my($prc_curve_id, $prc_issuer_id, $prc_iname, $prc_ticker, $prc_currency, $prc_subord_id, $prc_doc_id, $prc_type_id, $prc_recovery) = @_;
#print join('|', "Processing ", $prc_curve_id, $prc_issuer_id, $prc_iname, $prc_ticker, $prc_currency, $prc_subord_id, $prc_doc_id, $prc_type_id, $prc_recovery);
$prc_source = $pc_source_map->{$prc_curve_id};
$prc_ref_id = $pc_ref_id_map->{$prc_curve_id};
#AP
$prc_owner_id = $blotter_id_sector_map->{$prc_ref_id};
$prc_sector = $desk_map->{$prc_owner_id};
$prc_subord = $subord_map->{$prc_subord_id};
$prc_type = $curve_type_map->{$prc_type_id};
$prc_recovery = 0.0 if $prc_recovery eq "NULL";
# $prc_last_date = $last_close_date->{$prc_curve_id};
$summary_desk = &get_summary_desk($prc_sector);
$prc_last_date = $last_close_date->{$prc_curve_id};
$prc_last_date_prod_ctrl = $prc_last_date;
$prc_last_change_date = $last_change_date->{$prc_curve_id};
$prc_use_level_change = "";
$prc_use_level_change_prod_ctrl = "";
$consecutive_days_closed_same = "";
if (defined($excluded_list->{"level_change"}->{$summary_desk}) && defined($prc_last_change_date) && $prc_last_change_date < $prc_last_date) {
$prc_last_date = $prc_last_change_date;
$prc_use_level_change = "Yes";
}
if (defined($excluded_list->{"level_change_prod_ctrl"}->{$summary_desk}) && defined($prc_last_change_date) && $prc_last_change_date < $prc_last_date_prod_ctrl) {
$consecutive_days_closed_same = &diff_dates($asof, $prc_last_change_date);
$prc_last_date_prod_ctrl = $prc_last_change_date;
$prc_use_level_change_prod_ctrl = "Yes";
}
$prc_last_date = "" if $prc_last_date eq "NULL";
$prc_last_date_prod_ctrl = "" if $prc_last_date_prod_ctrl eq "NULL";
$prc_last_user = $last_close_user->{$prc_curve_id};
if (defined($username_map->{$prc_last_user})) {
$prc_last_user = $username_map->{$prc_last_user};
}
my($markit_recovery, $markit_id, $markit_comp, $markit_mismatch, $markit_color);
my($pt_recovery, $pt_id, $pt_mismatch, $pt_color);
my($gk_recovery, $gk_id, $gk_mismatch, $gk_color);
my($emct_recovery, $emct_id, $emct_mismatch, $emct_color);
my($ca_recovery, $ca_id, $ca_mismatch, $ca_color);
my($storm_recovery, $storm_id, $storm_mismatch, $storm_color);
$nn = 0;
@markit_rates = sort keys %{$markit_recovery_list->{$prc_curve_id}};
$n_markit = @markit_rates;
# $nn = $n_markit if $nn < $n_markit;
@pt_rates = sort keys %{$pt_recovery_list->{$prc_curve_id}};
$n_pt = @pt_rates;
$nn = $n_pt if $nn < $n_pt;
@gk_rates = sort keys %{$gk_recovery_list->{$prc_curve_id}};
$n_gk = @gk_rates;
$nn = $n_gk if $nn < $n_gk;
@emct_rates = sort keys %{$emct_recovery_list->{$prc_curve_id}};
$n_emct = @emct_rates;
if ($n_emct > 1) {
my($ok) = 0;
foreach $emct_rate (@emct_rates) {
if ($emct_rate == $prc_recovery) {
$ok = 1;
break;
}
}
if ($ok) {
@emct_rates = ($prc_recovery);
$n_emct = @emct_rates;
}
}
$nn = $n_emct if $nn < $n_emct;
if ($emct_curve_list->{$prc_curve_id} && $n_emct == 0) {
$emct_subord = uc $prc_subord_id;
if ($prc_type_id eq "cds") {
print EUMAP_FILE "$prc_ticker-pc-$prc_currency-$emct_subord-$prc_curve_id\t$emct_curve_list->{$prc_curve_id}\n";
} else {
print EUMAP_FILE "$prc_ticker-pc-$prc_currency-$emct_subord-$prc_type_id-$prc_curve_id\t$emct_curve_list->{$prc_curve_id}\n";
}
}
@ca_rates = sort keys %{$ca_recovery_list->{$prc_curve_id}};
$n_ca = @ca_rates;
if ($n_ca > 1) {
my($ok) = 0;
foreach $ca_rate (@ca_rates) {
if ($ca_rate == $prc_recovery) {
$ok = 1;
break;
}
}
if ($ok) {
@ca_rates = ($prc_recovery);
$n_ca = @ca_rates;
}
}
$nn = $n_ca if $nn < $n_ca;
if ($ca_curve_list->{$prc_curve_id} && $n_ca == 0) {
$ca_subord = uc $prc_subord_id;
if ($prc_type_id eq "cds") {
print UMAP_FILE "$prc_ticker-pc-$prc_currency-$ca_subord-$prc_curve_id\t$ca_curve_list->{$prc_curve_id}\n";
} else {
print UMAP_FILE "$prc_ticker-pc-$prc_currency-$ca_subord-$prc_type_id-$prc_curve_id\t$ca_curve_list->{$prc_curve_id}\n";
}
}
@storm_rates = sort keys %{$storm_recovery_list->{$prc_curve_id}};
$n_storm = @storm_rates;
$nn = $n_storm if $nn < $n_storm;
$prc_senior_not_40 = 0;
$prc_sub_not_25 = 0;
$action = "";
$standard_recovery = &get_standard_recovery($prc_sector, $prc_subord, $prc_ticker, $prc_iname, "HI");
$standard_recovery_lo = &get_standard_recovery($prc_sector, $prc_subord, $prc_ticker, $prc_iname, "LO");
$prc_is_zero = (! &allow_zero_recovery($prc_sector) && $prc_recovery == 0 && $standard_recovery != 0);
if ($prc_is_zero) {
$action = &get_action($prc_source, $prc_sector, $standard_recovery, $standard_recovery_lo);
}
if ($prc_source eq "gk") {
# should not use GK
if ($prc_subord =~ /^Senior Unsecured/) {
$prc_senior_not_40 = 1;
} else {
$prc_sub_not_25 = 1;
}
$action = &get_action($prc_source, "", $standard_recovery, $standard_recovery_lo);
}
$prc_mismatch = ($prc_is_zero || $prc_senior_not_40 || $prc_sub_not_25);
$prc_color = $prc_mismatch?"bgcolor=\"$light_red\"":"";
for ($i = 0; $i < $nn; $i++) {
if ($i < $n_markit) {
$markit_recovery = $markit_rates[$i];
$markit_id = $markit_recovery_list->{$prc_curve_id}->{$markit_recovery};
$markit_comp = $markit_comp_list->{$prc_curve_id}->{$markit_recovery};
$markit_mismatch = $markit_recovery ne "" && abs($prc_recovery - $markit_recovery) >= 1.0;
$markit_color = $markit_mismatch?"bgcolor=\"$light_red\"":"";
}
if ($i < $n_pt) {
$pt_recovery = $pt_rates[$i];
$pt_id = $pt_recovery_list->{$prc_curve_id}->{$pt_recovery};
$pt_mismatch = defined($pt_recovery) && (abs($prc_recovery - $pt_recovery) >= 1.0);
$pt_color = $pt_mismatch?"bgcolor=\"$light_red\"":"";
}
if ($i < $n_gk) {
$gk_recovery = $gk_rates[$i];
$gk_id = $gk_recovery_list->{$prc_curve_id}->{$gk_recovery};
$gk_mismatch = defined($gk_recovery) && (abs($prc_recovery - $gk_recovery) >= 1.0);
$gk_color = $gk_mismatch?"bgcolor=\"$light_red\"":"";
}
if ($i < $n_emct) {
$emct_recovery = $emct_rates[$i];
$emct_id = $emct_recovery_list->{$prc_curve_id}->{$emct_recovery};
$emct_mismatch = defined($emct_recovery) && (abs($prc_recovery - $emct_recovery) >= 1.0);
$emct_color = $emct_mismatch?"bgcolor=\"$light_red\"":"";
}
if ($i < $n_ca) {
$ca_recovery = $ca_rates[$i];
$ca_id = $ca_recovery_list->{$prc_curve_id}->{$ca_recovery};
$ca_mismatch = defined($ca_recovery) && (abs($prc_recovery - $ca_recovery) >= 1.0);
$ca_color = $ca_mismatch?"bgcolor=\"$light_red\"":"";
}
if ($i < $n_storm) {
$storm_recovery = $storm_rates[$i];
$storm_id = $storm_recovery_list->{$prc_curve_id}->{$storm_recovery};
$storm_mismatch = defined($storm_recovery) && (abs($prc_recovery - $storm_recovery) >= 1.0);
$storm_color = $storm_mismatch?"bgcolor=\"$light_red\"":"";
}
if ($i == 0) {
print UFILE join(',', $prc_curve_id, $prc_ticker,
$prc_currency, $prc_subord, $prc_type, $prc_recovery,
$prc_source, "\"$prc_sector\"", $prc_last_date, $emct_id, $ca_id, $pt_id, $storm_id, $gk_id, "\n");
}
#AP
#$markit_level = $gcdr_levels->{$markit_id} #will only work if we add the markit curve_id in the query in runReconRpt.ksh, line 93
$markit_curve_id = $gcdr_curves->{$prc_ticker}->{$prc_currency}->{$prc_subord_id}->{$prc_doc_id}->{$prc_type_id}->{"markit"};
# print join('|', "PC Details", $prc_curve_id, $prc_source, $prc_ref_id);
# print join('|', "Found Markit Curve", $markit_curve_id, $prc_ticker, $prc_currency, $prc_subord_id, $prc_doc_id, $prc_type_id);
#for all in tennor_map
$markit_level_3M = $markit_curve_id ne "" ? $gcdr_levels->{$markit_curve_id}->{$tennor_map->{"3M"}} : "";
$markit_level_6M = $markit_curve_id ne "" ? $gcdr_levels->{$markit_curve_id}->{$tennor_map->{"6M"}} : "";
$markit_level_1Y = $markit_curve_id ne "" ? $gcdr_levels->{$markit_curve_id}->{$tennor_map->{"1Y"}} : "";
$markit_level_2Y = $markit_curve_id ne "" ? $gcdr_levels->{$markit_curve_id}->{$tennor_map->{"2Y"}} : "";
$markit_level_3Y = $markit_curve_id ne "" ? $gcdr_levels->{$markit_curve_id}->{$tennor_map->{"3Y"}} : "";
$markit_level_4Y = $markit_curve_id ne "" ? $gcdr_levels->{$markit_curve_id}->{$tennor_map->{"4Y"}} : "";
$markit_level_5Y = $markit_curve_id ne "" ? $gcdr_levels->{$markit_curve_id}->{$tennor_map->{"5Y"}} : "";
$markit_level_7Y = $markit_curve_id ne "" ? $gcdr_levels->{$markit_curve_id}->{$tennor_map->{"7Y"}} : "";
$markit_level_10Y = $markit_curve_id ne "" ? $gcdr_levels->{$markit_curve_id}->{$tennor_map->{"10Y"}} : "";
$markit_level_15Y = $markit_curve_id ne "" ? $gcdr_levels->{$markit_curve_id}->{$tennor_map->{"15Y"}} : "";
$markit_level_20Y = $markit_curve_id ne "" ? $gcdr_levels->{$markit_curve_id}->{$tennor_map->{"20Y"}} : "";
$markit_level_30Y = $markit_curve_id ne "" ? $gcdr_levels->{$markit_curve_id}->{$tennor_map->{"30Y"}} : "";
$prc_level_3M= $gcdr_levels->{$prc_curve_id}->{$tennor_map->{"3M"}};
$prc_level_6M= $gcdr_levels->{$prc_curve_id}->{$tennor_map->{"6M"}};
$prc_level_1Y= $gcdr_levels->{$prc_curve_id}->{$tennor_map->{"1Y"}};
$prc_level_2Y= $gcdr_levels->{$prc_curve_id}->{$tennor_map->{"2Y"}};
$prc_level_3Y= $gcdr_levels->{$prc_curve_id}->{$tennor_map->{"3Y"}};
$prc_level_4Y= $gcdr_levels->{$prc_curve_id}->{$tennor_map->{"4Y"}};
$prc_level_5Y= $gcdr_levels->{$prc_curve_id}->{$tennor_map->{"5Y"}};
$prc_level_7Y= $gcdr_levels->{$prc_curve_id}->{$tennor_map->{"7Y"}};
$prc_level_10Y= $gcdr_levels->{$prc_curve_id}->{$tennor_map->{"10Y"}};
$prc_level_15Y= $gcdr_levels->{$prc_curve_id}->{$tennor_map->{"15Y"}};
$prc_level_20Y= $gcdr_levels->{$prc_curve_id}->{$tennor_map->{"20Y"}};
$prc_level_30Y= $gcdr_levels->{$prc_curve_id}->{$tennor_map->{"30Y"}};
# print "$prc_curve_id|$prc_ticker|$prc_currency|$prc_subord_id|$prc_type_id|$prc_level_5Y|$markit_curve_id|$markit_level_5Y\n";
# print "$markit_curve_id|$tennor_map->{\"5Y\"}|$gcdr_levels->{$markit_curve_id}->{$tennor_map->{\"5Y\"}}\n";
# print "$prc_curve_id|$tennor_map->{\"5Y\"}|$gcdr_levels->{$prc_curve_id}->{$tennor_map->{\"5Y\"}}\n";
my($rec) = {};
$rec->{prc_action} = $action;
$rec->{prc_sector} = $prc_sector;
$rec->{prc_ticker} = $prc_ticker;
$rec->{prc_iname} = $prc_iname;
$rec->{prc_currency} = $prc_currency;
$rec->{prc_subord} = $prc_subord;
$rec->{prc_doc_id} = $prc_doc_id;
$rec->{prc_type} = $prc_type;
$rec->{prc_source} = $prc_source;
$rec->{prc_curve_id} = $prc_curve_id;
$rec->{prc_ref_id} = $prc_ref_id;
$rec->{prc_color} = $prc_color;
$rec->{prc_recovery} = $prc_recovery;
$rec->{prc_last_date} = $prc_last_date;
$rec->{prc_last_date_prod_ctrl} = $prc_last_date_prod_ctrl;
$rec->{consecutive_days_closed_same} = $consecutive_days_closed_same;
$rec->{prc_use_level_change} = $prc_use_level_change;
$rec->{prc_use_level_change_prod_ctrl} = $prc_use_level_change_prod_ctrl;
$rec->{prc_last_user} = $prc_last_user;
$rec->{markit_id} = $markit_id;
$rec->{markit_curve_id} = $markit_curve_id;
$rec->{markit_comp} = $markit_comp;
#AP
$rec->{prc_level_3M} = $prc_level_3M;
$rec->{prc_level_6M} = $prc_level_6M;
$rec->{prc_level_1Y} = $prc_level_1Y;
$rec->{prc_level_2Y} = $prc_level_2Y;
$rec->{prc_level_3Y} = $prc_level_3Y;
$rec->{prc_level_4Y} = $prc_level_4Y;
$rec->{prc_level_5Y} = $prc_level_5Y;
$rec->{prc_level_7Y} = $prc_level_7Y;
$rec->{prc_level_10Y} = $prc_level_10Y;
$rec->{prc_level_15Y} = $prc_level_15Y;
$rec->{prc_level_20Y} = $prc_level_20Y;
$rec->{prc_level_30Y} = $prc_level_30Y;
$rec->{markit_level_3M} = $markit_level_3M;
$rec->{markit_level_6M} = $markit_level_6M;
$rec->{markit_level_1Y} = $markit_level_1Y;
$rec->{markit_level_2Y} = $markit_level_2Y;
$rec->{markit_level_3Y} = $markit_level_3Y;
$rec->{markit_level_4Y} = $markit_level_4Y;
$rec->{markit_level_5Y} = $markit_level_5Y;
$rec->{markit_level_7Y} = $markit_level_7Y;
$rec->{markit_level_10Y} = $markit_level_10Y;
$rec->{markit_level_15Y} = $markit_level_15Y;
$rec->{markit_level_20Y} = $markit_level_20Y;
$rec->{markit_level_30Y} = $markit_level_30Y;
$rec->{diff_level_3M} = $prc_level_3M-$markit_level_3M;
$rec->{diff_level_6M} = $prc_level_6M-$markit_level_6M;
$rec->{diff_level_1Y} = $prc_level_1Y-$markit_level_1Y;
$rec->{diff_level_2Y} = $prc_level_2Y-$markit_level_2Y;
$rec->{diff_level_3Y} = $prc_level_3Y-$markit_level_3Y;
$rec->{diff_level_4Y} = $prc_level_4Y-$markit_level_4Y;
$rec->{diff_level_5Y} = $prc_level_5Y-$markit_level_5Y;
$rec->{diff_level_7Y} = $prc_level_7Y-$markit_level_7Y;
$rec->{diff_level_10Y} = $prc_level_10Y-$markit_level_10Y;
$rec->{diff_level_15Y} = $prc_level_15Y-$markit_level_15Y;
$rec->{diff_level_20Y} = $prc_level_20Y-$markit_level_20Y;
$rec->{diff_level_30Y} = $prc_level_30Y-$markit_level_30Y;
$rec->{markit_color} = $markit_color;
$rec->{markit_recovery} = $markit_recovery;
$rec->{pt_id} = $pt_id;
$rec->{pt_color} = $pt_color;
$rec->{pt_recovery} = $pt_recovery;
$rec->{gk_id} = $gk_id;
$rec->{gk_color} = $gk_color;
$rec->{gk_recovery} = $gk_recovery;
$rec->{emct_id} = $emct_id;
$rec->{emct_color} = $emct_color;
$rec->{emct_recovery} = $emct_recovery;
$rec->{ca_id} = $ca_id;
$rec->{ca_color} = $ca_color;
$rec->{ca_recovery} = $ca_recovery;
$rec->{storm_id} = $storm_id;
$rec->{storm_color} = $storm_color;
$rec->{storm_recovery} = $storm_recovery;
$rec->{workdays_stale} = 1;
$stale_excluded = &excluded_stale($rec);
$no_standard = &no_standard($rec);
if ($no_standard) {
$rec->{excluded} = $no_standard;
push(@recovery_excluded_report, $rec);
} elsif ($prc_is_zero || $prc_senior_not_40 || $prc_sub_not_25) {
if ($prc_is_zero) {
push(@zero_report, $rec);
} elsif ($prc_senior_not_40) {
push(@senior_not_40_report, $rec);
} elsif ($prc_sub_not_25) {
push(@sub_not_25_report, $rec);
}
} elsif ($pt_mismatch || $gk_mismatch || $emct_mismatch || $ca_mismatch || $storm_mismatch) {
$rec->{prc_action} = get_mismatch_action($prc_source, $prc_sector, $pt_mismatch, $gk_mismatch, $emct_mismatch, $ca_mismatch, $storm_mismatch);
push(@recovery_recon_report, $rec);
add_mismatch_summary($pt_mismatch, $gk_mismatch, $emct_mismatch, $ca_mismatch, $storm_mismatch, $storm_id);
}
#
$stale_cutoff = &stale_threshhold($rec);
if (! $stale_cutoff) {
$stale_cutoff = $default_stale_cutoff;
}
# print "Stale Cutoff used for $prc_ticker: $stale_cutoff\n";
if (($n_emct > 0 || $n_ca > 0 || $n_pt > 0 || $n_gk > 0) && ($prc_last_date eq "" || &diff_dates($asof, $prc_last_date) > $stale_cutoff) || $consecutive_days_closed_same ne "" ) {
if ($i == 0) {
if ($stale_excluded) {
$rec->{excluded} = $stale_excluded;
push(@stale_excluded_report, $rec);
} else {
$flag = 0; #prevent duplicates from being added to product control report
if ($prc_last_date eq "" || (&diff_dates($asof, $prc_last_date) > $stale_cutoff) ) {
push(@stale_report, $rec);
push(@stale_report_prod_ctrl, $rec);
$flag = 1;
}
if ($consecutive_days_closed_same ne "") {
if ($flag == 0) {
push(@stale_report_prod_ctrl, $rec);
}
}
}
}
}
}
}
sub is_dummy_curve {
my($rec) = @_;
my($excluded) = $excluded_list->{"dummy"}->{$rec->{prc_ticker}};
return $excluded if $excluded;
# Mortgages
return "" if ($rec->{prc_ticker} eq "ABXHEAAA06");
return "" if ($rec->{prc_ticker} eq "ABXHEAA06");
return "" if ($rec->{prc_ticker} eq "ABXHEA06");
return "" if ($rec->{prc_ticker} eq "ABXHEBBB06");
return "" if ($rec->{prc_ticker} eq "ABXHEBBBM6");
return "Mortgage: Dummy Curve" if ($rec->{prc_sector} =~ /Mortgage/);
return "";
}
sub no_standard() {
my($rec) = @_;
my($excluded) = $excluded_list->{"recovery"}->{$rec->{prc_ticker}};
return $excluded if $excluded;
# Paul Lim, Dan McCarthy
return "NA SN: Special Subordinated" if ($rec->{prc_ticker} eq "TSO" && $rec->{prc_subord} eq "Subordinated");
return "NSSB: non-standard rate" if ($rec->{prc_ticker} =~ /^ITRXAB5/ &&
$rec->{prc_sector} =~ /^NSSB Credit Derivatives/);
# BeachStreet
return "NA Corr: Beach Street" if ($rec->{prc_ticker} =~ /^BEACHST/ &&
$rec->{prc_iname} =~ /^LL/);
return "";
}
sub excluded_stale() {
my($rec) = @_;
$is_dummy = is_dummy_curve($rec);
return $is_dummy if $is_dummy;
my($excluded) = $excluded_list->{"stale"}->{$rec->{prc_ticker}};
return $excluded if $excluded;
return "";
}
sub excluded_rating() {
my($rec) = @_;
##$is_dummy = is_dummy_curve($rec);
##return $is_dummy if ($is_dummy =~ /Dummy/);
my($excluded) = $excluded_list->{"rating"}->{$rec->{prc_ticker}};
if ($excluded) {
$desk = &get_summary_desk($rec->{prc_sector});
return $desk;
}
return "";
}
# Threshold
sub stale_threshhold() {
my($rec) = @_;
my($threshhold) = $excluded_list->{"threshhold"}->{$rec->{prc_ticker}};
if ($threshhold) {
return $threshhold;
}
return "";
}
sub get_mismatch_action() {
my($source, $sector, $pt_mismatch, $gk_mismatch, $emct_mismatch, $ca_mismatch, $storm_mismatch) = @_;
my($action);
$action = "Correct the break of:";
if ($storm_mismatch && $sector =~ /^Latin/) {
$action .= " $source/Storm.";
} else {
$action .= " EMCT" if ($emct_mismatch);
$action .= " Calypso" if ($ca_mismatch);
$action .= " PT" if ($pt_mismatch);
$action .= " Storm" if ($storm_mismatch);
$action .= " GK" if ($gk_mismatch);
$action .= ".";
}
if ($source ne "blotter") {
$action .= " Change pricing source to blotter.";
}
return $action;
}
sub get_action() {
my($source, $sector, $recovery, $recovery_lo) = @_;
my($action);
if ($source eq "gk") {
return "Change pricing source to blotter.";
}
if ($recovery < 0) {
$action = "Change $source recovery to non-zero.";
} elsif ($recovery == $recovery_lo) {
$action = "Change $source recovery to $recovery.";
} else {
$action = "Change $source recovery to (${recovery_lo}, ${recovery}).";
}
if ($source ne "blotter") {
if ($sector eq "" || $source eq "gk") {
$action .= " Change pricing source to blotter.";
} else {
$action .= " Change pricing source to blotter.";
}
}
return $action;
}
sub allow_zero_recovery() {
my($prc_sector) = @_;
return ($prc_sector =~ /Mortgage/);
}
# return -1 if there is no standard
sub get_standard_recovery() {
my($prc_sector, $prc_subord, $prc_ticker, $prc_iname, $hi_lo) = @_;
if ($prc_sector =~ /Mortgage/) {
return -1;
}
if ($prc_sector =~ /^North America/) {
if ($prc_subord =~ /^Senior Unsecured/) {
return 40;
} elsif ($prc_subord =~ /^Subordinated/) {
return 25;
}
return -1;
}
if ($prc_sector =~ /^European Single|^European Port/) {
if ($prc_subord =~ /^Senior Unsecured/) {
return 40;
} elsif ($prc_subord =~ /^Subordinated/) {
if ($hi_lo eq "HI") {
return 25;
} else {
return 20;
}
}
return -1;
}
if ($prc_sector =~ /^NSSB Credit Derivatives/) {
if ($prc_subord =~ /^Senior Unsecured/) {
return 35;
} elsif ($prc_subord =~ /^Subordinated/) {
return 30;
}
return -1;
}
return -1;
}
sub add_mismatch_summary() {
my($pt_mismatch, $gk_mismatch, $emct_mismatch, $ca_mismatch, $storm_mismatch, $storm_id) = @_;
$mismatch_summary->{"EMCT"} += 1 if ($emct_mismatch);
$mismatch_summary->{"Calypso"} += 1 if ($ca_mismatch);
$mismatch_summary->{"PT"} += 1 if ($pt_mismatch);
$mismatch_summary->{"Storm"} += 1 if ($storm_mismatch);
$mismatch_summary->{"GK"} += 1 if ($gk_mismatch);
if ($storm_mismatch) {
$storm_db = $storm_id;
$storm_db =~ s/\/.*$//;
$storm_summary->{$storm_db} += 1;
}
}
sub print_mismatch_summary() {
my($title) = @_;
print SUM_FILE "Report Summary\n\n$title\n\n";
print_system_mismatch("EMCT");
print_system_mismatch("Calypso");
print_system_mismatch("PT");
print_system_mismatch("GK");
print_system_mismatch("Storm");
print SUM_FILE "\n";
}
sub print_system_mismatch() {
my($sys_name) = @_;
$n_mismatch = $mismatch_summary->{$sys_name};
print SUM_FILE sprintf "\t%10s%6d\n", ($sys_name, $n_mismatch);
if ($sys_name eq "Storm" && $n_mismatch > 0) {
print SUM_FILE "\t\t by database:\n";
foreach $storm_db (sort keys %$storm_summary) {
$n_mismatch = $storm_summary->{$storm_db};
print SUM_FILE sprintf "\t\t%10s%6d\n", ($storm_db, $n_mismatch);
}
}
}
sub print_stale_report() {
my($rpt) = @_;
open(SFILE, "> stale_curve.${asof}.xls");
print SFILE <<EOF;
<html>
<head>
<title>Stale Curve Report</title>
</head>
<body>
<p>Report Date: $asof</p>
<table border="1" cellpadding="0" cellspacing="0">
<tr>
<td bgcolor="$light_yellow"><b>Threshold Day Count</b></td>
<td bgcolor="$light_yellow"><b>Last Closing Date</b></td>
<td bgcolor="$light_yellow"><b>User</b></td>
<td bgcolor="$light_yellow"><b>Owner</b></td>
<td bgcolor="$light_yellow"><b>Marx Ticker</b></td>
<td bgcolor="$light_yellow"><b>Marx Issuer Name</b></td>
<td bgcolor="$light_yellow"><b>CCY</b></td>
<td bgcolor="$light_yellow"><b>Subord</b></td>
<td bgcolor="$light_yellow"><b>Doc Clause</b></td>
<td bgcolor="$light_yellow"><b>Type</b></td>
<td bgcolor="$light_yellow"><b>Pricing Source</b></td>
<td bgcolor="$light_yellow"><b>Pricing Curve ID</b></td>
<td bgcolor="$light_yellow"><b>Blotter ShortCode</b></td>
<td bgcolor="$light_yellow"><b>MarkIt Name</b></td>
<td bgcolor="$light_yellow"><b>EMCT Name</b></td>
<td bgcolor="$light_yellow"><b>Calypso Name</b></td>
<td bgcolor="$light_yellow"><b>PT Name</b></td>
<td bgcolor="$light_yellow"><b>Storm Name</b></td>
<td bgcolor="$light_yellow"><b>GK Name</b></td>
<td bgcolor="$light_yellow"><b>PC Level</b></td>
<td bgcolor="$light_yellow"><b>MarkIt Level</b></td>
<td bgcolor="$light_yellow"><b>Level Diff</b></td>
<td bgcolor="$light_yellow"><b>Workdays Stale</b></td>
<td bgcolor="$light_yellow"><b>Age Bucket</b></td>
</tr>
EOF
foreach $rec (sort {$a->{prc_last_date} cmp $b->{prc_last_date} || $a->{prc_sector} cmp $b->{prc_sector} || $a->{prc_source} cmp $b->{prc_source} || $a->{prc_ticker} cmp $b->{prc_ticker} || $a->{prc_currency} cmp $b->{prc_currency} || $a->{prc_subord} cmp $b->{prc_subord} || $a->{prc_doc_id} cmp $b->{prc_doc_id}} @$rpt) {
# Set stale color
$stale_days = &diff_dates($asof, $rec->{prc_last_date});
if ($rec->{prc_last_date} eq "" || $stale_days >= 180) {
$last_color = "bgcolor=\"$light_red\"";
} elsif ($stale_days >= 90) {
$last_color = "bgcolor=\"$light_yellow\"";
} else {
$last_color = "";
}
#AP
# Set level difference color
$level_diff_color = "";
if ($rec->{diff_level_5Y} != 0 && $rec->{markit_level_5Y} == 0) {
$level_diff_color = "bgcolor=\"$light_yellow\"";
}
elsif ( $rec->{diff_level_5Y} != 0 ) {
$level_diff_color = "bgcolor=\"$light_red\"";
}
# Threshold
$stale_cutoff = &stale_threshhold($rec);
if (! $stale_cutoff) {
$stale_cutoff = $default_stale_cutoff;
}
$rec->{prc_threshhold} = $stale_cutoff;
if ( ! (($rec->{prc_last_date} eq "") || ($rec->{prc_use_level_change} =~ /Yes/)) ) {
$temp_date = $rec->{prc_last_date};
while ( $temp_date != $asof ) {
$temp_date = `/export1/app/gcdrbatch/bin/bumpweekdays "${temp_date}" 1`;
$rec->{workdays_stale}+=1;
}
}
else {
$rec->{workdays_stale} = "";
}
$rec->{prc_last_date} = "Never Closed" if ($rec->{prc_last_date} eq "");
$rec->{prc_last_date} = "Closed same level" if ($rec->{prc_use_level_change} =~ /Yes/);
if ($rec->{prc_source} eq "markit") {
$short_code = "";
$markit_id = $src_id_to_name->{$rec->{prc_ref_id}};
} else {
$short_code = $src_id_to_name->{$rec->{prc_ref_id}};
$markit_id = $rec->{markit_id};
}
$prc_sector = $rec->{prc_sector};
$desk = &get_summary_desk($prc_sector);
$stale_summary->{$desk} += 1;
$age_bucket="";
$age_bucket_color="#FFFFFF";
if (! defined($rec->{workdays_stale}) || $rec->{workdays_stale} eq "") {
$age_bucket="Never Closed";
$age_bucket_color=$light_red;
} elsif ($rec->{workdays_stale} >= 0 && $rec->{workdays_stale} <= 15) {
$age_bucket = "0-15";
$age_bucket_color=$light_yellow;
} elsif ($rec->{workdays_stale} >= 16 && $rec->{workdays_stale} <= 30) {
$age_bucket="16-30";
$age_bucket_color=$orange;
} elsif ($rec->{workdays_stale} >= 31) {
$age_bucket="31+";
$age_bucket_color=$light_red;
}
print SFILE <<EOF;
<tr>
<td>$rec->{prc_threshhold}</td>
<td $last_color>$rec->{prc_last_date}</td>
<td>$rec->{prc_last_user}</td>
<td>$rec->{prc_sector}</td>
<td>$rec->{prc_ticker}</td>
<td>$rec->{prc_iname}</td>
<td>$rec->{prc_currency}</td>
<td>$rec->{prc_subord}</td>
<td>$rec->{prc_doc_id}</td>
<td>$rec->{prc_type}</td>
<td>$rec->{prc_source}</td>
<td>$rec->{prc_curve_id}</td>
<td>$short_code</td>
<td>$markit_id</td>
<td>$rec->{emct_id}</td>
<td>$rec->{ca_id}</td>
<td>$rec->{pt_id}</td>
<td>$rec->{storm_id}</td>
<td>$rec->{gk_id}</td>
<td>$rec->{prc_level_5Y}</td>
<td>$rec->{markit_level_5Y}</td>
<td $level_diff_color>$rec->{diff_level_5Y}</td>
<td>$rec->{workdays_stale}</td>
<td bgcolor="$age_bucket_color">$age_bucket</td>
</tr>
EOF
}
print SFILE <<EOF;
</table>
</body>
</html>
EOF
close (SFILE);
$tot_mismatch = 0;
if (keys %$stale_summary > 0) {
foreach $desk (sort keys %$stale_summary) {
$n_mismatch = $stale_summary->{$desk};
print SUM_FILE sprintf "\t%35s%6d\n", ($desk,$n_mismatch);
$tot_mismatch += $n_mismatch
}
} else {
print SUM_FILE sprintf "\t%35s\n", ("None");
}
print SUM_FILE sprintf "\n\t%35s%6d\n\n", (Total,$tot_mismatch);
print SUM_FILE sprintf "Following businesses use last changed dates instead of last closed to check staleness:\n\n";
my($use_level_change) = $excluded_list->{"level_change"};
if (keys %$use_level_change > 0) {
foreach $desk (sort keys %$use_level_change) {
print SUM_FILE sprintf "\t%35s\n", ($desk);
}
} else {
print SUM_FILE sprintf "\t%35s\n", ("None");
}
}
#Marx Stale Curve Report - Product Control
sub print_prod_cntrl_report() {
my($rpt) = @_;
open(SFILE, "> stale_curve_product_control.${asof}.xls");
print SFILE <<EOF;
<html>
<head>
<title>Marx Stale Curve Report - Product Control</title>
</head>
<body>
<p>Report Date: $asof</p>
<table border="1" cellpadding="0" cellspacing="0">
<tr>
<td bgcolor="$light_yellow"><b>Threshold Day Count</b></td>
<td bgcolor="$light_yellow"><b>Last Closing Date</b></td>
<td bgcolor="$light_yellow"><b>Days Closed At Same Levels</b></td>
<td bgcolor="$light_yellow"><b>User</b></td>
<td bgcolor="$light_yellow"><b>Owner</b></td>
<td bgcolor="$light_yellow"><b>Marx Ticker</b></td>
<td bgcolor="$light_yellow"><b>Marx Issuer Name</b></td>
<td bgcolor="$light_yellow"><b>CCY</b></td>
<td bgcolor="$light_yellow"><b>Subord</b></td>
<td bgcolor="$light_yellow"><b>Doc Clause</b></td>
<td bgcolor="$light_yellow"><b>Type</b></td>
<td bgcolor="$light_yellow"><b>Pricing Source</b></td>
<td bgcolor="$light_yellow"><b>Pricing Curve ID</b></td>
<td bgcolor="$light_yellow"><b>Blotter ShortCode</b></td>
<td bgcolor="$light_yellow"><b>MarkIt Name</b></td>
<td bgcolor="$light_yellow"><b>EMCT Name</b></td>
<td bgcolor="$light_yellow"><b>Calypso Name</b></td>
<td bgcolor="$light_yellow"><b>PT Name</b></td>
<td bgcolor="$light_yellow"><b>Storm Name</b></td>
<td bgcolor="$light_yellow"><b>GK Name</b></td>
<td bgcolor="$light_yellow"><b>PC 3M</b></td>
<td bgcolor="$light_yellow"><b>PC 6M</b></td>
<td bgcolor="$light_yellow"><b>PC 1Y</b></td>
<td bgcolor="$light_yellow"><b>PC 2Y</b></td>
<td bgcolor="$light_yellow"><b>PC 3Y</b></td>
<td bgcolor="$light_yellow"><b>PC 4Y</b></td>
<td bgcolor="$light_yellow"><b>PC 5Y</b></td>
<td bgcolor="$light_yellow"><b>PC 7Y</b></td>
<td bgcolor="$light_yellow"><b>PC 10Y</b></td>
<td bgcolor="$light_yellow"><b>PC 15Y</b></td>
<td bgcolor="$light_yellow"><b>PC 20Y</b></td>
<td bgcolor="$light_yellow"><b>PC 30Y</b></td>
<td bgcolor="$light_yellow"><b>Markit 3M</b></td>
<td bgcolor="$light_yellow"><b>Markit 6M</b></td>
<td bgcolor="$light_yellow"><b>Markit 1Y</b></td>
<td bgcolor="$light_yellow"><b>Markit 2Y</b></td>
<td bgcolor="$light_yellow"><b>Markit 3Y</b></td>
<td bgcolor="$light_yellow"><b>Markit 4Y</b></td>
<td bgcolor="$light_yellow"><b>Markit 5Y</b></td>
<td bgcolor="$light_yellow"><b>Markit 7Y</b></td>
<td bgcolor="$light_yellow"><b>Markit 10Y</b></td>
<td bgcolor="$light_yellow"><b>Markit 15Y</b></td>
<td bgcolor="$light_yellow"><b>Markit 20Y</b></td>
<td bgcolor="$light_yellow"><b>Markit 30Y</b></td>
<td bgcolor="$light_yellow"><b>Diff 3M</b></td>
<td bgcolor="$light_yellow"><b>Diff 6M</b></td>
<td bgcolor="$light_yellow"><b>Diff 1Y</b></td>
<td bgcolor="$light_yellow"><b>Diff 2Y</b></td>
<td bgcolor="$light_yellow"><b>Diff 3Y</b></td>
<td bgcolor="$light_yellow"><b>Diff 4Y</b></td>
<td bgcolor="$light_yellow"><b>Diff 5Y</b></td>
<td bgcolor="$light_yellow"><b>Diff 7Y</b></td>
<td bgcolor="$light_yellow"><b>Diff 10Y</b></td>
<td bgcolor="$light_yellow"><b>Diff 15Y</b></td>
<td bgcolor="$light_yellow"><b>Diff 20Y</b></td>
<td bgcolor="$light_yellow"><b>Diff 30Y</b></td>
</tr>
EOF
foreach $rec (sort {$a->{prc_last_date_prod_ctrl} cmp $b->{prc_last_date_prod_ctrl} || $a->{prc_sector} cmp $b->{prc_sector} || $a->{prc_source} cmp $b->{prc_source} || $a->{prc_ticker} cmp $b->{prc_ticker} || $a->{prc_currency} cmp $b->{prc_currency} || $a->{prc_subord} cmp $b->{prc_subord} || $a->{prc_doc_id} cmp $b->{prc_doc_id}} @$rpt) {
# Set stale color
$stale_days = &diff_dates($asof, $rec->{prc_last_date_prod_ctrl});
if ($rec->{prc_last_date_prod_ctrl} eq "" || $stale_days >= 180) {
$last_color = "bgcolor=\"$light_red\"";
} elsif ($stale_days >= 90) {
$last_color = "bgcolor=\"$light_yellow\"";
} else {
$last_color = "";
}
# #AP
# # Set level difference color
# #$level_diff_color = $rec->{diff_level_5Y} == 0 ? "" : "bgcolor=\"$light_red\"";
# if ($rec->{diff_level_5Y} != 0 && $rec->{markit_level_5Y} == 0) {
# $level_diff_color = "bgcolor=\"$light_yellow\"";
# }
# elsif ($rec->{diff_level_5Y} != 0) {
# }
# Threshold
$stale_cutoff = &stale_threshhold($rec);
if (! $stale_cutoff) {
$stale_cutoff = $default_stale_cutoff;
}
$rec->{prc_threshhold} = $stale_cutoff;
$rec->{prc_last_date_prod_ctrl} = "Never Closed" if ($rec->{prc_last_date_prod_ctrl} eq "");
$rec->{prc_last_date_prod_ctrl} = "Closed same level" if ($rec->{prc_use_level_change_prod_ctrl} =~ /Yes/);
if ($rec->{prc_source} eq "markit") {
$short_code = "";
$markit_id = $src_id_to_name->{$rec->{prc_ref_id}};
} else {
$short_code = $src_id_to_name->{$rec->{prc_ref_id}};
$markit_id = $rec->{markit_id};
}
$prc_sector = $rec->{prc_sector};
$desk = &get_summary_desk($prc_sector);
$stale_summary->{$desk} += 1;
print SFILE <<EOF;
<tr>
<td>$rec->{prc_threshhold}</td>
<td $last_color>$rec->{prc_last_date_prod_ctrl}</td>
<td>$rec->{consecutive_days_closed_same}</td>
<td>$rec->{prc_last_user}</td>
<td>$rec->{prc_sector}</td>
<td>$rec->{prc_ticker}</td>
<td>$rec->{prc_iname}</td>
<td>$rec->{prc_currency}</td>
<td>$rec->{prc_subord}</td>
<td>$rec->{prc_doc_id}</td>
<td>$rec->{prc_type}</td>
<td>$rec->{prc_source}</td>
<td>$rec->{prc_curve_id}</td>
<td>$short_code</td>
<td>$markit_id</td>
<td>$rec->{emct_id}</td>
<td>$rec->{ca_id}</td>
<td>$rec->{pt_id}</td>
<td>$rec->{storm_id}</td>
<td>$rec->{gk_id}</td>
<td>$rec->{prc_level_3M}</td>
<td>$rec->{prc_level_6M}</td>
<td>$rec->{prc_level_1Y}</td>
<td>$rec->{prc_level_2Y}</td>
<td>$rec->{prc_level_3Y}</td>
<td>$rec->{prc_level_4Y}</td>
<td>$rec->{prc_level_5Y}</td>
<td>$rec->{prc_level_7Y}</td>
<td>$rec->{prc_level_10Y}</td>
<td>$rec->{prc_level_15Y}</td>
<td>$rec->{prc_level_20Y}</td>
<td>$rec->{prc_level_30Y}</td>
<td>$rec->{markit_level_3M}</td>
<td>$rec->{markit_level_6M}</td>
<td>$rec->{markit_level_1Y}</td>
<td>$rec->{markit_level_2Y}</td>
<td>$rec->{markit_level_3Y}</td>
<td>$rec->{markit_level_4Y}</td>
<td>$rec->{markit_level_5Y}</td>
<td>$rec->{markit_level_7Y}</td>
<td>$rec->{markit_level_10Y}</td>
<td>$rec->{markit_level_15Y}</td>
<td>$rec->{markit_level_20Y}</td>
<td>$rec->{markit_level_30Y}</td>
<td>$rec->{diff_level_3M}</td>
<td>$rec->{diff_level_6M}</td>
<td>$rec->{diff_level_1Y}</td>
<td>$rec->{diff_level_2Y}</td>
<td>$rec->{diff_level_3Y}</td>
<td>$rec->{diff_level_4Y}</td>
<td>$rec->{diff_level_5Y}</td>
<td>$rec->{diff_level_7Y}</td>
<td>$rec->{diff_level_10Y}</td>
<td>$rec->{diff_level_15Y}</td>
<td>$rec->{diff_level_20Y}</td>
<td>$rec->{diff_level_30Y}</td>
</tr>
EOF
}
print SFILE <<EOF;
</table>
</body>
</html>
EOF
close (SFILE);
$tot_mismatch = 0;
if (keys %$stale_summary > 0) {
foreach $desk (sort keys %$stale_summary) {
$n_mismatch = $stale_summary->{$desk};
print SUM_FILE sprintf "\t%35s%6d\n", ($desk,$n_mismatch);
$tot_mismatch += $n_mismatch
}
} else {
print SUM_FILE sprintf "\t%35s\n", ("None");
}
print SUM_FILE sprintf "\n\t%35s%6d\n\n", (Total,$tot_mismatch);
}
sub print_excluded_report() {
my($rpt, $title) = @_;
my($excluded_summary) = {};
open(SFILE, "> ${title}_excluded.${asof}.xls");
print SFILE <<EOF;
<html>
<head>
<title>$title excluded report</title>
</head>
<body>
<table border="1" cellpadding="0" cellspacing="0">
<tr>
<td bgcolor="$light_yellow"><b>Reason</b></td>
<td bgcolor="$light_yellow"><b>Owner</b></td>
<td bgcolor="$light_yellow"><b>Marx Ticker</b></td>
<td bgcolor="$light_yellow"><b>Marx Issuer Name</b></td>
<td bgcolor="$light_yellow"><b>CCY</b></td>
<td bgcolor="$light_yellow"><b>Subord</b></td>
<td bgcolor="$light_yellow"><b>Doc Clause</b></td>
<td bgcolor="$light_yellow"><b>Type</b></td>
<td bgcolor="$light_yellow"><b>Pricing Source</b></td>
<td bgcolor="$light_yellow"><b>Pricing Curve ID</b></td>
<td bgcolor="$light_yellow"><b>Last Close Date</b></td>
<td bgcolor="$light_yellow"><b>Username</b></td>
<td bgcolor="$light_yellow"><b>Marx Recovery</b></td>
<td bgcolor="$light_yellow"><b>Blotter ShortCode</b></td>
<td bgcolor="$light_yellow"><b>MarkIt Name</b></td>
<td bgcolor="$light_yellow"><b>Mark-It Recovery</b></td>
<td bgcolor="$light_yellow"><b>EMCT Name</b></td>
<td bgcolor="$light_yellow"><b>EMCT Recovery</b></td>
<td bgcolor="$light_yellow"><b>Calypso Name</b></td>
<td bgcolor="$light_yellow"><b>Calypso Recovery</b></td>
<td bgcolor="$light_yellow"><b>PT Name</b></td>
<td bgcolor="$light_yellow"><b>PT Recovery</b></td>
<td bgcolor="$light_yellow"><b>Storm Name</b></td>
<td bgcolor="$light_yellow"><b>Storm Recovery</b></td>
<td bgcolor="$light_yellow"><b>GK Name</b></td>
<td bgcolor="$light_yellow"><b>GK Recovery</b></td>
</tr>
EOF
foreach $rec (sort {$a->{excluded} cmp $b->{excluded} || $a->{prc_sector} cmp $b->{prc_sector} || $a->{prc_source} cmp $b->{prc_source} || $a->{prc_ticker} cmp $b->{prc_ticker} || $a->{prc_currency} cmp $b->{prc_currency} || $a->{prc_subord} cmp $b->{prc_subord} || $a->{prc_doc_id} cmp $b->{prc_doc_id}} @$rpt) {
if ($rec->{prc_source} eq "markit") {
$short_code = "";
$markit_id = $src_id_to_name->{$rec->{prc_ref_id}};
} else {
$short_code = $src_id_to_name->{$rec->{prc_ref_id}};
$markit_id = $rec->{markit_id};
}
$prc_sector