aboutsummaryrefslogtreecommitdiffstats
path: root/python
diff options
context:
space:
mode:
Diffstat (limited to 'python')
-rw-r--r--python/risk/indices.py18
-rw-r--r--python/swaption_pnl.py7
2 files changed, 14 insertions, 11 deletions
diff --git a/python/risk/indices.py b/python/risk/indices.py
index 210d8aae..02aabb5e 100644
--- a/python/risk/indices.py
+++ b/python/risk/indices.py
@@ -5,15 +5,19 @@ from typing import Tuple
def get_index_portfolio(
- d: datetime.date, strategies: Tuple[str], conn: connection, **kwargs
+ d: datetime.date, conn: connection, strategies: Tuple[str] = None, **kwargs
):
+ sql_str = (
+ "SELECT security_id AS redcode, notional, maturity "
+ "FROM list_cds_positions_by_strat(%s) "
+ )
+ params = (d,)
+ if strategies is not None:
+ sql_str += "WHERE folder in %s"
+ params += (strategies,)
+
with conn.cursor() as c:
- c.execute(
- "SELECT security_id AS redcode, notional, maturity "
- "FROM list_cds_positions_by_strat(%s) "
- "WHERE folder in %s",
- (d, strategies),
- )
+ c.execute(sql_str, params)
trades = [
CreditIndex(
redcode=rec.redcode,
diff --git a/python/swaption_pnl.py b/python/swaption_pnl.py
index cf0cc653..1510ee90 100644
--- a/python/swaption_pnl.py
+++ b/python/swaption_pnl.py
@@ -11,8 +11,8 @@ from typing import Tuple
def get_index_pv(
start_date: datetime.date,
end_date: datetime.date,
- strategies: Tuple[str],
conn: connection,
+ strategies: Tuple[str] = None,
):
dr = pd.bdate_range(start_date, end_date)
pvs = []
@@ -28,7 +28,7 @@ def get_index_pv(
accrued -= amount * t.notional * t.factor * t.fixed_rate * 1e-4
else:
accrued = 0.0
- portf = get_index_portfolio(prev_day, strategies, conn)
+ portf = get_index_portfolio(prev_day, conn, strategies)
nav = 0.0
with conn.cursor() as c:
c.execute(
@@ -52,7 +52,6 @@ def get_swaption_pv(
daily = []
dates = []
for d in dr:
- print(d)
prev_day = (d - BDay()).date()
portf = get_swaption_portfolio(prev_day, conn, source_list=["GS"])
nav = 0.0
@@ -91,7 +90,7 @@ if __name__ == "__main__":
parser.add_argument("end_date", type=datetime.datetime.fromisoformat)
args = parser.parse_args()
df_index = get_index_pv(
- args.start_date, args.end_date, ("IGOPTDEL", "HYOPTDEL"), dawndb
+ args.start_date, args.end_date, dawndb, ("IGOPTDEL", "HYOPTDEL")
)
df_swaption = get_swaption_pv(args.start_date, args.end_date, dawndb)
pnl_index = df_index.pv.diff() + df_index.daily