aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sql/dawn.sql5
1 files changed, 3 insertions, 2 deletions
diff --git a/sql/dawn.sql b/sql/dawn.sql
index 22d88f3e..7a46a860 100644
--- a/sql/dawn.sql
+++ b/sql/dawn.sql
@@ -1234,7 +1234,7 @@ 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,
- endbooknav,
+ coalesce(endbooknav, base_market_value),
f.ia, b.date, b.delta, b.gamma, b.vega,
b.theta, c.index, c.series, c.tenor, d.duration, c.indexfactor
FROM swaptions a
@@ -1242,13 +1242,14 @@ 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 invid = a.full_globeop_id
+LEFT JOIN bowdst_val ON link_ref = a.dealid AND as_of_date=p_date
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_marks_deriv f ON identifier=cpty_id AND f.date=p_date
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'
-AND periodenddate <= p_date
+AND (periodenddate IS NULL OR periodenddate <= p_date)
AND a.fund = p_fund
ORDER BY dealid, date DESC, periodenddate DESC;
END