diff options
Diffstat (limited to 'sql/dawn.sql')
| -rw-r--r-- | sql/dawn.sql | 119 |
1 files changed, 119 insertions, 0 deletions
diff --git a/sql/dawn.sql b/sql/dawn.sql index 90d4cd22..507772a0 100644 --- a/sql/dawn.sql +++ b/sql/dawn.sql @@ -353,3 +353,122 @@ BEGIN ORDER by identifier asc; END; $$ LANGUAGE plpgsql; + +-- Not sure how to map enums so use text for now +CREATE FOREIGN TABLE priced( + cusip varchar(9), + model_version smallint, + normalization text, + timestamp timestamp, + pv numeric(23,6), + pv_RnW numeric(23,6), + pv_io numeric(23,6), + pv_po numeric(23,6), + modDur float, + modDur_io float, + modDur_po float, + wal float, + wal_width float, + wal_io float, + wal_po float, + delta_hpi numeric(23,6), + delta_ir numeric(23,6), + delta_ir_io numeric(23,6), + delta_ir_po numeric(23,6), + delta_mult numeric(23,6), + delta_yield numeric(23,6), + delta_quantile numeric(23,6), + delta_RnW numeric(23,6), + tot_gamma_hpi numeric(23,6), + tot_gamma_ir numeric(23,6), + tot_gamma numeric(23,6)) + SERVER mysql_server + OPTIONS (dbname 'rmbs_model'); + +-- We want to use INHERITS here, but will only be available on 9.5 +CREATE FOREIGN TABLE priced_orig_ntl( + cusip varchar(9), + model_version smallint, + normalization text, + timestamp timestamp, + pv numeric(23,6), + pv_RnW numeric(23,6), + pv_io numeric(23,6), + pv_po numeric(23,6), + modDur float, + modDur_io float, + modDur_po float, + wal float, + wal_width float, + wal_io float, + wal_po float, + delta_hpi numeric(23,6), + delta_ir numeric(23,6), + delta_ir_io numeric(23,6), + delta_ir_po numeric(23,6), + delta_mult numeric(23,6), + delta_yield numeric(23,6), + delta_quantile numeric(23,6), + delta_RnW numeric(23,6), + tot_gamma_hpi numeric(23,6), + tot_gamma_ir numeric(23,6), + tot_gamma numeric(23,6)) + SERVER mysql_server + OPTIONS (dbname 'rmbs_model'); + +CREATE FOREIGN TABLE priced_percentiles( + cusip varchar(9), + model_version smallint, + percentile float, + normalization text, + timestamp timestamp, + pv numeric(23,6), + pv_io numeric(23,6), + pv_po numeric(23,6), + modDur float, + modDur_io float, + modDur_po float, + wal float, + wal_width float, + wal_io float, + wal_po float) + SERVER mysql_server + OPTIONS (dbname 'rmbs_model'); + +CREATE FOREIGN TABLE priced_percentiles_orig_ntl( + cusip varchar(9), + model_version smallint, + percentile float, + normalization text, + timestamp timestamp, + pv numeric(23,6), + pv_io numeric(23,6), + pv_po numeric(23,6), + modDur float, + modDur_io float, + modDur_po float, + wal float, + wal_width float, + wal_io float, + wal_po float) + SERVER mysql_server + OPTIONS (dbname 'rmbs_model'); + +CREATE FOREIGN TABLE index_desc( + basketid integer, + index text, + series smallint, + version smallint, + indexfactor float, + cumulativeloss float, + lastdate date, + redindexcode text, + tenor text, + maturity date) + SERVER postgresql_server; + + +-- #bonds that get written down +-- update securities set identifier='073879R75_A' where identifier='073879R75'; +-- update bonds set identifier='073879R75_A' where identifier='073879R75'; +-- refresh materialized view factors_history; |
