aboutsummaryrefslogtreecommitdiffstats
path: root/sql/dawn.sql
diff options
context:
space:
mode:
Diffstat (limited to 'sql/dawn.sql')
-rw-r--r--sql/dawn.sql11
1 files changed, 9 insertions, 2 deletions
diff --git a/sql/dawn.sql b/sql/dawn.sql
index 8f142814..292cd8ed 100644
--- a/sql/dawn.sql
+++ b/sql/dawn.sql
@@ -652,12 +652,18 @@ END
$$ LANGUAGE plpgsql;
CREATE OR REPLACE FUNCTION list_swaption_positions_and_risks(IN p_date date)
- RETURNS TABLE(deal_id character varying, security_id character varying, maturity date, notional double precision, swaption_type swaption_type, strike double precision, expiration_date date, market_value double precision, initial_margin_percentage double precision, latest_model_date date, delta double precision, gamma double precision, vega double precision, theta double precision, index index_type, series smallint, tenor tenor, duration double precision) AS $$
+ RETURNS TABLE(deal_id character varying, security_id character varying,
+ maturity date, notional double precision, option_type option_type,
+ strike double precision, expiration_date date, market_value double precision,
+ initial_margin_percentage double precision, latest_model_date date,
+ delta double precision, gamma double precision, vega double precision,
+ theta double precision, index index_type, series smallint, tenor tenor,
+ duration double precision) AS $$
BEGIN
RETURN QUERY
SELECT DISTINCT ON (a.dealid) a.dealid, a.security_id, c.maturity,
(CASE WHEN buysell = 't' THEN 1 ELSE -1 END) * a.notional,
- a.swaption_type, a.strike, a.expiration_date, b.market_value,
+ a.option_type, a.strike, a.expiration_date, b.market_value,
a.initial_margin_percentage, b.date, b.delta, b.gamma, b.vega,
b.theta, c.index, c.series, c.tenor, d.duration
FROM swaptions a
@@ -665,6 +671,7 @@ 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
+AND swap_type = 'CD_INDEX_OPTION'
ORDER BY dealid, date DESC;
END
$$ LANGUAGE plpgsql;