diff options
| -rw-r--r-- | python/Dawn/models.py | 8 | ||||
| -rw-r--r-- | sql/dawn.sql | 15 |
2 files changed, 13 insertions, 10 deletions
diff --git a/python/Dawn/models.py b/python/Dawn/models.py index 08cdf079..2b209734 100644 --- a/python/Dawn/models.py +++ b/python/Dawn/models.py @@ -171,10 +171,10 @@ class CDSDeal(db.Model): upfront_settle_date = db.Column(db.Date, nullable=False) initial_margin_percentage = db.Column(db.Float) swap_type = db.Column(SWAP_TYPE, nullable=False) - attach = db.Column(db.SmallInteger, info={'min': 0, 'max': 100}) - detach = db.Column(db.SmallInteger, info={'min': 0, 'max': 100}) - corr_attach = db.Column(db.Float, info={'min': 0.}) - corr_detach = db.Column(db.Float, info={'min': 0.}) + attach = db.Column(db.Float, info={'min': 0., 'max': 1.}) + detach = db.Column(db.Float, info={'min': 0., 'max': 1.}) + corr_attach = db.Column(db.Float, info={'min': 0., 'max': 1.}) + corr_detach = db.Column(db.Float, info={'min': 0., 'max':1.}) index_ref = db.Column(db.Float) clearing_facility = db.Column(db.String(12), default=None, info={'filters': [lambda x: x or None,]}) 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 |
