aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--python/load_globeop_report.py30
1 files changed, 12 insertions, 18 deletions
diff --git a/python/load_globeop_report.py b/python/load_globeop_report.py
index 6fd998b9..03297caa 100644
--- a/python/load_globeop_report.py
+++ b/python/load_globeop_report.py
@@ -3,18 +3,17 @@ import os
import pandas as pd
from itertools import chain
from dates import bus_day
-import pdb
-def get_globs(fname, years=['2013', '2014', '2015', '2016']):
- basedir = '/home/share/Daily'
+def get_globs(fname, years=['2013', '2014', '2015', '2016', '2017']):
+ basedir = '/home/serenitas/Daily'
globs = [iglob(os.path.join(basedir,
year,
"{0}_*/{0}*/Reports/{1}.csv".format(year, fname)))
for year in years]
for year in years[-2:]:
globs.append(iglob(os.path.join(basedir,
- '{0}-*/Reports/{1}.csv'.format(year,
- fname))))
+ '{0}-*/Reports/{1}.csv'.format(year,
+ fname))))
return globs
def valuation_reports():
@@ -25,18 +24,18 @@ def valuation_reports():
except ValueError:
date = pd.Timestamp(f.split('/')[4])
- if date>=pd.Timestamp('2013-02-06'):
+ if date >= pd.Timestamp('2013-02-06'):
newdf = pd.read_csv(f, parse_dates=['KnowledgeDate','PeriodEndDate'])
else:
newdf = pd.read_csv(f)
newdf['KnowledgeDate'] = date
newdf['PeriodEndDate'] = date - bus_day
if newdf.empty or ('PeriodEndDate' in df and \
- not df[df.PeriodEndDate == newdf.PeriodEndDate.iat[0]].empty):
+ not df[df.PeriodEndDate == newdf.PeriodEndDate.iat[0]].empty):
continue
df = df.append(newdf)
del df['AccountingPeriod']
- for col in ['Strat','InvCcy','Fund','Port']:
+ for col in ['Strat', 'InvCcy', 'Fund', 'Port']:
df[col] = df[col].astype('category')
df.to_hdf('globeop.hdf', 'valuation_report', format='table', complib='blosc')
@@ -48,8 +47,6 @@ def pnl_reports():
except ValueError:
date = pd.Timestamp(f.split('/')[4])
date = date - bus_day
- if date in df:
- print(date)
df[date] = pd.read_csv(f)
df = pd.concat(df, names=['date', 'to_drop'])
df.reset_index(level='to_drop', drop=True, inplace=True)
@@ -58,21 +55,18 @@ def pnl_reports():
df[col] = df[col].astype('category')
df.to_hdf('globeop.hdf', 'pnl', format='table', complib='blosc')
-def ts(s):
- return pd.Timestamp(s)
-
def monthly_pnl_bycusip(df, strats):
df = df[(df.Strat.isin(strats)) & (df.CustAcctName=='V0NSCLMAMB')]
pnl_cols = ['BookUnrealMTM', 'BookRealMTM', 'BookRealIncome', 'BookUnrealIncome',
'TotalBookPL']
- return df.groupby('InvId').resample('M', 'last')[['MTD '+col for col in pnl_cols]]
+ return df.groupby('InvId').resample('M').last()[['MTD '+col for col in pnl_cols]]
if __name__=='__main__':
- #valuation_reports()
- #pnl_reports()
+ valuation_reports()
+ pnl_reports()
df_val = pd.read_hdf('globeop.hdf', 'valuation_report')
df_pnl = pd.read_hdf('globeop.hdf', 'pnl')
- nav = df_val[df_val.Fund=='SERCGMAST'].groupby('PeriodEndDate')['EndBookNAV'].sum()
+ nav = df_val[df_val.Fund == 'SERCGMAST'].groupby('PeriodEndDate')['EndBookNAV'].sum()
subprime_strats = ['MTG_GOOD', 'MTG_RW', 'MTG_IO','MTG_THRU', 'MTG_B4PR']
clo_strats = ['CLO_BBB', 'CLO_AAA', 'CLO_BB20']
@@ -83,6 +77,6 @@ if __name__=='__main__':
#df_monthly.loc[idx[ts('2015-01-01'):ts('2015-01-31'),:],:]
# clo = df_pnl[df_pnl.Strat.isin(clo_strats)]
- # clo_monthly_pnl = clo.groupby(level=0).sum()['MTD TotalBookPL'].resample('M', how='last')
+ # clo_monthly_pnl = clo.groupby(level=0).sum()['MTD TotalBookPL'].resample('M').last()
# clo.groupby(level=0).sum()['2015-12-01':'2015-12-31']