diff options
Diffstat (limited to 'python')
| -rw-r--r-- | python/csv_headers/globeop_upload.py | 69 | ||||
| -rw-r--r-- | python/position_file_bowdst.py | 80 |
2 files changed, 75 insertions, 74 deletions
diff --git a/python/csv_headers/globeop_upload.py b/python/csv_headers/globeop_upload.py index f58b25ed..8c8afb0c 100644 --- a/python/csv_headers/globeop_upload.py +++ b/python/csv_headers/globeop_upload.py @@ -708,3 +708,72 @@ HEADERS = { "InitialMarginCurrency", ], } + + +POSITION_HEADERS = { + "bond": [ + "AccountNumber", + "COB Date", + "Prime Broker", + "SecurityType", + "CUSIP", + "ISIN", + "SEDOL", + "SecurityDescription", + "Position", + "MarketPrice", + "Currency", + "Base Market Value", + "Local Market Value", + "Fx Rate", + ], + "future": [ + "AccountNumber", + "COB Date", + "Prime Broker", + "SecurityType", + "BBGTicker", + "RIC", + "UnderlyingSecurity", + "SecurityDescription", + "Currency", + "Quantity", + "OpenTradeEquity", + "ClosingPrice", + "MaturityDate", + "Unrealised P&L in USD", + "Local Market Value", + "Fx Rate", + ], + "otc": [ + "Client Name", + "Fund Name", + "Counterparty", + "Product Type", + "Unique Deal ID", + "TransactionIndicator (Buy/Sell)", + "PutCall Indicator (Call/Put)", + "CapFloorIndicator", + "CurrencyPair", + "DealCurrencyA", + "DealCurrencyB", + "NotionalA", + "NotionalB", + "OriginalPrice", + "Strike", + "FixedRate", + "Quantity", + "Start Date", + "Effective Date", + "Maturity Date", + "Underlying Maturity", + "RecPayFixed", + "Underlying (ISIN / CUSP / RED CODES)", + "Underlying Desc", + "Exercise Type", + "MTM Currency", + "MTM Valuation", + "COB Date", + "Clearing House Name", + ], +} diff --git a/python/position_file_bowdst.py b/python/position_file_bowdst.py index af104ace..269ee8fd 100644 --- a/python/position_file_bowdst.py +++ b/python/position_file_bowdst.py @@ -6,6 +6,11 @@ from serenitas.utils.remote import SftpClient from serenitas.utils.env import DAILY_DIR from pandas.tseries.offsets import MonthEnd from serenitas.utils.exchange import ExchangeMessage, FileAttachment +from csv_headers.globeop_upload import POSITION_HEADERS + + +def build_line(obj, asset_type): + return [obj.get(h, None) for h in POSITION_HEADERS[asset_type]] def process_upload(positions, upload): @@ -13,7 +18,7 @@ def process_upload(positions, upload): for asset_type, trades in positions.items(): buf = StringIO() csvwriter = csv.writer(buf) - csvwriter.writerow(HEADERS[asset_type]) + csvwriter.writerow(POSITION_HEADERS[asset_type]) csvwriter.writerows(build_line(trade, asset_type) for trade in trades) buf = buf.getvalue().encode() fname = f"HEDGEMARK.POSITION.BOS_PAT_BOWDOIN.{datetime.datetime.now():%Y%m%d.%H%M%S}.{asset_type.capitalize()}Deal.PositionsAsOf{args.date}.csv" @@ -44,79 +49,6 @@ def process_upload(positions, upload): ) -def build_line(obj, asset_type): - return [obj.get(h, None) for h in HEADERS[asset_type]] - - -HEADERS = { - "bond": [ - "AccountNumber", - "COB Date", - "Prime Broker", - "SecurityType", - "CUSIP", - "ISIN", - "SEDOL", - "SecurityDescription", - "Position", - "MarketPrice", - "Currency", - "Base Market Value", - "Local Market Value", - "Fx Rate", - ], - "future": [ - "AccountNumber", - "COB Date", - "Prime Broker", - "SecurityType", - "BBGTicker", - "RIC", - "UnderlyingSecurity", - "SecurityDescription", - "Currency", - "Quantity", - "OpenTradeEquity", - "ClosingPrice", - "MaturityDate", - "Unrealised P&L in USD", - "Local Market Value", - "Fx Rate", - ], - "otc": [ - "Client Name", - "Fund Name", - "Counterparty", - "Product Type", - "Unique Deal ID", - "TransactionIndicator (Buy/Sell)", - "PutCall Indicator (Call/Put)", - "CapFloorIndicator", - "CurrencyPair", - "DealCurrencyA", - "DealCurrencyB", - "NotionalA", - "NotionalB", - "OriginalPrice", - "Strike", - "FixedRate", - "Quantity", - "Start Date", - "Effective Date", - "Maturity Date", - "Underlying Maturity", - "RecPayFixed", - "Underlying (ISIN / CUSP / RED CODES)", - "Underlying Desc", - "Exercise Type", - "MTM Currency", - "MTM Valuation", - "COB Date", - "Clearing House Name", - ], -} - - def positions_bond(conn, date): with conn.cursor() as c: c.execute("SELECT * FROM risk_positions(%s, null, 'BOWDST') ", (date,)) |
