aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sql/dawn.sql4
1 files changed, 3 insertions, 1 deletions
diff --git a/sql/dawn.sql b/sql/dawn.sql
index c30759ea..8f9a4118 100644
--- a/sql/dawn.sql
+++ b/sql/dawn.sql
@@ -113,6 +113,8 @@ CREATE TABLE cds(id serial primary key,
detach smallint,
clearing_facility varchar(12),
isda_definition isda,
+ termination_date date DEFAULT NULL,
+ termination_amount float DEFAULT NULL,
CONSTRAINT tranche_check CHECK (swap_type != 'CD_INDEX_TRANCHE' OR
(attach IS NOT NULL AND detach IS NOT NULL)));
@@ -393,7 +395,7 @@ BEGIN
query := 'WITH tmp AS (SELECT cds.security_id, cds.security_desc, cds.maturity,
cds.fixed_rate, %s SUM(cds.notional * (CASE WHEN cds.protection=''Buyer'' THEN -1 ELSE 1 END))
OVER (PARTITION BY cds.security_id, cds.maturity, cds.attach, cds.detach) AS notional
-FROM cds WHERE cds.trade_date <=$1 %s)
+FROM cds WHERE (cds.termination_date is NULL OR cds.termination_date> $1) and cds.trade_date <=$1 %s)
SELECT DISTINCT ON (tmp.security_id, tmp.maturity %s) * FROM tmp WHERE tmp.notional!=0';
IF p_type = 'tranche' THEN