aboutsummaryrefslogtreecommitdiffstats
path: root/python/analytics/curve_trades.py
diff options
context:
space:
mode:
Diffstat (limited to 'python/analytics/curve_trades.py')
-rw-r--r--python/analytics/curve_trades.py10
1 files changed, 6 insertions, 4 deletions
diff --git a/python/analytics/curve_trades.py b/python/analytics/curve_trades.py
index 73afaa0f..6c20994d 100644
--- a/python/analytics/curve_trades.py
+++ b/python/analytics/curve_trades.py
@@ -66,8 +66,10 @@ def theta_matrix_by_series(index="IG", rolling=6):
return theta_matrix[["3yr", "5yr", "7yr", "10yr"]]
-def ratio_within_series(index="IG", rolling=6, param="duration"):
+def ratio_within_series(index="IG", rolling=6, param="duration", max_series=None):
otr = on_the_run(index)
+ if max_series is not None:
+ otr = max_series
df = get_index_quotes(
index, list(range(otr - rolling, otr + 1)), tenor=["3yr", "5yr", "7yr", "10yr"]
).unstack()
@@ -187,9 +189,9 @@ def forward_loss(index="IG"):
df["fwd_loss_rate"] = df.indexel.diff(2) / df.duration.diff(2)
-def curve_model(tenor_1="5yr", tenor_2="10yr", index="IG"):
+def curve_model(tenor_1="5yr", tenor_2="10yr", index="IG", max_series=None):
# OLS model
- df = ratio_within_series(index, param="close_spread")
+ df = ratio_within_series(index, param="close_spread", max_series=max_series)
df = pd.concat(
[
df.duration[tenor_1],
@@ -204,7 +206,7 @@ def curve_model(tenor_1="5yr", tenor_2="10yr", index="IG"):
)
df = np.log(df)
ols_model = smf.ols(
- "ratio ~ close_spread + duration1 + theta1 + theta2", data=df
+ "ratio ~ np.log(close_spread) + np.log(duration1) + theta1 + theta2", data=df
).fit()
return df, ols_model