aboutsummaryrefslogtreecommitdiffstats
path: root/python
diff options
context:
space:
mode:
Diffstat (limited to 'python')
-rw-r--r--python/intex/intex_scenarios.py8
-rw-r--r--python/intex/load_indicative.py33
-rw-r--r--python/intex/load_intex_collateral.py5
3 files changed, 25 insertions, 21 deletions
diff --git a/python/intex/intex_scenarios.py b/python/intex/intex_scenarios.py
index 0613a1e2..576e275e 100644
--- a/python/intex/intex_scenarios.py
+++ b/python/intex/intex_scenarios.py
@@ -55,10 +55,10 @@ def get_recovery(conn, dealname, workdate, defaultrecovery = 50):
conn.commit()
return float(recovery)
-def get_reinvenddate(conn, dealname):
- sqlstr = 'SELECT reinv_end_date from deal_indicative where dealname=%s'
+def get_reinvenddate(conn, dealname, workdate):
+ sqlstr = 'SELECT reinv_end_date FROM historical_clo_universe(%s, %s)'
with conn.cursor() as c:
- c.execute(sqlstr, (dealname,))
+ c.execute(sqlstr, (dealname, workdate))
reinvenddate, = c.fetchone()
conn.commit()
if reinvenddate:
@@ -80,7 +80,7 @@ def generate_scenarios(workdate, dealname, conn):
return
reinvflag = config['reinvflag']
if reinvflag:
- reinvenddate = get_reinvenddate(conn, dealname)
+ reinvenddate = get_reinvenddate(conn, dealname, workdate)
reinv_assets = get_reinv_assets(conn, dealname, workdate)
n_float_assets = len([v for v in reinv_assets.values() if v == 'FLOAT'])
n_fixed_assets = len([v for v in reinv_assets.values() if v == 'FIXED'])
diff --git a/python/intex/load_indicative.py b/python/intex/load_indicative.py
index 89e87e1e..3686aa85 100644
--- a/python/intex/load_indicative.py
+++ b/python/intex/load_indicative.py
@@ -98,11 +98,11 @@ def upload_cusip_data(conn, filename):
conn.commit()
def upload_deal_data(conn, filename):
- sqlstr = "select dealname, array_agg(\"Latest Update\") from clo_universe group by dealname"
+ sqlstr = 'SELECT dealname, array_agg("Latest Update") FROM clo_universe GROUP BY dealname'
with conn.cursor() as c:
c.execute(sqlstr)
deallist1 = dict(c)
- sqlstr = "select dealname from deal_indicative"
+ sqlstr = "SELECT dealname FROM deal_indicative"
with conn.cursor() as c:
c.execute(sqlstr)
deallist2 = [d[0] for d in c]
@@ -125,7 +125,8 @@ def upload_deal_data(conn, filename):
line["Paid Down"] = re.sub("Paid Down: ","", line["Latest Update"])
line["Latest Update"] = line["Paid Down"]
for field in ["Deal Closing Date", "Deal Termination Date", "Reinv End Date", \
- "Latest Update", "Pay Day", "Deal First Pay Date", "Paid Down"]:
+ "Latest Update", "Pay Day", "Deal First Pay Date", "Paid Down",
+ "Deal's Last Refi Date"]:
if line[field]:
try:
line[field] = datetime.datetime.strptime(line[field], '%b %d, %Y').date()
@@ -135,24 +136,22 @@ def upload_deal_data(conn, filename):
if line["Pay Day"]:
line["Pay Day"] = line["Pay Day"].day
for key in ["Principal Collection Account", "Interest Collection Account",
- "Curr Deal Bal", "Tranche Curr Bal", "CDOpercent", "defaultedbal"]:
+ "Curr Deal Bal", "Tranche Curr Bal", "CDOpercent", "defaultedbal",
+ "Orig Deal Bal", "Tranche Orig Bal"]:
if line[key]:
line[key] = sanitize_float(line[key])
line['Deal/Tranche ID'] = line['Deal/Tranche ID'].lower()
dealname = line['Deal/Tranche ID']
if dealname not in deallist2:
- for key in ["Orig Deal Bal", "Tranche Orig Bal"]:
- if line[key]:
- line[key] = sanitize_float(line[key])
-
- sqlstr = "INSERT INTO deal_indicative VALUES( %(Deal/Tranche ID)s, %(Deal Name)s, " \
- "%(Collateral Manager)s, %(Deal Closing Date)s, %(Deal Termination Date)s, " \
- "%(Pay Day)s, %(Reinv End Date)s, %(Deal First Pay Date)s, %(Orig Deal Bal)s, " \
- "%(Tranche Orig Bal)s, %(Deal CUSIP List)s, %(Paid Down)s)"
+ sqlstr = "INSERT INTO deal_indicative VALUES( %(Deal/Tranche ID)s, " \
+ "%(Deal Name)s, %(Collateral Manager)s, " \
+ "%(Deal Closing Date)s, %(Pay Day)s, " \
+ "%(Deal First Pay Date)s, %(Paid Down)s)"
else:
- #we always update Deal Cusip List and paid_down
- sqlstr = 'UPDATE deal_indicative SET "Deal Cusip List"=%(Deal CUSIP List)s, ' \
- 'paid_down=%(Paid Down)s WHERE dealname=%(Deal/Tranche ID)s'
+ #we always update paid_down
+ sqlstr = 'UPDATE deal_indicative SET paid_down=%(Paid Down)s ' \
+ 'WHERE dealname=%(Deal/Tranche ID)s'
+
if line['Deal CUSIP List']:
line['Deal CUSIP List'] = line['Deal CUSIP List'].split(",")
try:
@@ -167,7 +166,9 @@ def upload_deal_data(conn, filename):
"VALUES (%(Deal/Tranche ID)s, %(Curr Deal Bal)s, %(Tranche Curr Bal)s, " \
"%(Tranche Factor)s, %(Principal Collection Account)s, " \
"%(Interest Collection Account)s, %(CDOpercent)s, %(defaultedbal)s, " \
- "%(Coupon)s, %(Latest Update)s)"
+ "%(Coupon)s, %(Latest Update)s, %(Deal's Last Refi Date)s, " \
+ "%(Deal CUSIP List)s, %(Deal Termination Date)s, %(Reinv End Date)s, " \
+ "%(Orig Deal Bal)s, %(Tranche Orig Bal)s)"
try:
with conn.cursor() as c:
c.execute(sqlstring, line)
diff --git a/python/intex/load_intex_collateral.py b/python/intex/load_intex_collateral.py
index cb736240..e6963ed3 100644
--- a/python/intex/load_intex_collateral.py
+++ b/python/intex/load_intex_collateral.py
@@ -89,7 +89,10 @@ def upload_data(conn, workdate):
temp = line["Amortization Schedule"].split("; ")
temp = [e.split(" @ ") for e in temp]
amounts, dates = zip(*temp)
- amounts = [float(e.replace(",", "")) for e in amounts]
+ if '%' in amounts[0]: #for reinvestment assets amort is in percentage.
+ amounts = [float(e.replace("%", "")) / 100 for e in amounts]
+ else:
+ amounts = [float(e.replace(",", "")) for e in amounts]
dates = [datetime.datetime.strptime(e, "%b %d, %Y").date() for e in dates]
r[-1] = dates
r.append(amounts)