aboutsummaryrefslogtreecommitdiffstats
path: root/python/position.py
diff options
context:
space:
mode:
Diffstat (limited to 'python/position.py')
-rw-r--r--python/position.py12
1 files changed, 7 insertions, 5 deletions
diff --git a/python/position.py b/python/position.py
index 84b8d82d..4bd54c6f 100644
--- a/python/position.py
+++ b/python/position.py
@@ -41,7 +41,7 @@ def backpopulate_marks(begin_str='2015-01-15', end_str='2015-07-15'):
positions = positions.drop_duplicates()
positions.to_sql('position', engine, if_exists='append', index=False)
-def update_securities(engine, session):
+def update_securities(engine, session, workdate):
field = {'Corp': 'PREV_CPN_DT', 'Mtge': 'START_ACC_DT'}
all_securities = get_list(engine)
conn = engine.raw_connection()
@@ -51,9 +51,11 @@ def update_securities(engine, session):
data = pd.DataFrame.from_dict(data, orient='index')
m = securities.merge(data, left_index=True, right_index=True)
with conn.cursor() as c:
- c.executemany("UPDATE securities SET start_accrued_date=%({0})s "
- ",coupon=%(CUR_CPN)s WHERE identifier=%(identifier)s".format(field[bbg_type]),
- m.to_dict('records'))
+ for r in m.to_dict('records'):
+ if r[field[bbg_type]]<workdate:
+ c.execute("UPDATE securities SET start_accrued_date=%({0})s "
+ ",coupon=%(CUR_CPN)s WHERE identifier=%(identifier)s".format(field[bbg_type]),
+ r)
conn.commit()
def init_fx(session, engine, startdate):
@@ -129,7 +131,7 @@ if __name__=="__main__":
engine = create_engine('postgresql://dawn_user@debian/dawndb')
workdate = pd.datetime.today()
with init_bbg_session(BBG_IP) as session:
- update_securities(engine, session)
+ update_securities(engine, session, workdate)
populate_cashflow_history(engine, session, workdate)
update_fx(engine, session, ['EURUSD', 'CADUSD'])
# # with init_bbg_session(BBG_IP) as session: