aboutsummaryrefslogtreecommitdiffstats
path: root/sql
diff options
context:
space:
mode:
Diffstat (limited to 'sql')
-rw-r--r--sql/dawn.sql8
1 files changed, 4 insertions, 4 deletions
diff --git a/sql/dawn.sql b/sql/dawn.sql
index 1c373cb6..486bbad6 100644
--- a/sql/dawn.sql
+++ b/sql/dawn.sql
@@ -939,7 +939,7 @@ CREATE OR REPLACE function risk_positions(p_date date,
(description varchar(32), identifier varchar(12), notional float, price float,
strategy bond_strat, factor float, local_market_value float, usd_market_value float,
curr_cpn float, int_acc float, last_pay_date date, principal_payment float,
-accrued_payment float, last_settle_date date, cusip varchar(9)) AS $$
+accrued_payment float, last_settle_date date, figi varchar(12)) AS $$
BEGIN
RETURN QUERY
SELECT a.description, a.identifier, a.notional, c.price, a.strategy, coalesce(b.factor, 1),
@@ -948,10 +948,10 @@ BEGIN
b.coupon,
a.notional * coalesce(b.factor,1) * fxrate *
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, a.cusip
+ b.last_pay_date, a.principal_payment, a.accrued_payment, a.last_settle_date, a.figi
FROM list_positions(p_date, p_assetclass, true, p_fund) a
- LEFT JOIN factors_history(p_date) b USING (identifier)
- LEFT JOIN list_marks(p_date) c USING (identifier)
+ LEFT JOIN factors_history(p_date) b ON a.figi = b.identifier
+ LEFT JOIN list_marks(p_date) c ON a.figi = c.identifier
LEFT JOIN fx_rate(p_date) USING (currency)
ORDER by identifier asc;
END;