diff options
Diffstat (limited to 'python/dawn_utils.py')
| -rw-r--r-- | python/dawn_utils.py | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/python/dawn_utils.py b/python/dawn_utils.py index 1ce4007d..bfa3d312 100644 --- a/python/dawn_utils.py +++ b/python/dawn_utils.py @@ -29,6 +29,8 @@ identifier = COALESCE(identifier, cusip, isin)', NEW.id); stub := 'SCCSH'; WHEN 'capfloors' THEN stub := 'CAP'; + WHEN 'spots' THEN + stub := 'SCFX'; END CASE; sqlstr := format(sqlstr, 'dealid = $1||id', NEW.id); END IF; @@ -155,6 +157,36 @@ def load_wires(engine, schema=None): blotter.to_sql('wires', engine, if_exists='append', index=False, schema=schema) return blotter +def load_spots(engine, schema=None): + blotter = pd.read_excel("/home/serenitas/Daily/Blotter_gh.xlsm", 'FXSpot', + skiprows=[0, 1, 2, 3, 4]) + blotter.dropna(axis=0, subset=['Deal ID'], inplace=True) + blotter = blotter.iloc[:,2:] + blotter.drop(['Deal Type', 'Asset Class', 'Client', 'State', "Counterparty", + "Custodian", "Cash Account", "Account"], + axis=1, inplace=True) + blotter.rename(columns= {'Date': 'trade_date', + 'Settlement Date': 'settlement_date', + 'Cash Account': 'cashaccount', + 'Strategy': 'folder', + 'Deal ID': 'id', + 'Action': 'action', + 'Sell Currency': 'sell_currency', + 'Sell Amount': 'sell_amount', + 'Buy Currency': 'buy_currency', + 'Buy Amount': 'buy_amount', + 'Spot - Buy/Sold Rate': 'spot_rate', + 'Commission Currency': 'commission_currency', + 'commission note': 'commission'}, inplace=True) + blotter.folder = blotter.folder.str.rstrip() + blotter['action'] = 'NEW' + blotter['id'] = blotter['id'].str.replace('[A-Z_]', '').astype('int') + blotter['custodian'] = 'INTBR' + blotter['cashaccount'] = 'IANSCLMAFU' + blotter['cp_code'] = 'IBKRNY' + blotter.to_sql('spots', engine, if_exists='append', index=False, schema=schema) + return blotter + if __name__ == "__main__": """ This script will create the tables and triggers for the Dawn app. If schema is not None, it will create it under a specific schema""" |
