aboutsummaryrefslogtreecommitdiffstats
path: root/python/intex_scenarios.py
diff options
context:
space:
mode:
Diffstat (limited to 'python/intex_scenarios.py')
-rw-r--r--python/intex_scenarios.py108
1 files changed, 57 insertions, 51 deletions
diff --git a/python/intex_scenarios.py b/python/intex_scenarios.py
index c43caee7..331bc31a 100644
--- a/python/intex_scenarios.py
+++ b/python/intex_scenarios.py
@@ -74,9 +74,10 @@ def generate_scenarios(workdate, dealnames, conn, cursor):
reinvenddate = cursor.fetchone()[0]
if reinvenddate:
reinvenddate = reinvenddate.strftime("%Y%m%d")
+ reinvflag=True
else:
print "missing reinvestment end date"
- pdb.set_trace()
+ reinvflag=False
reinv_assets = get_reinv_assets(dealname)
perct_reinv_assets = convert_reinvtoperct(reinv_assets)
basedir = os.path.join(common.root, "Scenarios", "Intex curves_" + workdate)
@@ -112,56 +113,61 @@ def generate_scenarios(workdate, dealnames, conn, cursor):
newline = "DEAL_NAME=" + dealname.upper() + "\n"
fh2.write(newline)
continue
- if pattern11.match(line):
- line = re.sub(pattern11, r"\1{0}\2", line).format(dealname.upper()).rstrip()
- if reinv_assets["REINV_TBA1"] == "Float":
- line = line + "COUP_SPR=2.5|AMORT=Bullet|USE_REINVEST_PIP=1|MAT_DATE=84|\n"
- elif reinv_assets["REINV_TBA1"] == "Fixed":
- line = line + "COUP_SPR=7|AMORT=Bullet|USE_REINVEST_PIP=1|MAT_DATE=84|\n"
- fh2.write(line)
- continue
- if pattern12.match(line):
- line = re.sub(pattern12, r"\1{0}\2", line).format(dealname.upper()).rstrip()
- if reinv_assets["REINV_TBA2"] == "Float":
- line = line + "COUP_SPR=2.5|AMORT=Bullet|USE_REINVEST_PIP=1|MAT_DATE=84|\n"
- elif reinv_assets["REINV_TBA2"] == "Fixed":
- line = line + "COUP_SPR=7|AMORT=Bullet|USE_REINVEST_PIP=1|MAT_DATE=84|\n"
- fh2.write(line)
- continue
- if pattern2.match(line):
- line = re.sub(pattern2, r"\1{0}\2{1}", line).format(dealname.upper(), reinvenddate)
- fh2.write(line)
- continue
- if pattern3.match(line):
- if reinv_assets['REINV_TBA1'] == 'Fixed':
- line = re.sub(pattern3, r"\1{0}\2{1}", line).format(dealname.upper(), " ".join(fixedreinvprices[i-2]))
- elif reinv_assets['REINV_TBA1'] == 'Float':
- line = re.sub(pattern3, r"\1{0}\2{1}", line).format(dealname.upper(), " ".join(floatreinvprices[i-2]))
- fh2.write(line)
- continue
- if pattern4.match(line):
- if reinv_assets['REINV_TBA2'] == 'Fixed':
- line = re.sub(pattern4, r"\1{0}\2{1}", line).format(dealname.upper(), " ".join(fixedreinvprices[i-2]))
- elif reinv_assets['REINV_TBA2'] == 'Float':
- line = re.sub(pattern4, r"\1{0}\2{1}", line).format(dealname.upper(), " ".join(floatreinvprices[i-2]))
- fh2.write(line)
- continue
- if pattern5.match(line):
- 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']:
- 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):
- line = re.sub(pattern7, dealname.upper(), line)
- fh2.write(line)
- continue
+ if reinvflag:
+ if pattern11.match(line):
+ line = re.sub(pattern11, r"\1{0}\2", line).format(dealname.upper()).rstrip()
+ if reinv_assets["REINV_TBA1"] == "Float":
+ line = line + "COUP_SPR=2.5|AMORT=Bullet|USE_REINVEST_PIP=1|MAT_DATE=84|\n"
+ elif reinv_assets["REINV_TBA1"] == "Fixed":
+ line = line + "COUP_SPR=7|AMORT=Bullet|USE_REINVEST_PIP=1|MAT_DATE=84|\n"
+ fh2.write(line)
+ continue
+ if pattern12.match(line):
+ line = re.sub(pattern12, r"\1{0}\2", line).format(dealname.upper()).rstrip()
+ if reinv_assets["REINV_TBA2"] == "Float":
+ line = line + "COUP_SPR=2.5|AMORT=Bullet|USE_REINVEST_PIP=1|MAT_DATE=84|\n"
+ elif reinv_assets["REINV_TBA2"] == "Fixed":
+ line = line + "COUP_SPR=7|AMORT=Bullet|USE_REINVEST_PIP=1|MAT_DATE=84|\n"
+ fh2.write(line)
+ continue
+ if pattern2.match(line):
+ line = re.sub(pattern2, r"\1{0}\2{1}", line).format(dealname.upper(), reinvenddate)
+ fh2.write(line)
+ continue
+ if pattern3.match(line):
+ if reinv_assets['REINV_TBA1'] == 'Fixed':
+ line = re.sub(pattern3, r"\1{0}\2{1}", line).format(dealname.upper(),
+ " ".join(fixedreinvprices[i-2]))
+ elif reinv_assets['REINV_TBA1'] == 'Float':
+ line = re.sub(pattern3, r"\1{0}\2{1}", line).format(dealname.upper(),
+ " ".join(floatreinvprices[i-2]))
+ fh2.write(line)
+ continue
+ if pattern4.match(line):
+ if reinv_assets['REINV_TBA2'] == 'Fixed':
+ line = re.sub(pattern4, r"\1{0}\2{1}", line).format(dealname.upper(),
+ " ".join(fixedreinvprices[i-2]))
+ elif reinv_assets['REINV_TBA2'] == 'Float':
+ line = re.sub(pattern4, r"\1{0}\2{1}", line).format(dealname.upper(),
+ " ".join(floatreinvprices[i-2]))
+ fh2.write(line)
+ continue
+ if pattern5.match(line):
+ 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']:
+ 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):
+ line = re.sub(pattern7, dealname.upper(), line)
+ fh2.write(line)
+ continue
# if "STANDARD_VAR" in line:
# newline = "STANDARD_VAR[REINVEST_PRICE,1]=" + " ".join(reinvprices)
# fh2.write(newline)