aboutsummaryrefslogtreecommitdiffstats
path: root/python
diff options
context:
space:
mode:
Diffstat (limited to 'python')
-rw-r--r--python/risk/portfolio.py31
1 files changed, 9 insertions, 22 deletions
diff --git a/python/risk/portfolio.py b/python/risk/portfolio.py
index c1564395..1f30c15a 100644
--- a/python/risk/portfolio.py
+++ b/python/risk/portfolio.py
@@ -34,21 +34,7 @@ def gen_bond_proxies(position_date, fund, conn):
crt_pos = crt_risk(position_date, conn, fund=fund)
with dbconn("etdb") as etconn:
clo_pos = clo_risk(position_date, conn, etconn, fund=fund)
-
- for name, position in zip(
- (
- "rmbs_bonds",
- "crt_bonds",
- "clo_bonds",
- ),
- (
- rmbs_pos,
- crt_pos,
- clo_pos,
- ),
- ):
- if isinstance(position, pd.DataFrame):
- yield name, -position.get("hy_equiv", np.zeros(1)).sum()
+ return {"rmbs_bonds": rmbs_pos, "ctd_bonds": crt_pos, "clo_bonds": clo_pos}
def build_portfolio(position_date, value_date, fund="SERCGMAST"):
@@ -69,12 +55,10 @@ def build_portfolio(position_date, value_date, fund="SERCGMAST"):
syn_portf = deepcopy(portf)
syn_portf += get_index_portfolio(position_date, conn, fund)
- curve_portf = get_index_portfolio(
- position_date, conn, fund, include_strategies="%CURVE"
- )
nocurve_portf = get_index_portfolio(
position_date, conn, fund, exclude_strategies="%CURVE"
)
+ portf += nocurve_portf
basis_portf = get_index_portfolio(
position_date, conn, fund, include_strategies="%BASIS"
)
@@ -83,17 +67,20 @@ def build_portfolio(position_date, value_date, fund="SERCGMAST"):
("CASH_BASIS", "negate_basis_trades"),
)
- portf += nocurve_portf
+ curve_portf = get_index_portfolio(
+ position_date, conn, fund, include_strategies="%CURVE"
+ )
curve_portf.value_date = value_date
curve_portf.mark()
portf.add_trade(
hy_equiv_trade(value_date, curve_portf.hy_equiv),
("curve_trades", "curve_trades"),
)
-
# Add the bond proxies to the portfolio only
- for name, notional in gen_bond_proxies(position_date, fund, conn):
- portf.add_trade(hy_equiv_trade(value_date, notional), (name, name))
+ for name, pos in gen_bond_proxies(position_date, fund, conn).items():
+ portf.add_trade(
+ hy_equiv_trade(value_date, pos.hy_equiv.sum()), (name, name)
+ )
for p in [portf, syn_portf]:
p.value_date = value_date