diff options
| -rw-r--r-- | python/process_queue.py | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/python/process_queue.py b/python/process_queue.py index 9832dbc7..46a9a53c 100644 --- a/python/process_queue.py +++ b/python/process_queue.py @@ -179,18 +179,21 @@ def generate_csv(l, name='bond_trades'): else: return output.getvalue() -def upload_file(timestamp): +def upload_file(timestamp, name='bond_trades'): ftp = FTP('ftp.globeop.com') ftp.login('srntsftp', config.ftp_password) ftp.cwd('incoming') - filename = 'Serenitas.ALL.{0:%Y%m%d.%H%M%S}.Mortgages.csv'.format(timestamp) + filename = 'Serenitas.ALL.{0:%Y%m%d.%H%M%S}.{1}.csv'.format(timestamp, "Mortgages" if name=='bond_trades' + else "CreditDefaultSwapDeal") cmd = 'STOR {0}'.format(filename) with open(os.path.join('/home/share/Daily', str(timestamp.date()), filename), 'rb') as fh: ftp.storbinary(cmd, fh) -def write_buffer(buf): +def write_buffer(buf, name='bond_trades'): timestamp = pd.datetime.now() - filename = 'Serenitas.ALL.{0:%Y%m%d.%H%M%S}.Mortgages.csv'.format(timestamp) + filename = 'Serenitas.ALL.{0:%Y%m%d.%H%M%S}.{1}.csv'.format(timestamp, + "Mortgages" if name=='bond_trades' else + "CreditDefaultSwapDeal") with open(os.path.join('/home/share/Daily', str(timestamp.date()), filename), 'wb') as fh: fh.write(buf) return timestamp @@ -205,10 +208,11 @@ if __name__=="__main__": for name in ['bond_trades', 'cds_trades']: l = get_trades(q, name) if l: - buf = generate_csv(l) - with init_bbg_session(BBG_IP) as session: - for trade in l: - bbg_process(conn, session, trade) + buf = generate_csv(l, name) + if name == 'bond_trades': + with init_bbg_session(BBG_IP) as session: + for trade in l: + bbg_process(conn, session, trade) timestamp = write_buffer(buf) if not args.no_upload and name!='cds_trades': upload_file(timestamp) |
