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 24c00a2d..bab0bb1a 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)
);
@@ -4171,4 +4172,4 @@ SELECT id,
upfront,
settle_date,
swap_type
-FROM irs JOIN counterparties ON cp_code = code) ORDER BY trade_date DESC, folder; \ No newline at end of file
+FROM irs JOIN counterparties ON cp_code = code) ORDER BY trade_date DESC, folder;