diff options
| -rw-r--r-- | R/new_index_series.R | 10 | ||||
| -rw-r--r-- | R/thetas-durations.R | 4 | ||||
| -rw-r--r-- | python/markit/import_quotes.py | 7 |
3 files changed, 11 insertions, 10 deletions
diff --git a/R/new_index_series.R b/R/new_index_series.R index fe234afc..238a7f90 100644 --- a/R/new_index_series.R +++ b/R/new_index_series.R @@ -66,7 +66,7 @@ newcurves <- function(indextype, series, basketid){ sqlstr <- paste0("INSERT INTO bbg_issuers", "(name, company_id, ticker, currency, seniority, doc_clause, cds_curve)", - "VALUES($1, $2, $3, $4, $5, $6, $7)") + "VALUES($1, $2, $3, $4, $5, $6, $7) ON CONFLICT DO NOTHING") with(prep.data, for(i in 1:nrow(prep.data)){ r <- dbSendQuery(serenitasdb, sqlstr, @@ -103,11 +103,11 @@ markit.mappings <- function(df){ } if(interactive()) { - basket.id <- newbasketID('HY', 26, 1, as.Date("2021-06-20"), 500) - df <- newcurves('HY', 26, basket.id) + basket.id <- newbasketID('IG', 28, 1, as.Date("2022-06-20"), 100) + df <- newcurves('IG', 28, basket.id) mappings <- data.frame(company_id = df$company_id, - markit_ticker=c("BLL","THEADT", "EQIX", "TRADIG", "TGRI-Ptnr", "ETE"), - seniority=c(rep("SNRFOR",3),"SUBLT2","SNRFOR","SECDOM"), coupon=500) + markit_ticker=c("ECACN","KINDERM", "JOHCON"), + seniority=rep("SNRFOR",3), coupon=100) markit.mappings(mappings) ## then update index_list in markit/import_quotes.py and rerun insert_cds } diff --git a/R/thetas-durations.R b/R/thetas-durations.R index 54e79f8f..b70b1726 100644 --- a/R/thetas-durations.R +++ b/R/thetas-durations.R @@ -76,11 +76,11 @@ sqlstr.duration <- paste("UPDATE index_quotes set duration=$1 where date=$2 and "and series=$4 and tenor=$5") sqlstr.theta <- paste("UPDATE index_quotes set theta=$1 where date=$2 and index=$3", "and series=$4 and tenor=$5") -for(index in c('IG', 'HY')){ +for(index in c('IG', 'HY')) { recov <- if(index=='IG') 0.4 else 0.3 coupon <- if(index=='IG') 0.01 else 0.05 tenors <- if(index=='IG') c("3yr", "5yr", "7yr", "10yr") else c("3yr", "5yr", "7yr") - for(series in 18:27){ + for(series in 18:28) { indexquotes <- get.indexquotes.table(index, series, tenors) if(nrow(indexquotes)==0){ next diff --git a/python/markit/import_quotes.py b/python/markit/import_quotes.py index d3ac8a29..203e1397 100644 --- a/python/markit/import_quotes.py +++ b/python/markit/import_quotes.py @@ -18,7 +18,7 @@ def convert(x): return None index_list = ['HY9', 'HY10'] + ['HY' + str(s) for s in range(15, 27)] + ['IG9'] + \ - ['IG' + str(s) for s in range(16, 28)] + \ + ['IG' + str(s) for s in range(16, 29)] + \ ['XO' + str(s) for s in range(22, 27)] + \ ['EU9'] + \ ['EU' + str(s) for s in range(19, 27)] @@ -51,7 +51,7 @@ def get_markit_bbg_mapping(database, basketid_list, workdate): ## each markit ticker can be mapped to multiple bbg tickers ## these bbg tickers can have different curves (ok) ## or same curves (not ok since date, curve_ticker needs to be unique) - ## therefore we keep them in a set strucutre + ## therefore we keep them in a set structure markit_bbg_mapping[key].add(tuple(line['cds_curve'])) database.commit() return (all_tickers, markit_bbg_mapping) @@ -80,7 +80,8 @@ def insert_cds(database, workdate): filename = "cds eod {0:%Y%m%d}.csv".format(workdate) colnames = ['Upfront'+tenor for tenor in ['6m', '1y', '2y', '3y', '4y', '5y', '7y', '10y']] sqlstr = "INSERT INTO cds_quotes(date, curve_ticker, upfrontbid, upfrontask," \ - "runningbid, runningask, source, recovery) VALUES(%s, %s, %s, %s, %s, %s, %s, %s)" + "runningbid, runningask, source, recovery) VALUES(%s, %s, %s, %s, %s, %s, %s, %s) " \ + "ON CONFLICT DO NOTHING" tickers_found = set([]) with database.cursor() as c: |
