diff options
Diffstat (limited to 'python/markit')
| -rw-r--r-- | python/markit/loans.py | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/python/markit/loans.py b/python/markit/loans.py index f9fbe065..b6ec11d8 100644 --- a/python/markit/loans.py +++ b/python/markit/loans.py @@ -49,8 +49,8 @@ def download_marks(conn, workdate, payload): raise SystemExit
with conn.cursor() as c:
for line in reader:
- if line['Depth']=='implied':
- line['Depth']=0
+ if line['Depth'] == 'implied':
+ line['Depth'] = 0
c.execute(sqlstring, (line['LoanX ID'], line['Bid'], line['Offer'],
line['Depth'], line['Mark Date']))
conn.commit()
@@ -61,18 +61,19 @@ def update_facility(conn, workdate, payload): sqlstring = "SELECT loanxid FROM markit_prices EXCEPT SELECT loanxid FROM markit_facility";
facility_diff_filename = os.path.join(os.environ['DATA_DIR'], "Facility files",
"facility_diff_{0}.csv".format(workdate))
- with open( facility_diff_filename, "wb") as fh:
+ with open( facility_diff_filename, "wt") as fh:
flag = False
with conn.cursor() as c:
c.execute(sqlstring)
for loanxid in c:
payload.update({'LOANXID': loanxid[0]})
r = requests.get('https://loans.markit.com/loanx/LoanXOneFacility.csv', params=payload)
+ header, *rest = r.content.decode().split('\n')
if flag:
- fh.write(r.content.split('\n')[1] + "\n")
+ fh.write(rest[0] + "\n")
else:
- fh.write(r.content.split('\n')[0] + "\n")
- fh.write(r.content.split('\n')[1] + "\n")
+ fh.write(header + "\n")
+ fh.write(rest[0] + "\n")
flag = True
sqlstring = "INSERT INTO markit_facility(LoanXID, PMDID, IssuerName, dealname, facility_type," \
|
