aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sql/dawn.sql5
1 files changed, 3 insertions, 2 deletions
diff --git a/sql/dawn.sql b/sql/dawn.sql
index ba8c182d..185e028f 100644
--- a/sql/dawn.sql
+++ b/sql/dawn.sql
@@ -670,7 +670,8 @@ FROM swaptions a
JOIN (SELECT * FROM swaption_marks where date <= p_date) b USING (dealid)
JOIN index_desc c ON a.security_id=redindexcode AND a.maturity=c.maturity
LEFT JOIN (SELECT * FROM index_quotes WHERE date=p_date) d USING (index, series, tenor, version)
-WHERE termination_date IS NULL AND a.expiration_date > p_date AND trade_date <= p_date
+WHERE (termination_date IS NULL OR termination_date > p_date)
+AND a.expiration_date > p_date AND trade_date <= p_date
AND swap_type = 'CD_INDEX_OPTION'
ORDER BY dealid, date DESC;
END
@@ -684,7 +685,7 @@ BEGIN
RETURN QUERY
SELECT a.dealid, folder, (CASE WHEN buysell = 't' THEN 1 ELSE -1 END) * a.notional,
a.option_type, a.strike, a.expiration_date, a.maturity, a.initial_margin_percentage
-FROM swaptions a WHERE termination_date IS NULL
+FROM swaptions a WHERE (termination_date IS NULL OR termination_date > p_date)
AND a.expiration_date > p_date
AND a.trade_date <= p_date
AND a.swap_type = 'SWAPTION';