diff options
| -rw-r--r-- | sql/serenitasdb.sql | 27 |
1 files changed, 10 insertions, 17 deletions
diff --git a/sql/serenitasdb.sql b/sql/serenitasdb.sql index 0033d1dd..e27f1c62 100644 --- a/sql/serenitasdb.sql +++ b/sql/serenitasdb.sql @@ -139,7 +139,7 @@ CREATE TABLE tranche_quotes ( Basis real,
QuoteSource varchar(4),
markit_id integer UNIQUE,
- UNIQUE (QuoteDate, Index, Series, Version, Tenor, Attach, Detach, QuoteSource, trancherunningmid, markit_id)
+ UNIQUE (QuoteDate, Index, Series, Version, Tenor, Attach, Detach, QuoteSource, trancheupfront)
);
CREATE TABLE tranche_quotes_csv(
@@ -648,36 +648,29 @@ $$ r.quotesource = 'JPM' AND pg_date > '2016-04-25' THEN
CONTINUE;
END IF;
+ IF r.quotesource = 'MSre' THEN
+ CONTINUE;
+ END IF;
EXIT WHEN r.quotesource != 'CITI';
END LOOP;
- IF pg_index_type = 'HY' AND pg_series >=15 THEN
- EXECUTE
+ EXECUTE
'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'
- INTO flag
- USING pg_index_type, pg_series, pg_tenor, r.quotedate, r.quotesource, lower_attach;
- IF flag THEN
+ INTO flag
+ USING pg_index_type, pg_series, pg_tenor, r.quotedate, r.quotesource, lower_attach;
+ IF flag THEN
+ IF pg_index_type = 'HY' AND pg_series >=15 THEN
RETURN QUERY
SELECT * FROM tranche_quotes WHERE index=pg_index_type::index_type AND series= pg_series
AND tenor=pg_tenor::tenor AND quotedate=r.quotedate AND detach-attach!=5::smallint AND
quotesource=r.quotesource ORDER BY attach ASC;
- RETURN;
- END IF;
- ELSE
- EXECUTE
- '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 quotesource=$5'
- INTO flag
- USING pg_index_type, pg_series, pg_tenor, r.quotedate, r.quotesource, lower_attach;
- IF flag THEN
+ ELSE
RETURN QUERY
SELECT * FROM tranche_quotes WHERE index=pg_index_type::index_type AND series=pg_series
AND tenor=pg_tenor::tenor AND quotedate=r.quotedate AND quotesource=r.quotesource
ORDER BY attach asc;
- RETURN;
END IF;
END IF;
END;
|
