aboutsummaryrefslogtreecommitdiffstats
path: root/sql
diff options
context:
space:
mode:
Diffstat (limited to 'sql')
-rw-r--r--sql/dawn.sql4
1 files changed, 3 insertions, 1 deletions
diff --git a/sql/dawn.sql b/sql/dawn.sql
index 7ad59571..079cb045 100644
--- a/sql/dawn.sql
+++ b/sql/dawn.sql
@@ -1711,13 +1711,15 @@ 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 - coalesce(terminated_amount, 0.)),
a.option_type, a.strike, a.expiration_date, b.market_value,
- end_mkt_value,
+ coalesce(endbooknav, base_market_value, end_mkt_value),
f.ia, b.date, b.delta, b.gamma, b.vega,
b.theta, b.hy_equiv, c.index, c.series, c.tenor, d.duration, a.portfolio, c.indexfactor
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)
+LEFT JOIN valuation_reports ON NULLIF(substring(invid FROM '\D{3}[0]*(\d*)K'), '')::integer = a.globeop_id
+LEFT JOIN bowdst_val ON link_ref = a.dealid AND as_of_date=p_date
LEFT JOIN isosel_accrued ON a.dealid=isosel_accrued.init_fix_id
LEFT JOIN (SELECT dealid, SUM(termination_amount) AS terminated_amount
FROM terminations WHERE termination_date <= p_date GROUP BY dealid) e USING (dealid)