aboutsummaryrefslogtreecommitdiffstats
path: root/python/notebooks/Valuation Backtest.ipynb
diff options
context:
space:
mode:
Diffstat (limited to 'python/notebooks/Valuation Backtest.ipynb')
-rw-r--r--python/notebooks/Valuation Backtest.ipynb36
1 files changed, 27 insertions, 9 deletions
diff --git a/python/notebooks/Valuation Backtest.ipynb b/python/notebooks/Valuation Backtest.ipynb
index 6326ec98..6a81dcd5 100644
--- a/python/notebooks/Valuation Backtest.ipynb
+++ b/python/notebooks/Valuation Backtest.ipynb
@@ -55,7 +55,7 @@
"outputs": [],
"source": [
"#Regression Intercept\n",
- "results[0]"
+ "round(results[0],1)"
]
},
{
@@ -65,7 +65,7 @@
"outputs": [],
"source": [
"#Sale Difference\n",
- "results[1]"
+ "round(results[1],2)"
]
},
{
@@ -97,10 +97,17 @@
"#difference by source\n",
"nav = ops.get_net_navs()['endbooknav']\n",
"difference = mark.diff_by_source_percentage(df)\n",
- "#difference.to_clipboard()\n",
- "\n",
+ "#difference.to_clipboard()"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
"#plot\n",
- "ax = difference.plot(kind = 'bar', legend = True)\n",
+ "ax = difference.plot(kind = 'bar', legend = True, figsize = [10, 3.5])\n",
"\n",
"visible = ax.xaxis.get_ticklabels()[::6]\n",
"for label in ax.xaxis.get_ticklabels():\n",
@@ -110,7 +117,11 @@
"ax.xaxis.set_major_formatter(plt.FixedFormatter(difference.index.to_series().dt.strftime(\"%b %Y\")))\n",
"ax.set_ylabel('NAV Impact vs. Fund Policy (%)')\n",
"vals = ax.get_yticks()\n",
- "ax.set_yticklabels(['{:3.0f}%'.format(x*100) for x in vals])"
+ "ax.set_yticklabels(['{:3.0f}%'.format(x*100) for x in vals])\n",
+ "ax.set_xlabel('')\n",
+ "ax.grid(False, which='major',axis = 'x')\n",
+ "lgd = ax.legend(loc='upper center', bbox_to_anchor=(0.5, -.3), shadow=True, ncol=5)\n",
+ "ax.figure.savefig(\"/home/serenitas/edwin/PythonGraphs/Valuation_2.png\", bbox_extra_artists=(lgd,), bbox_inches='tight')"
]
},
{
@@ -164,7 +175,7 @@
"metadata": {},
"outputs": [],
"source": [
- "mark.annual_performance(results[1])"
+ "round(mark.annual_performance(results[1])*100,2)"
]
},
{
@@ -174,7 +185,7 @@
"outputs": [],
"source": [
"#A positive impact % means the alternative methodology results in a higher NAV than the fund's valuation policy.\n",
- "pd.DataFrame(mark.alt_nav_impact())"
+ "round(pd.DataFrame(mark.alt_nav_impact())*100,2)"
]
},
{
@@ -213,7 +224,14 @@
"execution_count": null,
"metadata": {},
"outputs": [],
- "source": []
+ "source": [
+ "df = ops.trade_performance()\n",
+ "df = df.set_index('trade_date')\n",
+ "df.days_held = df.days_held.dt.days\n",
+ "winner = df[df.percent_gain > 0]\n",
+ "df[df.days_held.notnull()].groupby(pd.TimeGrouper(freq='A')).mean()\n",
+ "df"
+ ]
}
],
"metadata": {