diff options
| -rw-r--r-- | sql/dawn.sql | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/sql/dawn.sql b/sql/dawn.sql index ae2631f9..1d2f0f4e 100644 --- a/sql/dawn.sql +++ b/sql/dawn.sql @@ -454,7 +454,8 @@ $$ LANGUAGE plpgsql; CREATE OR REPLACE function list_cds_marks(p_date date) RETURNS TABLE(security_id varchar(12), security_desc varchar(32), maturity date, - notional float, factor float, coupon float, duration float, clean_nav float, accrued float) AS $$ + notional float, factor float, coupon float, duration float, tenor tenor, + price float, closespread float, clean_nav float, accrued float) AS $$ DECLARE days integer; BEGIN @@ -463,10 +464,10 @@ RETURN QUERY WITH temp AS (SELECT a.*, c.index, c.series, c.version, c.tenor, c.indexfactor/100. AS fact FROM list_cds_positions(p_date) a LEFT JOIN index_desc c ON (a.security_id=c.redindexcode AND a.maturity=c.maturity)), -index_price AS (SELECT index, series, version, tenor, closeprice, index_quotes.duration - FROM index_quotes WHERE date=p_date) +index_price AS (SELECT index, series, version, d.tenor, closeprice, d.duration, d.closespread + FROM index_quotes d WHERE date=p_date) SELECT temp.security_id, temp.security_desc, temp.maturity, temp.notional, temp.fact, temp.fixed_rate/100, -index_price.duration, (index_price.closeprice/100.-1)*temp.notional*temp.fact, +index_price.duration, temp.tenor, index_price.closeprice, index_price.closespread, (index_price.closeprice/100.-1)*temp.notional*temp.fact, temp.notional*temp.fixed_rate/100.*temp.fact*days/360 FROM temp LEFT JOIN index_price USING (index, series, version, tenor); |
