diff options
| -rw-r--r-- | sql/dawn.sql | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/sql/dawn.sql b/sql/dawn.sql index 5707d0a7..a41c4674 100644 --- a/sql/dawn.sql +++ b/sql/dawn.sql @@ -836,7 +836,7 @@ DECLARE and_clause text; BEGIN days:=days_accrued(p_date); -SELECT eurusd INTO eur_fx FROM fx WHERE date=p_date; +SELECT DISTINCT ON (date) eurusd INTO eur_fx FROM fx WHERE date BETWEEN p_date - INTERVAL '3 DAYS' AND p_date; IF strat IS NOT NULL THEN params := '$1, $4'; and_clause := 'AND strat = ltrim($4::text, ''SER_'')::strategy'; @@ -849,8 +849,8 @@ sqlquery := format( 'WITH temp AS (SELECT a.*, c.index, c.series, c.version, c.tenor, c.indexfactor/100. AS fact FROM list_cds_positions(%s) a LEFT JOIN index_desc c ON (a.security_id=c.redindexcode AND a.maturity=c.maturity)), -index_price AS (SELECT index, series, version, d.tenor, closeprice, d.duration2, d.closespread, d.theta2 - FROM index_quotes d WHERE date=$1), +index_price AS (SELECT DISTINCT ON (index, series, version, d.tenor) index, series, version, d.tenor, closeprice, d.duration2, d.closespread, d.theta2 + FROM index_quotes d WHERE date BETWEEN $1 - INTERVAL ''3 days'' AND $1 ORDER BY index, series, version, d.tenor, date desc), globeop_marks AS (SELECT security_id, maturity, sum(endqty) AS current_notional, sum(endbooknav) AS nav FROM (SELECT *, split_part(invid, ''_'', 2) AS security_id, |
