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, 6 insertions, 6 deletions
diff --git a/python/position.py b/python/position.py
index dd142cf7..47ea1a46 100644
--- a/python/position.py
+++ b/python/position.py
@@ -115,11 +115,11 @@ def init_swap_rates(conn, session, tenors=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 15, 20
ticker = f"USISDA{t:02} Index"
sql_str = f'INSERT INTO USD_swap_fixings(fixing_date, "{t}y") ' + \
'VALUES(%s, %s) ON CONFLICT (fixing_date)' + \
- f' DO UPDATE SET "{t}y" = %s'
+ f' DO UPDATE SET "{t}y" = excluded."{t}y"'
with conn.cursor() as c:
c.executemany(sql_str,
- [(d, r, r) for d, r in data[ticker]['PX_LAST'].items()])
+ [(d, r) for d, r in data[ticker]['PX_LAST'].items()])
conn.commit()
def init_swaption_vol(session,
@@ -156,13 +156,13 @@ def insert_swaption_vol(data, conn, source, vol_type="N"):
for t in tenors[-14:]:
sql_str = f'INSERT INTO {table_name}(date, "{t}y", source) ' + \
'VALUES(%s, %s, %s) ON CONFLICT (date, source)' + \
- f' DO UPDATE SET "{t}y" = %s, source = %s'
+ f' DO UPDATE SET "{t}y" = excluded."{t}y", source = excluded.source'
with conn.cursor() as c:
df_temp = df.xs(t, axis=1, level=1).reindex(tenors, axis=1)
for k, v in df_temp.iterrows():
if np.all(np.isnan(v.values)):
continue
- c.execute(sql_str, (k, v.tolist(), source, v.tolist(), source))
+ c.execute(sql_str, (k, v.tolist(), source))
conn.commit()
def update_swaption_vol(conn, session,
@@ -186,7 +186,7 @@ def update_swaption_vol(conn, session,
for t in tenors[4:]:
sql_str = f'INSERT INTO {table_name}(date, "{t}y", source) ' + \
'VALUES(%s, %s, %s) ON CONFLICT (date, source)' + \
- f' DO UPDATE SET "{t}y" = %s, source = %s'
+ f' DO UPDATE SET "{t}y" = excluded."{t}y", source = excluded.source'
r = []
dates = []
for expiry in tenors:
@@ -201,7 +201,7 @@ def update_swaption_vol(conn, session,
if dates.count(dates[0]) < len(dates):
raise ValueError('Not all quotes are from the same date')
with conn.cursor() as c:
- c.execute(sql_str, (dates[0], r, source, r, source))
+ c.execute(sql_str, (dates[0], r, source))
conn.commit()
def update_swap_rates(conn, session,