diff options
| -rw-r--r-- | python/calibrate_tranches_BC.py | 2 | ||||
| -rw-r--r-- | sql/serenitasdb.sql | 5 |
2 files changed, 5 insertions, 2 deletions
diff --git a/python/calibrate_tranches_BC.py b/python/calibrate_tranches_BC.py index e0ca250f..b72ebbcb 100644 --- a/python/calibrate_tranches_BC.py +++ b/python/calibrate_tranches_BC.py @@ -137,6 +137,8 @@ if __name__ == "__main__": begin_date = args.start_from if args.update: begin_date = get_lastdate(serenitas_conn, index, series, tenor) + if begin_date is None: + continue if not args.update and begin_date is None: try: begin_date = start_dates[f"{index.lower()}{series}"] diff --git a/sql/serenitasdb.sql b/sql/serenitasdb.sql index 7c76fc57..67fd9e9d 100644 --- a/sql/serenitasdb.sql +++ b/sql/serenitasdb.sql @@ -139,6 +139,7 @@ CREATE TABLE tranche_quotes ( Basis real,
QuoteSource varchar(4),
markit_id integer UNIQUE,
+ deleted bool DEFAULT False NOT NULL,
UNIQUE (QuoteDate, Index, Series, Version, Tenor, Attach, Detach, QuoteSource, trancheupfront)
);
@@ -656,7 +657,7 @@ $$ FOR r in EXECUTE
'SELECT DISTINCT quotesource, quotedate FROM tranche_quotes
WHERE index=$1::index_type AND series=$2 AND date(timezone(''localtime'', quotedate))=$3
- AND tenor =$4::tenor ORDER BY quotedate desc'
+ AND tenor =$4::tenor AND NOT deleted ORDER BY quotedate desc'
USING pg_index_type, pg_series, pg_date, pg_tenor LOOP
-- The JPM quotes are untriggered whereas Citi quotes are triggered
IF pg_index_type = 'XO' AND pg_series = 22 AND
@@ -670,7 +671,7 @@ $$ 'SELECT array_agg(attach ORDER BY attach ASC)||100::smallint = $6||array_agg(detach ORDER BY detach ASC)
FROM tranche_quotes
WHERE index=$1::index_type AND series=$2 AND tenor=$3::tenor
- AND quotedate=$4 AND detach-attach!=5::smallint AND quotesource=$5'
+ AND quotedate=$4 AND detach-attach!=5::smallint AND quotesource=$5 AND NOT deleted'
INTO flag
USING pg_index_type, pg_series, pg_tenor, r.quotedate, r.quotesource, lower_attach;
IF flag THEN
|
