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.py28
1 files changed, 7 insertions, 21 deletions
diff --git a/python/intex_scenarios.py b/python/intex_scenarios.py
index 0451c407..21b9b78e 100644
--- a/python/intex_scenarios.py
+++ b/python/intex_scenarios.py
@@ -26,27 +26,13 @@ pattern7 = re.compile("GOLDL3")
reinvfloatpercentage = 85
reinvfixedpercentage = 15
-def get_reinv_assets(dealname):
- # collatdates = sorted([datetime.strptime(d.split("_")[1], "%Y-%m-%d").date()
- # for d in os.listdir(os.path.join(root, "data"))
- # if "Collaterals" in d], reverse=True)
- collatfolders = sorted([d for d in os.listdir(os.path.join(common.root, "data")) if "Collaterals" in d],
- reverse = True)
+def get_reinv_assets(dealname, workdate):
d = {'REINV_TBA1': None, 'REINV_TBA2': None}
- filename = dealname.upper() + ",AD.txt"
- for folder in collatfolders:
- if filename not in os.listdir(os.path.join(common.root, "data", folder)):
- continue
- else:
- with open(os.path.join(common.root, "data", folder, filename )) as fh:
- dr = csv.DictReader(fh, dialect = 'excel-tab')
- headers = dr.fieldnames
- for line in dr:
- if line['ID Number'] == 'REINV_TBA1':
- d['REINV_TBA1'] = line['Fixed or Float']
- if line['ID Number'] == 'REINV_TBA2':
- d['REINV_TBA2'] = line['Fixed or Float']
- return d
+ sqlstr = 'select * from et_historicaldealinfo(%s, %s) where ReinvFlag IS TRUE'
+ cursor.execute(sqlstr, (dealname, workdate))
+ reinvassets = cursor.fetchall()
+ for line in reinvassets:
+ d[reinvassets[3]] = d[22]
def convert_reinvtoperct(d):
newd = {'REINV_TBA1': None, 'REINV_TBA2': None}
@@ -76,7 +62,7 @@ def generate_scenarios(workdate, dealnames, conn, cursor):
else:
print "missing reinvestment end date"
reinvflag=False
- reinv_assets = get_reinv_assets(dealname)
+ reinv_assets = get_reinv_assets(dealname, workdate)
perct_reinv_assets = convert_reinvtoperct(reinv_assets)
basedir = os.path.join(common.root, "Scenarios", "Intex curves_" + workdate)
with open(os.path.join(basedir, "csv", dealname + "-rollingmat"), "rb") as fh: