aboutsummaryrefslogtreecommitdiffstats
path: root/python/external_deriv_marks.py
diff options
context:
space:
mode:
Diffstat (limited to 'python/external_deriv_marks.py')
-rw-r--r--python/external_deriv_marks.py22
1 files changed, 14 insertions, 8 deletions
diff --git a/python/external_deriv_marks.py b/python/external_deriv_marks.py
index ea8acdc8..28a7b048 100644
--- a/python/external_deriv_marks.py
+++ b/python/external_deriv_marks.py
@@ -5,6 +5,7 @@ from env import DAILY_DIR
from collateral.baml_isda import load_excel
from collateral.citi import load_pdf, get_col
from dates import bus_day
+from analytics.utils import next_business_day
# local_nav is the nav in the trade's own currency
COLUMNS = ["trade_date", "buy/sell", "notional", "local_nav", "base_nav", "ia"]
@@ -76,9 +77,11 @@ def ms_navs(date: datetime.date = None, fund: str = "Serenitas"):
def citi_navs(date: datetime.date = None, **kwargs):
+ date = next_business_day(date)
dfs = []
- glob_str = f"{date + bus_day:%Y%m%d}*" if date else "*"
+ glob_str = f"{date:%Y%m%d}*" if date else "*"
for fname in (DAILY_DIR / "CITI_reports").glob(f"262966_Portfolio_{glob_str}.xlsx"):
+ print(fname)
df = pd.read_excel(
fname, skiprows=6, skipfooter=2, parse_dates=["Trade Date", "Value Date"]
)
@@ -92,7 +95,7 @@ def citi_navs(date: datetime.date = None, **kwargs):
"Notional",
"Market Value",
"Market Value",
- "BasicAmt",
+ "BaxsicAmt",
]
]
df.columns = COLUMNS
@@ -110,8 +113,9 @@ def citi_navs(date: datetime.date = None, **kwargs):
def baml_navs(date: datetime.date = None, fund: str = "Serenitas"):
+ date = next_business_day(date)
dfs = []
- glob_str = f"{date + bus_day:%m%d%Y}" if date else "*"
+ glob_str = f"{date:%m%d%Y}" if date else "*"
for fname in (DAILY_DIR / fund / "BoA_reports").glob(
f"301__LMCG_INVESTMENTSLP_CSA_{glob_str}_*.xls"
):
@@ -180,7 +184,7 @@ def cs_navs(date: datetime.date = None, fund: str = "Serenitas"):
df = df[["Trade Date", "Buy/Sell", "Notional", "Mid Price", "Mid Price"]]
df.columns = COLUMNS[:-1]
# TODO: fix this
- df_ia = get_ia(date)
+ df_ia = get_ia(date, fund)
df = df.join(df_ia)
d[datetime.datetime.strptime(fname.stem.split("_")[1], "%b%d%Y").date()] = df
if d:
@@ -192,9 +196,10 @@ def cs_navs(date: datetime.date = None, fund: str = "Serenitas"):
return df
-def get_ia(date: datetime.date = None):
- glob_str = f"{date + bus_day:%m%d%Y}"
- for fname in (DAILY_DIR / "CS_reports").glob(
+def get_ia(date: datetime.date = None, fund: str = "Serenitas"):
+ date = next_business_day(date)
+ glob_str = f"{date:%m%d%Y}"
+ for fname in (DAILY_DIR / fund / "CS_reports").glob(
f"CollateralCptyStatement161SerenitasCGMFRVM_{glob_str}.pdf"
):
l = load_pdf(fname)
@@ -243,6 +248,7 @@ if __name__ == "__main__":
type=datetime.datetime.fromisoformat,
nargs="?",
default=datetime.date.today(),
+ help="this is today's date, we load marks as of previous day cob",
)
parser.add_argument(
"-a", "--all", action="store_true", default=False, help="download everything"
@@ -251,7 +257,7 @@ if __name__ == "__main__":
"-d", "--debug", action="store_true", default=False, help="more verbose logging"
)
args = parser.parse_args()
- date = None if args.all else args.date - bus_day
+ date = None if args.all else (args.date - bus_day).date()
logging.basicConfig()
logger = logging.getLogger("external_marks")
logger.setLevel(logging.DEBUG if args.debug else logging.INFO)