aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sql/dawn.sql17
1 files changed, 8 insertions, 9 deletions
diff --git a/sql/dawn.sql b/sql/dawn.sql
index b94a295d..39eb021c 100644
--- a/sql/dawn.sql
+++ b/sql/dawn.sql
@@ -34,11 +34,10 @@ CREATE TABLE counterparties(code varchar(12) primary key,
valuation_email2 text,
valuation_contact3 text,
valuation_email3 text,
- valuation_contact3 text,
- valuation_email3 text,
- valuation_contact4 = text,
- valuation_email4 = text,
- notes text);
+ valuation_contact4 text,
+ valuation_email4 text,
+ notes text,
+ instructions text);
CREATE INDEX ON counterparties(name);
@@ -107,8 +106,8 @@ CREATE TABLE securities(identifier varchar(12) PRIMARY KEY,
currency currency default 'USD',
bbg_type bbg_type default 'Mtge',
asset_class asset_class,
- paid_down date default 'Infinity'
- start_accrued_date date)
+ paid_down date default 'Infinity',
+ start_accrued_date date);
CREATE TABLE marks(date date,
identifier varchar(12) REFERENCES securities(identifier),
@@ -149,10 +148,10 @@ END;
$$ LANGUAGE plpgsql;
CREATE OR REPLACE function list_risk_numbers(p_date date, assetclass asset_class, include_unsettled boolean DEFAULT False)
-RETURNS TABLE(identifier varchar(12), price float, delta float, index_delta index_type, duration float, wal float,
+RETURNS TABLE(identifier varchar(12), description varchar(32), mark float, delta float, index_delta index_type, duration float, wal float,
undiscounted_price float, model_price float) AS $$
BEGIN
- RETURN QUERY SELECT a.identifier, b.price, c.delta, c.index_delta,
+ RETURN QUERY SELECT a.identifier, a.description, b.price, c.delta, c.index_delta,
c.duration, c.wal, c_undiscounted_price, c.model_price
FROM list_positions(p_date, assetclass, include_unsettled) a
LEFT JOIN (SELECT DISTINCT ON (identifier) date, marks.identifier, marks.price FROM marks