diff options
Diffstat (limited to 'sql/dawn.sql')
| -rw-r--r-- | sql/dawn.sql | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/sql/dawn.sql b/sql/dawn.sql index 85789749..e3bd7640 100644 --- a/sql/dawn.sql +++ b/sql/dawn.sql @@ -133,8 +133,8 @@ CREATE TABLE cds(id serial primary key, upfront float NOT NULL, upfront_settle_date date NOT NULL, swap_type swap_type NOT NULL, - attach smallint, - detach smallint, + attach float, + detach float, clearing_facility varchar(12) DEFAULT NULL, isda_definition isda, termination_date date DEFAULT NULL, @@ -334,7 +334,7 @@ CREATE TABLE external_marks_deriv(date date NOT NULL, trade_type trade_type, PRIMARY KEY(identifier, date)); -CREATE VIEW id_mappings AS +CREATE OR REPLACE VIEW id_mappings AS SELECT trade_date, dealid, cpty_id, notional*price/100 as nav, 'SWAPTION'::trade_type as trade_type from swaptions UNION SELECT trade_date, dealid, cds.cpty_id, upfront as nav, @@ -496,9 +496,12 @@ END; $$ LANGUAGE plpgsql; CREATE OR REPLACE VIEW orig_cds AS -SELECT DISTINCT ON (dealid) dealid, folder, index, series, version, tenor, fixed_rate, notional, upfront, -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 +SELECT DISTINCT ON (dealid) dealid, folder, index, series, + version, tenor, fixed_rate, notional, upfront, + 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 |
