aboutsummaryrefslogtreecommitdiffstats
path: root/sql
diff options
context:
space:
mode:
Diffstat (limited to 'sql')
-rw-r--r--sql/serenitasdb.sql5
1 files changed, 3 insertions, 2 deletions
diff --git a/sql/serenitasdb.sql b/sql/serenitasdb.sql
index 7c76fc57..67fd9e9d 100644
--- a/sql/serenitasdb.sql
+++ b/sql/serenitasdb.sql
@@ -139,6 +139,7 @@ CREATE TABLE tranche_quotes (
Basis real,
QuoteSource varchar(4),
markit_id integer UNIQUE,
+ deleted bool DEFAULT False NOT NULL,
UNIQUE (QuoteDate, Index, Series, Version, Tenor, Attach, Detach, QuoteSource, trancheupfront)
);
@@ -656,7 +657,7 @@ $$
FOR r in EXECUTE
'SELECT DISTINCT quotesource, quotedate FROM tranche_quotes
WHERE index=$1::index_type AND series=$2 AND date(timezone(''localtime'', quotedate))=$3
- AND tenor =$4::tenor ORDER BY quotedate desc'
+ AND tenor =$4::tenor AND NOT deleted ORDER BY quotedate desc'
USING pg_index_type, pg_series, pg_date, pg_tenor LOOP
-- The JPM quotes are untriggered whereas Citi quotes are triggered
IF pg_index_type = 'XO' AND pg_series = 22 AND
@@ -670,7 +671,7 @@ $$
'SELECT array_agg(attach ORDER BY attach ASC)||100::smallint = $6||array_agg(detach ORDER BY detach ASC)
FROM tranche_quotes
WHERE index=$1::index_type AND series=$2 AND tenor=$3::tenor
- AND quotedate=$4 AND detach-attach!=5::smallint AND quotesource=$5'
+ AND quotedate=$4 AND detach-attach!=5::smallint AND quotesource=$5 AND NOT deleted'
INTO flag
USING pg_index_type, pg_series, pg_tenor, r.quotedate, r.quotesource, lower_attach;
IF flag THEN