aboutsummaryrefslogtreecommitdiffstats
path: root/python
diff options
context:
space:
mode:
Diffstat (limited to 'python')
-rw-r--r--python/markit/import_quotes.py45
m---------python/pyisda0
2 files changed, 31 insertions, 14 deletions
diff --git a/python/markit/import_quotes.py b/python/markit/import_quotes.py
index 9947b8dd..39f9ee9e 100644
--- a/python/markit/import_quotes.py
+++ b/python/markit/import_quotes.py
@@ -143,6 +143,12 @@ def insert_cds(database, workdate):
"SECDOM": 1,
"SNRLAC": 2,
}
+ with database.cursor() as c:
+ c.execute("SELECT id, seniority, event_date FROM defaulted")
+ default_table = {
+ (cid, Seniority[seniority]): event_date for cid, seniority, event_date in c
+ }
+
with open(
os.path.join(os.environ["BASE_DIR"], "Tranche_data", "CDS", filename)
) as fh:
@@ -161,20 +167,31 @@ def insert_cds(database, workdate):
upfront_rates = np.array([convert(line[c]) / 100 for c in colnames])
recovery_rates = np.full(8, convert(line["RealRecovery"]) / 100)
coupon_rates = coupon_100 if spread == 100 else coupon_500
- sc = SpreadCurve(
- workdate,
- yc_dict[k.currency],
- None,
- None,
- None,
- tenors,
- coupon_rates,
- upfront_rates,
- recovery_rates,
- ticker=k.ticker,
- seniority=seniority_mapping[k.tier],
- doc_clause=DocClause[k.short_code],
- )
+ for _, bbg_id in markit_bbg_mapping[k]:
+ if event_date := default_table.get(bbg_id, False):
+ if workdate >= event_date:
+ defaulted = event_date
+ break
+ else:
+ defaulted = None
+ try:
+ sc = SpreadCurve(
+ workdate,
+ yc_dict[k.currency],
+ None,
+ None,
+ None,
+ tenors,
+ coupon_rates,
+ upfront_rates,
+ recovery_rates,
+ ticker=k.ticker,
+ seniority=seniority_mapping[k.tier],
+ doc_clause=DocClause[k.short_code],
+ defaulted=defaulted,
+ )
+ except ValueError:
+ logging.error(f"couldn't build curve for {k.ticker}")
buf = sc.as_buffer(True)
for curves, (cid, sen) in markit_bbg_mapping[k]:
c.execute(
diff --git a/python/pyisda b/python/pyisda
-Subproject e2b581e2ecae15b145039035a8b318f8437a520
+Subproject 750beafc64f1e22095bdc0b043002c20ca62a0a