aboutsummaryrefslogtreecommitdiffstats
path: root/sql/dawn.sql
diff options
context:
space:
mode:
Diffstat (limited to 'sql/dawn.sql')
-rw-r--r--sql/dawn.sql9
1 files changed, 5 insertions, 4 deletions
diff --git a/sql/dawn.sql b/sql/dawn.sql
index 19c2d2fa..f0e09836 100644
--- a/sql/dawn.sql
+++ b/sql/dawn.sql
@@ -1019,7 +1019,7 @@ CREATE OR REPLACE FUNCTION list_swaption_positions_and_risks(IN p_date date)
maturity date, notional double precision, option_type option_type,
strike double precision, expiration_date date, serenitas_nav double precision,
globeop_nav double precision,
- initial_margin_percentage double precision, latest_model_date date,
+ initial_margin 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 $$
@@ -1030,7 +1030,7 @@ SELECT DISTINCT ON (a.dealid) a.dealid, a.security_id, c.maturity,
(CASE WHEN buysell = 't' THEN 1 ELSE -1 END) * (a.notional - coalesce(terminated_amount, 0.)),
a.option_type, a.strike, a.expiration_date, b.market_value,
endbooknav,
- a.initial_margin_percentage, b.date, b.delta, b.gamma, b.vega,
+ f.ia, 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)
@@ -1039,11 +1039,12 @@ LEFT JOIN (SELECT * FROM index_quotes WHERE date=p_date) d USING (index, series,
LEFT JOIN valuation_reports ON invid = a.globeop_id
LEFT JOIN (SELECT dealid, SUM(termination_amount) AS terminated_amount
FROM terminations WHERE termination_date <= p_date GROUP BY dealid) e USING (dealid)
+LEFT JOIN external_deriv_marks f ON a.cpty_id = f.identifier
WHERE a.notional IS DISTINCT FROM terminated_amount
AND a.expiration_date > p_date AND trade_date <= p_date
AND swap_type = 'CD_INDEX_OPTION'
-ORDER BY dealid, date DESC, periodenddate DESC
-END;
+ORDER BY dealid, date DESC, periodenddate DESC;
+END
$$ LANGUAGE plpgsql;
CREATE OR REPLACE FUNCTION public.list_ir_capfloor_positions(p_date date, p_fund fund DEFAULT 'SERCGMAST'::fund)