aboutsummaryrefslogtreecommitdiffstats
path: root/sql
diff options
context:
space:
mode:
Diffstat (limited to 'sql')
-rw-r--r--sql/serenitasdb.sql22
1 files changed, 20 insertions, 2 deletions
diff --git a/sql/serenitasdb.sql b/sql/serenitasdb.sql
index 5778632f..e50d27a8 100644
--- a/sql/serenitasdb.sql
+++ b/sql/serenitasdb.sql
@@ -375,6 +375,7 @@ GRANT ALL ON cds_quotes TO serenitas_user;
CREATE INDEX IF NOT EXISTS cds_quotes_date_index ON cds_quotes(date);
CREATE TABLE markit_tranche_quotes(
+ id integer GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
quotedate date,
basketid integer REFERENCES index_version,
tenor tenor,
@@ -385,7 +386,7 @@ CREATE TABLE markit_tranche_quotes(
upfront_ask float,
tranche_spread smallint,
index_price float,
- PRIMARY KEY (quotedate, basketid, tenor, attach, detach)
+ UNIQUE (quotedate, basketid, tenor, attach, detach)
);
GRANT ALL ON markit_tranche_quotes TO serenitas_user;
@@ -763,7 +764,24 @@ CREATE TABLE tranche_risk(
GRANT ALL ON tranche_risk to serenitas_user;
-ALTER TABLE tranche_risk ADD UNIQUE(tranche_id);
+CREATE TABLE markit_tranche_risk(
+ id integer GENERATED BY DEFAULT PRIMARY KEY,
+ tranche_id integer UNIQUE REFERENCES markit_tranche_quotes(id) ON DELETE CASCADE,
+ index_price float,
+ index_basis float,
+ index_expected_loss float,
+ index_duration float,
+ index_theta float,
+ corr_at_detach float,
+ delta float,
+ fwd_delta float,
+ gamma float,
+ theta float,
+ corr01 float,
+ duration float,
+ spread float,
+ expected_loss float);
+
CREATE OR REPLACE FUNCTION riskmonitor_getindicesinfo2(
IN p_date date,