aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--python/risk/bonds.py10
1 files changed, 5 insertions, 5 deletions
diff --git a/python/risk/bonds.py b/python/risk/bonds.py
index 23626c3b..5db1ec5e 100644
--- a/python/risk/bonds.py
+++ b/python/risk/bonds.py
@@ -15,7 +15,7 @@ class AssetClass(Enum):
CRT = auto()
-def get_df(date, engine, zero_factor=False):
+def get_df(date, engine, *, zero_factor=False):
if zero_factor:
normalization = "unnormalized"
table1 = "priced_orig_ntl"
@@ -59,8 +59,8 @@ def get_df(date, engine, zero_factor=False):
def subprime_risk(date, conn, engine):
- df = get_df(date, engine, False)
- df_zero = get_df(date, engine, True)
+ df = get_df(date, engine, zero_factor=False)
+ df_zero = get_df(date, engine, zero_factor=True)
df.loc[df_zero.index] = df_zero
df_pos = get_portfolio(date, conn, AssetClass.Subprime)
df_pv = df.xs("pv", axis=1, level=0)
@@ -121,7 +121,7 @@ def subprime_risk(date, conn, engine):
df_calc.bond_yield += (
np.log(df_calc.pv1 * df_calc.curr_ntl / df_calc.local_market_value)
/ df_calc.modDur
- ).clip_upper(1.0)
+ ).clip(upper=1.0)
# delta scaled by ratio of market_value to model value
df_calc.delta_ir *= df_calc.local_market_value / df_calc.pv3
return df_calc
@@ -136,7 +136,7 @@ def get_portfolio(date, conn, asset_class: AssetClass, fund="SERCGMAST"):
if asset_class is AssetClass.CLO:
with conn.cursor() as c:
c.execute(
- "SELECT cusip, identifier FROM securities " "WHERE asset_class = 'CLO'"
+ "SELECT cusip, identifier FROM securities WHERE asset_class = 'CLO'"
)
cusip_map = {identifier: cusip for cusip, identifier in c.fetchall()}
df["cusip"] = df["identifier"].replace(cusip_map)