aboutsummaryrefslogtreecommitdiffstats
path: root/python/globeop_reports.py
diff options
context:
space:
mode:
Diffstat (limited to 'python/globeop_reports.py')
-rw-r--r--python/globeop_reports.py14
1 files changed, 7 insertions, 7 deletions
diff --git a/python/globeop_reports.py b/python/globeop_reports.py
index e44641b9..bb2c01db 100644
--- a/python/globeop_reports.py
+++ b/python/globeop_reports.py
@@ -16,7 +16,7 @@ def get_monthly_pnl(group_by = ['identifier']):
index_col=['date'])
df_pnl['identifier'] = df_pnl.invid.str.replace("_A$", "")
pnl_cols = ['bookunrealmtm', 'bookrealmtm', 'bookrealincome', 'bookunrealincome', 'totalbookpl']
- monthend_pnl = df_pnl.groupby(pd.TimeGrouper('M')).apply(lambda df: df.loc[df.index[-1]])
+ monthend_pnl = df_pnl.groupby(pd.Grouper(freq='M')).apply(lambda df: df.loc[df.index[-1]])
return monthend_pnl.groupby(['date'] + group_by)[['mtd' + col for col in pnl_cols]].sum()
def get_portfolio(report_date = False):
@@ -41,8 +41,8 @@ def curr_port_PNL(date = datetime.date.today(), asset_class='Subprime'):
def trade_performance():
sql_string = "SELECT * FROM bonds"
- df_trades = pd.read_sql_query(sql_string, dbengine('dawndb'), parse_dates=['lastupdate', 'trade_date', 'settle_date'])
- df_trades = df_trades[df_trades.asset_class == 'Subprime']
+ df_trades = pd.read_sql_query(sql_string, dbengine('dawndb'), parse_dates={'lastupdate': {'utc': True}, 'trade_date': {}, 'settle_date': {}})
+ df_trades = df_trades[df_trades['asset_class'] == 'Subprime']
df_pnl = get_monthly_pnl()
df_sell = df_trades[df_trades.buysell == False].groupby('identifier').last().reset_index()
@@ -167,14 +167,14 @@ def num_bond_by_strat():
df = get_portfolio()
df = df[(df.custacctname == 'V0NSCLMAMB') &
~(df.invid.isin(['USD', 'CAD', 'EUR'])) & (df.endqty > 0)]
- df = df.groupby(pd.TimeGrouper('M')).apply(lambda df: df.loc[df.index[-1]])
+ df = df.groupby(pd.Grouper(freq='M')).apply(lambda df: df.loc[df.index[-1]])
return df.groupby(['periodenddate', 'port']).identifier.nunique().unstack()
def num_bond_trades():
sql_string = "SELECT * FROM bonds"
df = pd.read_sql_query(sql_string, dbengine('dawndb'), parse_dates=['trade_date'],
index_col=['trade_date'])
- df = df.groupby([pd.TimeGrouper('M'), 'buysell']).identifier.count().unstack()
+ df = df.groupby([pd.Grouper(freq='M'), 'buysell']).identifier.count().unstack()
idx = pd.date_range(df.index[0], df.index[-1], freq = 'M')
return df.reindex(idx, fill_value = 0)
@@ -217,12 +217,12 @@ def calc_trade_performance_stats():
temp = {}
temp1 = {}
for x, df1 in df.groupby('winners'):
- for y, df2 in df1.groupby(pd.TimeGrouper(freq='A')):
+ for y, df2 in df1.groupby(pd.Grouper(freq='A')):
import pdb; pdb.set_trace()
y = y.date().year
results.loc[y] = df2[df2.days_held.notnull()].mean()[['curr_face','initialinvestment', 'days_held']]
#results.loc[] = len(df2[df2.winners == x].index)/len(df)
- df[df.days_held.notnull()]['days_held'].groupby(pd.TimeGrouper(freq='A')).mean()
+ df[df.days_held.notnull()]['days_held'].groupby(pd.Grouper(freq='A')).mean()