aboutsummaryrefslogtreecommitdiffstats
path: root/python/pnl_explain.py
diff options
context:
space:
mode:
Diffstat (limited to 'python/pnl_explain.py')
-rw-r--r--python/pnl_explain.py12
1 files changed, 8 insertions, 4 deletions
diff --git a/python/pnl_explain.py b/python/pnl_explain.py
index c00c2348..a631eeb7 100644
--- a/python/pnl_explain.py
+++ b/python/pnl_explain.py
@@ -133,7 +133,12 @@ def get_tranche_pv(
# we know prev_day is an accrued payment date
# we remove one business day so that previous_twentieth actually returns
# the previous twentieth
- amount = (prev_day - previous_twentieth(prev_day - bus_day)).days / 360
+ amount = (
+ (
+ prev_day
+ - previous_twentieth(prev_day - bus_day, cal="/usr/share/cds/US")
+ ).days
+ ) / 360
accrued = 0.0
for t in portf.trades:
accrued -= (
@@ -210,12 +215,11 @@ def get_tranche_pv2(
start_date = prev_business_day(start_date)
df = pd.read_sql_query(
"SELECT date, tranche_id AS id, "
- "clean_nav * (CASE WHEN currency='USD' THEN 1. ELSE eurusd END) AS clean_nav, "
- "accrued * (CASE WHEN currency='USD' THEN 1. ELSE eurusd END) AS accrued, "
+ "clean_nav, "
+ "accrued, "
"folder "
"FROM tranche_risk "
"JOIN cds ON tranche_id=id "
- "LEFT JOIN fx USING (date) "
"WHERE date BETWEEN %s and %s AND fund=%s",
conn,
params=(start_date, end_date, fund),