diff options
Diffstat (limited to 'python/intex_scenarios.py')
| -rw-r--r-- | python/intex_scenarios.py | 37 |
1 files changed, 25 insertions, 12 deletions
diff --git a/python/intex_scenarios.py b/python/intex_scenarios.py index 067413e3..15e6851b 100644 --- a/python/intex_scenarios.py +++ b/python/intex_scenarios.py @@ -41,7 +41,7 @@ conn = psycopg2.connect(database="ET", cursor = conn.cursor()
# workdate = date.today().strftime('%Y-%m-%d')
-workdate = '2013-01-15'
+workdate = '2013-01-16'
def get_reinv_assets(dealname):
# collatdates = sorted([datetime.strptime(d.split("_")[1], "%Y-%m-%d").date()
@@ -65,7 +65,22 @@ def get_reinv_assets(dealname): d['REINV_TBA2'] = line['Fixed or Float']
return d
-for dealname in ["ares12", "callid7", "symph5", "lafasq", "marath1", "drydn8"]:
+def convert_reinvtoperct(d):
+ newd = {'REINV_TBA1': None, 'REINV_TBA2': None}
+ if not d['REINV_TBA2']:
+ newd['REINV_TBA1'] = 100
+ if d['REINV_TBA1'] == d['REINV_TBA2']: # case when we have two float or two fixed assets
+ newd['REINV_TBA1'] = 85
+ newd['REINV_TBA2'] = 15
+ elif d['REINV_TBA1'] == 'Float':
+ newd['REINV_TBA1'] = reinvfloatpercentage
+ newd['REINV_TBA2'] = reinvfixedpercentage
+ elif d['REINV_TBA1'] == 'Fixed':
+ newd['REINV_TBA1'] = reinvfixedpercentage
+ newd['REINV_TBA2'] = reinvfloatpercentage
+ return newd
+
+for dealname in ["babs062", "harch2", "jerst", "aresvr", "babs071", "landmrk9", "carlg123", "trim6", "frasul2", "vent6", "cifc061b"]:
cursor.execute('SELECT \"Reinv End Date\" from latest_clo_universe where dealname=%s', (dealname,))
reinvenddate = cursor.fetchone()[0]
if reinvenddate:
@@ -74,6 +89,8 @@ for dealname in ["ares12", "callid7", "symph5", "lafasq", "marath1", "drydn8"]: print "missing reinvestment end date"
pdb.set_trace()
reinv_assets = get_reinv_assets(dealname)
+ perct_reinv_assets = convert_reinvtoperct(reinv_assets)
+
basedir = os.path.join(root, "Scenarios", "Intex curves_" + workdate)
with open(os.path.join(basedir, "csv", dealname + "-reinvprices.csv"), "r") as fhreinv:
floatreinvprices = fhreinv.readline().rstrip("\n").split(",")
@@ -136,19 +153,15 @@ for dealname in ["ares12", "callid7", "symph5", "lafasq", "marath1", "drydn8"]: fh2.write(line)
continue
if pattern5.match(line):
- if not reinv_assets['REINV_TBA2']:
- line = re.sub(pattern5, r"\1{0}\2{1}", line).format(dealname.upper(), 100)
- elif reinv_assets['REINV_TBA1'] == 'Fixed':
- line = re.sub(pattern5, r"\1{0}\2{1}", line).format(dealname.upper(), reinvfixedpercentage)
- elif reinv_assets['REINV_TBA1'] == 'Float':
- line = re.sub(pattern5, r"\1{0}\2{1}", line).format(dealname.upper(), reinvfloatpercentage)
+ if reinv_assets['REINV_TBA1']:
+ line = re.sub(pattern5, r"\1{0}\2{1}", line).format(
+ dealname.upper(), perct_reinv_assets['REINV_TBA1'])
fh2.write(line)
continue
if pattern6.match(line):
- if reinv_assets['REINV_TBA2'] == 'Float':
- line = re.sub(pattern6, r"\1{0}\2{1}", line).format(dealname.upper(), reinvfloatpercentage)
- elif reinv_assets['REINV_TBA2'] == 'Fixed':
- line = re.sub(pattern6, r"\1{0}\2{1}", line).format(dealname.upper(), reinvfixedpercentage)
+ if reinv_assets['REINV_TBA2']:
+ line = re.sub(pattern6, r"\1{0}\2{1}", line).format(
+ dealname.upper(), perct_reinv_assets['REINV_TBA2'])
fh2.write(line)
continue
if pattern7.search(line):
|
