diff options
Diffstat (limited to 'python/risk/bonds.py')
| -rw-r--r-- | python/risk/bonds.py | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/python/risk/bonds.py b/python/risk/bonds.py index 99010740..ecb720b5 100644 --- a/python/risk/bonds.py +++ b/python/risk/bonds.py @@ -84,7 +84,14 @@ def get_df(date, engine, *, zero_factor=False): def subprime_risk(pos_date, conn, engine, model_date=None): if model_date is None: - model_date = pos_date + sql_string = ( + "SELECT distinct timestamp::date FROM priced " + "WHERE normalization = 'current_notional' and model_version = 1 " + "AND date(timestamp) BETWEEN %s AND %s ORDER BY timestamp DESC" + ) + with conn.cursor() as c: + c.execute(sql_string, (pos_date - datetime.timedelta(days=15), pos_date)) + (model_date,) = c.fetchone() df = get_df(model_date, engine, zero_factor=False) df_zero = get_df(model_date, engine, zero_factor=True) df.loc[df_zero.index] = df_zero |
