aboutsummaryrefslogtreecommitdiffstats
path: root/python/position.py
diff options
context:
space:
mode:
Diffstat (limited to 'python/position.py')
-rw-r--r--python/position.py19
1 files changed, 13 insertions, 6 deletions
diff --git a/python/position.py b/python/position.py
index cc229136..15c4f0c7 100644
--- a/python/position.py
+++ b/python/position.py
@@ -12,11 +12,11 @@ def get_bbg_numbers(workdate, fields):
positions = pd.read_sql_query("select * from list_positions(%s)", engine, params=(workdate.date(),))
positions.loc[positions.identifier.str.endswith('_A'),'bbg_id'] = positions.identifier.str.slice(stop=9)
positions.loc[~positions.identifier.str.endswith('_A'),'bbg_id'] = positions.identifier.str.slice(stop=12)
- sec = [s + " Mtge" if s!='XS0295516776' else s +" Corp" for s in positions.bbg_id.tolist()]
- data = retreive_data(session, sec, fields, workdate)
+ positions.bbg_id = positions.bbg_id + ' ' + positions.bbg_type
+ data = retreive_data(session, positions.bbg_id.tolist(), fields, workdate)
df = process_msgs(data)
df = pd.DataFrame.from_dict(df, orient='index')
- return df
+ return positions.merge(df, left_on='bbg_id', right_index=True)
def get_list(workdate):
positions = pd.read_sql_query("select * from list_positions(%s)", engine, params=(workdate.date(),))
@@ -47,8 +47,15 @@ def backpopulate_marks(begin_str='2015-01-15', end_str='2015-07-15'):
if __name__=="__main__":
session = init_bbg_session('192.168.0.4', 8194)
fields = ["START_ACC_DT", "MTG_FACTOR_PAY_DT", "CUR_CPN", "INT_ACC",
- "DAYS_ACC", "MTG_FACE_AMT", "MTG_FACTOR", "MTG_PREV_FACTOR", "MTG_FACTOR_PRINC_PAY",
- "MTG_PRINC_LOSSES", "CRNCY"]
+ "DAYS_ACC", "MTG_FACTOR", "MTG_PREV_FACTOR", "MTG_FACTOR_PRINC_PAY",
+ "MTG_PRINC_LOSSES"]
workdate = pd.datetime.today()
df = get_bbg_numbers(workdate, fields)
- df.to_csv("positions_{0:%Y-%m-%d}.csv".format(workdate))
+ # df.to_csv("../../positions_daily/positions_{0:%Y-%m-%d}.csv".format(workdate))
+ # df.rename(columns={'CUR_CPN': 'coupon',
+ # 'MTG_FACTOR': 'factor',
+ # 'price':
+ # conn = engine.raw_connection()
+ # with conn.cursor() as c:
+ # c.executemany("UPDATE position SET WHERE identifier= %(identifier)s
+ # with engine.raw_connenction.cursor() as c: