diff options
Diffstat (limited to 'sql/serenitasdb.sql')
| -rw-r--r-- | sql/serenitasdb.sql | 43 |
1 files changed, 41 insertions, 2 deletions
diff --git a/sql/serenitasdb.sql b/sql/serenitasdb.sql index 58c388aa..03677d6a 100644 --- a/sql/serenitasdb.sql +++ b/sql/serenitasdb.sql @@ -411,7 +411,7 @@ CREATE OR REPLACE FUNCTION curve_quotes_fmt(varchar(4), date, bbgSource DEFAULT END;
$$ LANGUAGE plpgsql;
-CREATE TABLE index_quotes(
+CREATE TABLE index_quotes_old(
date date,
index index_type,
series smallint,
@@ -429,9 +429,48 @@ CREATE TABLE index_quotes( theta2 float,
PRIMARY KEY(date, index, series, tenor, version));
+CREATE TABLE index_quotes_pre (
+ id serial NOT NULL PRIMARY KEY,
+ date date,
+ index index_type,
+ series smallint,
+ version smallint,
+ tenor tenor,
+ close_price float,
+ close_spread float,
+ model_price float,
+ model_spread float,
+ source bbgsource,
+ UNIQUE (date, index, series, tenor, version, source)
+);
+
+CREATE TABLE index_risk(
+ id integer PRIMARY REFERENCES index_quotes_new,
+ theta float,
+ duration float,
+ theta2 float,
+ duration2 float,
+ tweak float
+);
+
+CREATE VIEW index_quotes AS
+SELECT date, index, series, version, tenor, close_price, close_spread,
+model_price, model_spread, duration, theta, duration2, theta2
+FROM index_quotes_pre JOIN index_risk USING (id) WHERE SOURCE='MKIT';
+
+CREATE TABLE bbg_ticker_mapping(
+ ticker text PRIMARY KEY,
+ index index_type,
+ series smallint,
+ version smallint,
+ tenor tenor
+);
+
CREATE TABLE bbg_index_quotes(
date date,
- ticker text,
+ ticker text REFERENCES bbg_ticker_mapping,
+ index index_type,
+ series smallint,
version smallint,
tenor tenor,
last_price float,
|
