aboutsummaryrefslogtreecommitdiffstats
path: root/sql/dawn.sql
diff options
context:
space:
mode:
Diffstat (limited to 'sql/dawn.sql')
-rw-r--r--sql/dawn.sql16
1 files changed, 16 insertions, 0 deletions
diff --git a/sql/dawn.sql b/sql/dawn.sql
index 9e7570a1..e6d7cf8a 100644
--- a/sql/dawn.sql
+++ b/sql/dawn.sql
@@ -1922,6 +1922,22 @@ AND fund=p_fund;
END;
$$ LANGUAGE plpgsql;
+CREATE OR REPLACE FUNCTION list_ir_positions(p_date date, p_fund fund)
+ RETURNS TABLE(maturity_date date, fixed_rate double precision, fund fund, folder strategy, float_index cash_rate, currency currency, clearing_facility clearing_cp, roll_day roll_day, notional double precision)
+ LANGUAGE plpgsql
+AS $function$
+BEGIN
+ RETURN QUERY SELECT i.maturity_date, i.fixed_rate, i.fund, i.folder, i.float_index, i.currency, i.clearing_facility, i.roll_day,
+ sum(CASE WHEN payreceive THEN i.notional ELSE -i.notional end) AS notional
+ FROM irs i
+ WHERE i.fund = $2 AND i.trade_date <= $1
+ GROUP BY i.maturity_date, i.fixed_rate, i.fund, i.folder, i.float_index, i.currency, i.clearing_facility, i.roll_day
+ HAVING sum(CASE WHEN payreceive THEN i.notional ELSE -i.notional end) != 0;
+END;
+$function$
+;
+
+
CREATE OR REPLACE function list_abscds_marks(p_date date, fund fund DEFAULT 'SERCGMAST'::fund)
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 $$