diff options
Diffstat (limited to 'python')
| -rw-r--r-- | python/process_queue.py | 28 |
1 files changed, 3 insertions, 25 deletions
diff --git a/python/process_queue.py b/python/process_queue.py index 7142336a..9832dbc7 100644 --- a/python/process_queue.py +++ b/python/process_queue.py @@ -70,7 +70,6 @@ def build_line(obj, queue='bond_trades'): line += [None]*5 line += [obj.protection, obj.security_id, obj.security_desc] line += [None]*9 - return line def bbg_process(conn, session, trade): @@ -103,7 +102,7 @@ def bbg_process(conn, session, trade): principal_payment = currentface * trade['price'] / 100. with conn.cursor() as c: c.execute("UPDATE bonds SET principal_payment = %s, accrued_payment = %s " - "WHERE id = %s", (principal_payment, accrued_payment, trade['id'])) + "WHERE id = %s", (principal_payment, accrued_payment, int(trade['id']))) conn.commit() if len(fields) > 2: #we don't have the data in the securities table sql_fields = ['identifier', 'cusip', 'isin', 'description', 'face_amount', @@ -159,7 +158,7 @@ headers = {'bond_trades':['Deal Type', 'Deal ID', 'Action', 'Client', 'Reserved' 'PaymentFrequency', 'FirstCouponRate', 'FirstCouponDate', 'ResetLag', 'Liquidation', 'LiquidationDate', 'Protection', 'UnderlyingSecurityId', 'UnderlyingSecurityDescription', 'CreditSpreadCurve', - 'CreditEvents', 'RecoveryRate', 'Settlement','InitialMargin', + 'CreditEvents', 'RecoveryRate', 'Settlement', 'InitialMargin', 'InitialMarginPercentage','InitialMarginCurrency', 'DiscountCurve', 'ClientReference', 'UpfrontFee', 'UpfrontFeePayDate', 'RegenerateCashFlow', 'UpfrontFeeComment', 'GiveUpBroker','SwapType', 'OnPrice', @@ -180,27 +179,6 @@ def generate_csv(l, name='bond_trades'): else: return output.getvalue() -def generate_csv(l): - output - StringIO() - csvwriter = csv.writer(output) - headers = ['Deal Type', 'Deal ID', 'Action', 'Client', 'Reserved', 'Reserved', - 'Folder', 'Custodian', 'Cash Account', 'Counterparty', 'Comments', - 'State', 'Trade Date', 'Reserved', 'Reserved', 'EffectiveDate', 'MaturityDate', - 'Currency', 'Notional', 'FixedRate', 'PaymentRollDateConvention', 'DayCount', - 'PaymentFrequency', 'FirstCouponRate', 'FirstCouponDate', 'ResetLag', 'Liquidation', - 'LiquidationDate', 'Protection', 'UnderlyingSecurityId', - 'UnderlyingSecurityDescription', 'CreditSpreadCurve', - 'CreditEvents', 'RecoveryRate', 'Settlement','InitialMargin', - 'InitialMarginPercentage','InitialMarginCurrency', 'DiscountCurve', - 'ClientReference', 'UpfrontFee', 'UpfrontFeePayDate', 'RegenerateCashFlow', - 'UpfrontFeeComment', 'GiveUpBroker','SwapType', 'OnPrice', - 'OffPrice', 'AttachmentPoint', 'ExhaustionPoint', 'Fees', 'Fee Payment Dates', - 'Fee Comments', 'Credit Event Occurred', 'Calendar', - 'Clearing Facility', 'Adjusted', 'CcpTradeRef', 'BlockId', - 'BlockAmount', 'NettingId', 'AnnouncementDate', 'ExecTS', - 'DefaultProbability', 'ClientMargin', 'Factor', 'ISDADefinition'] - - def upload_file(timestamp): ftp = FTP('ftp.globeop.com') ftp.login('srntsftp', config.ftp_password) @@ -232,6 +210,6 @@ if __name__=="__main__": for trade in l: bbg_process(conn, session, trade) timestamp = write_buffer(buf) - if not args.no_upload: + if not args.no_upload and name!='cds_trades': upload_file(timestamp) q.delete(name) |
