aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sql/dawn.sql8
1 files changed, 4 insertions, 4 deletions
diff --git a/sql/dawn.sql b/sql/dawn.sql
index 927b4763..82c5994d 100644
--- a/sql/dawn.sql
+++ b/sql/dawn.sql
@@ -876,7 +876,7 @@ CREATE OR REPLACE function list_positions(p_date date,
RETURNS TABLE(identifier varchar(12), description varchar(32), notional float, strategy bond_strat,
curr_cpn float, start_accrued_date date, last_settle_date date,
principal_payment float, accrued_payment float, currency currency, daycount day_count,
- bbg_type bbg_type) AS $$
+ bbg_type bbg_type, cusip varchar(9)) AS $$
DECLARE sqlquery text;
DECLARE asset_opt text;
DECLARE unsettled_opt text;
@@ -898,7 +898,7 @@ BEGIN
AND fund=$3)
SELECT DISTINCT ON (temp.identifier) securities.figi, securities.description, notional, folder,
securities.coupon, start_accrued_date, settle_date, temp.principal_payment,
- temp.accrued_payment, securities.currency, securities.day_count, securities.bbg_type
+ temp.accrued_payment, securities.currency, securities.day_count, securities.bbg_type, securities.cusip
FROM temp LEFT JOIN securities USING (identifier)
WHERE (temp.notional>0 '||unsettled_opt||') AND paid_down>$1 '||asset_opt
||' ORDER BY identifier, settle_date desc';
@@ -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) AS $$
+accrued_payment float, last_settle_date date, cusip varchar(9)) AS $$
BEGIN
RETURN QUERY
SELECT a.description, a.identifier, a.notional, c.price, a.strategy, coalesce(b.factor, 1),
@@ -948,7 +948,7 @@ 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
+ b.last_pay_date, a.principal_payment, a.accrued_payment, a.last_settle_date, a.cusip
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)