diff options
Diffstat (limited to 'python')
| -rw-r--r-- | python/swaption_pnl.py | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/python/swaption_pnl.py b/python/swaption_pnl.py index f17a9da8..985eca94 100644 --- a/python/swaption_pnl.py +++ b/python/swaption_pnl.py @@ -1,21 +1,22 @@ import datetime import pandas as pd from analytics.utils import get_fx +from dates import bus_day from psycopg2.extensions import connection from risk.swaptions import get_swaption_portfolio from risk.indices import get_index_portfolio from pandas.tseries.offsets import BDay from pyisda.date import previous_twentieth -from typing import Tuple +from typing import Tuple, Union def get_index_pv( start_date: datetime.date, end_date: datetime.date, conn: connection, - strategies: Tuple[str] = None, + strategies: Union[Tuple[str], None] = None, ): - dr = pd.bdate_range(start_date, end_date) + dr = pd.bdate_range(start_date, end_date, freq=bus_day) pvs = [] daily = [] dates = [] @@ -41,7 +42,7 @@ def get_index_pv( for (fee, curr) in c: nav += fee * get_fx(curr, d) daily.append(nav + accrued) - pvs.append(portf.local_pv) + pvs.append(portf.pv) dates.append(prev_day) df = pd.DataFrame({"pv": pvs, "daily": daily}, index=pd.to_datetime(dates)) return df @@ -50,12 +51,12 @@ def get_index_pv( def get_swaption_pv( start_date: datetime.date, end_date: datetime.date, conn: connection, **kwargs ): - dr = pd.bdate_range(start_date, end_date) + dr = pd.bdate_range(start_date, end_date, freq=bus_day) pv = [] daily = [] dates = [] for d in dr: - prev_day = (d - BDay()).date() + prev_day = (d - bus_day).date() portf = get_swaption_portfolio(prev_day, conn, **kwargs) nav = 0.0 # add terminations |
