aboutsummaryrefslogtreecommitdiffstats
path: root/sql/dawn.sql
diff options
context:
space:
mode:
Diffstat (limited to 'sql/dawn.sql')
-rw-r--r--sql/dawn.sql11
1 files changed, 5 insertions, 6 deletions
diff --git a/sql/dawn.sql b/sql/dawn.sql
index 1949cf60..b6b675aa 100644
--- a/sql/dawn.sql
+++ b/sql/dawn.sql
@@ -489,12 +489,11 @@ CREATE TABLE mark_source_mapping(
final text,
PRIMARY KEY (globeop));
-CREATE OR REPLACE function list_marks(p_date date, include_unsettled boolean DEFAULT False)
-RETURNS TABLE(identifier varchar(12), price float) AS $$
+CREATE OR REPLACE function list_marks(p_date date)
+RETURNS TABLE(p_date date, identifier varchar(12), price float) AS $$
BEGIN
- RETURN QUERY SELECT a.identifier, b.price FROM list_positions(p_date, Null, include_unsettled) a LEFT JOIN
-(SELECT DISTINCT ON (identifier) date, marks.identifier, marks.price FROM marks
-WHERE date<= p_date ORDER BY identifier, date DESC) b USING (identifier);
+ RETURN SELECT DISTINCT ON (identifier) marks.date, marks.identifier, marks.price FROM marks
+WHERE date<= p_date ORDER BY identifier, marks.date DESC;
END;
$$ LANGUAGE plpgsql;
@@ -606,7 +605,7 @@ BEGIN
b.last_pay_date, a.principal_payment, a.accrued_payment, a.last_settle_date
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, True) c USING (identifier)
+ LEFT JOIN list_marks(p_date) c USING (identifier)
LEFT JOIN fx_rate(p_date) USING (currency)
ORDER by identifier asc;
END;