diff options
| -rw-r--r-- | sql/dawn.sql | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/sql/dawn.sql b/sql/dawn.sql index 1fa580a1..190b819c 100644 --- a/sql/dawn.sql +++ b/sql/dawn.sql @@ -154,7 +154,7 @@ CREATE MATERIALIZED VIEW factors_history AS temp.principal / securities.face_amount * 100::double precision AS principal, temp.interest / securities.face_amount * 100::double precision AS interest, temp.losses / securities.face_amount * 100::double precision AS losses, - COALESCE(temp.coupon, securities.coupon) + COALESCE(temp.coupon, securities.coupon) AS coupon FROM temp JOIN securities USING (identifier); @@ -247,10 +247,10 @@ BEGIN SELECT a.description, a.identifier, a.notional, c.price, a.strategy, coalesce(b.factor, 1), c.price/100. * a.notional * (CASE WHEN coalesce(b.factor,1)=0 THEN 1 ELSE coalesce(b.factor,1) END), c.price/100. * a.notional * (CASE WHEN coalesce(b.factor,1)=0 THEN 1 ELSE coalesce(b.factor,1) END) * fxrate, - a.curr_cpn, + b.coupon, a.notional * coalesce(b.factor,1) * fxrate * - yearfrac(start_accrued_date, p_date+1, daycount) * a.curr_cpn/100., - b.date, a.principal_payment, a.accrued_payment, a.last_settle_date + yearfrac(case WHEN start_accrued_date>p_date+1 THEN b.prev_cpn_date ELSE start_accrued_date END, p_date+1, daycount) * b.coupon/100., + b.last_pay_date, a.principal_payment, a.accrued_payment, a.last_settle_date FROM list_positions(p_date, p_assetclass) a LEFT JOIN factors_history(p_date) b USING (identifier) LEFT JOIN list_marks(p_date, True) c USING (identifier) |
