aboutsummaryrefslogtreecommitdiffstats
path: root/sql
diff options
context:
space:
mode:
Diffstat (limited to 'sql')
-rw-r--r--sql/dawn.sql18
1 files changed, 8 insertions, 10 deletions
diff --git a/sql/dawn.sql b/sql/dawn.sql
index d7faeeda..81507e75 100644
--- a/sql/dawn.sql
+++ b/sql/dawn.sql
@@ -14,7 +14,8 @@ CREATE TYPE bbg_type AS ENUM('Mtge', 'Corp');
CREATE type day_count AS ENUM('ACT/360', 'ACT/ACT', '30/360', 'ACT/365');
CREATE type bus_day_convention AS ENUM('Modified Following', 'Following', 'Modified Preceding', 'Preceding',
'Second-Day-After', 'End-of-Month');
-CREATE type index_type AS ENUM('IG', 'HY', 'EU', 'XO', 'LCDX');
+CREATE type index_type AS ENUM('IG', 'HY', 'EU', 'LCDX', 'XO');
+CREATE TYPE tenor AS ENUM('6mo', '1yr', '2yr', '3yr', '4yr', '5yr', '7yr', '10yr');
CREATE TYPE swap_type AS ENUM('CD_INDEX', 'CD_INDEX_TRANCHE', 'CD_BASKET_TRANCHE', 'ABS_CDS');
CREATE type isda AS ENUM('ISDA2014', 'ISDA2003Cred');
CREATE type protection AS ENUM('Buyer', 'Seller');
@@ -297,10 +298,7 @@ SELECT temp.security_id, temp.security_desc, temp.maturity, temp.notional, temp.
index_price.duration, (index_price.closeprice/100.-1)*temp.notional*temp.fact,
temp.notional*temp.fixed_rate/100.*temp.fact*days/360
FROM temp
-LEFT JOIN index_price ON temp.index::text=index_price.index
- AND temp.series=index_price.series
- AND temp.version=index_price.version
- AND temp.tenor=index_price.tenor;
+LEFT JOIN index_price USING (index, series, version, tenor);
END
$$ LANGUAGE plpgsql;
@@ -599,14 +597,14 @@ CREATE FOREIGN TABLE index_desc(
cumulativeloss float,
lastdate date,
redindexcode text,
- tenor text,
+ tenor tenor,
maturity date,
coupon integer)
SERVER postgresql_server;
CREATE FOREIGN TABLE index_version(
basketID serial,
- Index text,
+ Index index_type,
Series smallint,
Version smallint,
IndexFactor float,
@@ -618,7 +616,7 @@ CREATE FOREIGN TABLE index_version(
CREATE FOREIGN TABLE index_maturity(
index index_type,
series smallint,
- tenor text,
+ tenor tenor,
maturity date)
SERVER postgresql_server;
@@ -627,7 +625,7 @@ CREATE FOREIGN TABLE index_quotes(
index index_type,
series smallint,
version smallint,
- tenor text,
+ tenor tenor,
closeprice float,
closespread float,
modelprice float,
@@ -641,7 +639,7 @@ SERVER postgresql_server;
CREATE FOREIGN TABLE markit_tranche_quotes(
quotedate date,
basketid integer,
- tenor text,
+ tenor tenor,
attach smallint,
detach smallint,
upfront_bid float,