aboutsummaryrefslogtreecommitdiffstats
path: root/sql
diff options
context:
space:
mode:
Diffstat (limited to 'sql')
-rw-r--r--sql/dawn.sql9
1 files changed, 9 insertions, 0 deletions
diff --git a/sql/dawn.sql b/sql/dawn.sql
index 3f38a4a2..35ebd395 100644
--- a/sql/dawn.sql
+++ b/sql/dawn.sql
@@ -270,6 +270,11 @@ CREATE TABLE external_marks(
source text,
PRIMARY KEY (identifier, date, source));
+CREATE TABLE mark_source_mapping(
+ globeop text,
+ 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 $$
BEGIN
@@ -393,6 +398,10 @@ protection, attach, detach, trade_date, upfront_settle_date FROM cds
JOIN index_desc ON index_desc.redindexcode=cds.security_id AND index_desc.maturity=cds.maturity
ORDER BY dealid, trade_date;
+CREATE OR REPLACE VIEW external_marks_mapped AS
+select date, identifier, mark, b.final as source from external_marks a
+left join mark_source_mapping b on a.source = b.globeop order by a.date asc;
+
CREATE OR REPLACE function query_positions(p_type text DEFAULT NULL)
RETURNS text AS $$
DECLARE