aboutsummaryrefslogtreecommitdiffstats
path: root/sql/dawn.sql
diff options
context:
space:
mode:
Diffstat (limited to 'sql/dawn.sql')
-rw-r--r--sql/dawn.sql13
1 files changed, 7 insertions, 6 deletions
diff --git a/sql/dawn.sql b/sql/dawn.sql
index c4b138ab..185bb576 100644
--- a/sql/dawn.sql
+++ b/sql/dawn.sql
@@ -1072,9 +1072,9 @@ AS SELECT bonds.dealid,
bonds.accrued,
bonds.folder,
bonds.portfolio,
- bonds.principal_payment * bond_allocation.notional / sum(bond_allocation.notional) OVER w AS principal_payment,
- bonds.accrued_payment * bond_allocation.notional / sum(bond_allocation.notional) OVER w AS accrued_payment,
- (bonds.principal_payment + bonds.accrued_payment) * bond_allocation.notional / sum(bond_allocation.notional) OVER w AS net_amount,
+ ((bond_allocation.notional / sum(bond_allocation.notional) OVER w) * bonds.principal_payment)::numeric(11, 2) AS principal_payment,
+ ((bond_allocation.notional / sum(bond_allocation.notional) OVER w) * bonds.accrued_payment)::numeric(11, 2) AS accrued_payment,
+ ((bond_allocation.notional / sum(bond_allocation.notional) OVER w) * (bonds.principal_payment + bonds.accrued_payment))::numeric(11, 2) AS net_amount,
bonds.current_face * bond_allocation.notional / sum(bond_allocation.notional) OVER w AS current_face,
bond_allocation.notional AS faceamount,
accounts.fund,
@@ -1088,6 +1088,7 @@ AS SELECT bonds.dealid,
LEFT JOIN counterparties ON bonds.cp_code = counterparties.code
WINDOW w AS (PARTITION BY bond_allocation.tradeid);
+
CREATE OR REPLACE function list_positions(p_date date,
p_class asset_class DEFAULT NULL,
include_unsettled boolean DEFAULT True,
@@ -4121,8 +4122,8 @@ CREATE TABLE bond_csv_upload(
id int4 NOT NULL GENERATED ALWAYS AS IDENTITY,
tradeid int NOT NULL,
identifier text NOT NULL,
- principal decimal NOT NULL,
- interest decimal NOT NULL,
+ principal numeric(11, 2) NOT NULL,
+ interest numeric(11, 2) NOT NULL,
CONSTRAINT unique_upload_check UNIQUE (tradeid, cusip, principal, interest)
);
@@ -4179,4 +4180,4 @@ SELECT a.security_id::text, a.maturity::date, a.INDEX, a.security_desc::text, pr
endlocalmarketprice ,
split_part(invid, '_', 2) AS security_id,
split_part(invid, '_', 6)::date AS maturity
- FROM valuation_reports WHERE invid LIKE 'CDS\_%%' AND periodenddate =p_date AND fund= p_fund) i)b USING (security_id, maturity); END $$ LANGUAGE plpgsql; \ No newline at end of file
+ FROM valuation_reports WHERE invid LIKE 'CDS\_%%' AND periodenddate =p_date AND fund= p_fund) i)b USING (security_id, maturity); END $$ LANGUAGE plpgsql;