aboutsummaryrefslogtreecommitdiffstats
path: root/sql
diff options
context:
space:
mode:
Diffstat (limited to 'sql')
-rw-r--r--sql/dawn.sql15
1 files changed, 15 insertions, 0 deletions
diff --git a/sql/dawn.sql b/sql/dawn.sql
index 292cd8ed..ba8c182d 100644
--- a/sql/dawn.sql
+++ b/sql/dawn.sql
@@ -676,6 +676,21 @@ ORDER BY dealid, date DESC;
END
$$ LANGUAGE plpgsql;
+CREATE OR REPLACE FUNCTION list_ir_swaption_positions(IN p_date date)
+ RETURNS TABLE(deal_id character varying, strategy swaption_strat, notional double precision,
+ option_type option_type, strike double precision, expiration_date date, maturity date,
+ initial_margin_percentage double precision) AS $$
+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
+AND a.expiration_date > p_date
+AND a.trade_date <= p_date
+AND a.swap_type = 'SWAPTION';
+END
+$$ LANGUAGE plpgsql;
+
CREATE OR REPLACE function list_abscds_marks(p_date date)
RETURNS TABLE(security_id varchar(12), cusip varchar(9), security_desc varchar(32), maturity date,
notional float, factor float, fixed_rate float, clean_nav float, accrued float) AS $$