aboutsummaryrefslogtreecommitdiffstats
path: root/python
diff options
context:
space:
mode:
Diffstat (limited to 'python')
-rw-r--r--python/globeop_reports.py7
-rw-r--r--python/notebooks/Allocation Reports.ipynb10
2 files changed, 8 insertions, 9 deletions
diff --git a/python/globeop_reports.py b/python/globeop_reports.py
index bb2c01db..f624971c 100644
--- a/python/globeop_reports.py
+++ b/python/globeop_reports.py
@@ -139,7 +139,7 @@ def pnl_alloc_plot(df):
ax.set_yticklabels(['{:.2f}%'.format(y*100) for y in y_ticks])
plt.tight_layout()
-def cap_alloc_plot(df):
+def cap_alloc_plot_pie(df):
""" Takes the alloc('capital') dataframe"""
# create piechart and add a circle at the center
@@ -158,7 +158,7 @@ def avg_turnover():
last_monthend = datetime.date.today() - off.MonthEnd(1)
sql_string = "SELECT * FROM bonds where buysell = 'False'"
df = pd.read_sql_query(sql_string, dbengine('dawndb'),
- parse_dates=['lastupdate', 'trade_date', 'settle_date'])
+ parse_dates={'lastupdate':'utc=True', 'trade_date':'', 'settle_date':''})
df = df[(df.trade_date > last_monthend - off.MonthEnd(12))
& (df.trade_date <= last_monthend)]
return (df.principal_payment + df.accrued_payment).sum()/avg_nav
@@ -184,7 +184,7 @@ def shift_cash(date, amount, df, strat):
df.loc[date,'Cash'] = df.loc[date, 'Cash'] + amount/nav.loc[date].endbooknav
return df
-def cap_alloc_plot(df):
+def cap_alloc_plot_bar(df):
#ax = df.plot.bar(stacked=True)
ax = df[:-1].plot.bar(stacked=True, legend=False, figsize=(10,4))
@@ -201,7 +201,6 @@ def cap_alloc_plot(df):
ax.xaxis.set_label_text("")
return ax
- #plt.tight_layout()
def calc_trade_performance_stats():
df = trade_performance().set_index('trade_date')
diff --git a/python/notebooks/Allocation Reports.ipynb b/python/notebooks/Allocation Reports.ipynb
index 14756d41..00ad7972 100644
--- a/python/notebooks/Allocation Reports.ipynb
+++ b/python/notebooks/Allocation Reports.ipynb
@@ -45,7 +45,7 @@
"#Capital Allocation\n",
"cap_alloc = go.alloc('capital')\n",
"alloc1 = cap_alloc.xs(report_date)\n",
- "go.cap_alloc_plot(alloc1)"
+ "go.cap_alloc_plot_pie(alloc1)"
]
},
{
@@ -85,10 +85,10 @@
"outputs": [],
"source": [
"df = cap_alloc.endbooknav.groupby('periodenddate').apply(lambda x: x/x.sum())\n",
- "df = df.unstack().groupby(pd.TimeGrouper('M')).apply(lambda df: df.loc[df.index[-1]])\n",
+ "df = df.unstack().groupby(pd.Grouper(freq='M')).apply(lambda df: df.loc[df.index[-1]])\n",
"df = go.shift_cash(datetime.date(2017,11,30), -2096454, df, 'Curve')\n",
"temp = df.iloc[-1].sort_values(ascending=False)\n",
- "df = df.reindex_axis(temp.index, axis=1)"
+ "df = df.reindex(temp.index, axis=1)"
]
},
{
@@ -97,7 +97,7 @@
"metadata": {},
"outputs": [],
"source": [
- "ax = go.cap_alloc_plot(df[:-1])\n",
+ "ax = go.cap_alloc_plot_bar(df[:-1])\n",
"lgd = ax.legend(loc='lower center', bbox_to_anchor=(0.5, -0.3), ncol=4)\n",
"ax.figure.savefig(\"/home/serenitas/edwin/PythonGraphs/cap_alloc_1.png\", bbox_extra_artists=(lgd,), bbox_inches='tight')"
]
@@ -135,7 +135,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
- "version": "3.6.1"
+ "version": "3.6.4"
}
},
"nbformat": 4,