aboutsummaryrefslogtreecommitdiffstats
path: root/sql
diff options
context:
space:
mode:
Diffstat (limited to 'sql')
-rw-r--r--sql/dawn.sql6
1 files changed, 5 insertions, 1 deletions
diff --git a/sql/dawn.sql b/sql/dawn.sql
index 3ffaa44b..af7b2d4c 100644
--- a/sql/dawn.sql
+++ b/sql/dawn.sql
@@ -718,7 +718,8 @@ $$ 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, option_type option_type,
- strike double precision, expiration_date date, market_value double precision,
+ strike double precision, expiration_date date, serenitas_nav double precision,
+ globeop_nav 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,
@@ -728,15 +729,18 @@ 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.option_type, a.strike, a.expiration_date, b.market_value,
+ endbooknav,
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
LEFT JOIN (SELECT * FROM swaption_marks where date <= p_date) b USING (dealid)
LEFT 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)
+LEFT JOIN valuation_reports ON invid = a.globeop_id
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'
+AND periodenddate = p_date
ORDER BY dealid, date DESC;
END
$$ LANGUAGE plpgsql;