Skip to content

Commit

Permalink
Start with with chapter results πŸ‘¨β€πŸ’» (#401)
Browse files Browse the repository at this point in the history
  • Loading branch information
KarelZe authored Jun 5, 2023
1 parent 550521f commit f04b70b
Show file tree
Hide file tree
Showing 7 changed files with 451 additions and 120 deletions.
82 changes: 81 additions & 1 deletion notebooks/6.0a-mb-visualizations.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"import matplotlib.dates as mdates\n",
"import matplotlib.ticker as ticker\n",
"from matplotlib.ticker import FormatStrFormatter, StrMethodFormatter, PercentFormatter\n",
"\n",
"from matplotlib.dates import DateFormatter\n",
"\n",
"import json\n",
"import os\n",
Expand Down Expand Up @@ -71,6 +71,86 @@
")\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Accuracies Over Time"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"accuracies_over_time_ise = pd.read_parquet(\"gs://thesis-bucket-option-trade-classification/data/results/ise_supervised_all-classical-accurcies-over-time.parquet\")\n",
"accuracies_over_time_cboe = pd.read_parquet(\"gs://thesis-bucket-option-trade-classification/data/results/cboe_supervised_all-classical-accurcies-over-time.parquet\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"fig, ax = plt.subplots(2,1,figsize=(14*CM,10*CM), sharey=True, sharex=True, tight_layout=True)\n",
"\n",
"\n",
"ax[0].plot(accuracies_over_time_ise[\"tick(all)\"], label=\"$\\operatorname{tick}_{\\mathrm{all}}$\", lw=1)\n",
"ax[0].plot(accuracies_over_time_ise[\"quote(best)\"], label=\"$\\operatorname{quote}_{\\mathrm{nbbo}}$\", lw=1, zorder=20)\n",
"ax[0].plot(accuracies_over_time_ise[\"quote(best)->quote(ex)->rev_tick(all)\"], label=r\"$\\operatorname{quote}_{\\mathrm{nbbo}} \\to \\operatorname{quote}_{\\mathrm{ex}} \\to \\operatorname{rtick}_{\\mathrm{all}}$\", lw=1, zorder=50)\n",
"ax[0].plot(accuracies_over_time_ise[\"trade_size(ex)->quote(best)->quote(ex)->depth(best)->depth(ex)->rev_tick(all)\"], label=r\"$\\operatorname{tsize}_{\\mathrm{ex}} \\to \\operatorname{quote}_{\\mathrm{nbbo}} \\to \\operatorname{quote}_{\\mathrm{ex}} \\to \\operatorname{depth}_{\\mathrm{nbbo}} \\to \\operatorname{depth}_{\\mathrm{ex}} \\to \\operatorname{rtick}_{\\mathrm{all}}$\", lw=1, zorder=100)\n",
"\n",
"ax[0].axvline(x=pd.Timestamp('2013-10-24'), linestyle='--', color='grey', linewidth=0.5)\n",
"ax[0].axvline(x=pd.Timestamp('2015-11-05'), linestyle='--', color='grey', linewidth=0.5)\n",
"\n",
"# ax[1].s\n",
"ax[1].plot(accuracies_over_time_cboe[\"tick(all)\"], label=\"$\\operatorname{tick}_{\\mathrm{all}}$\", lw=1)\n",
"ax[1].plot(accuracies_over_time_cboe[\"quote(best)\"], label=\"$\\operatorname{quote}_{\\mathrm{nbbo}}$\", lw=1, zorder=20)\n",
"ax[1].plot(accuracies_over_time_cboe[\"quote(best)->quote(ex)->rev_tick(all)\"], label=r\"$\\operatorname{quote}_{\\mathrm{nbbo}} \\to \\operatorname{quote}_{\\mathrm{ex}} \\to \\operatorname{rtick}_{\\mathrm{all}}$\", lw=1, zorder=50)\n",
"ax[1].plot(accuracies_over_time_cboe[\"trade_size(ex)->quote(best)->quote(ex)->depth(best)->depth(ex)->rev_tick(all)\"], label=r\"$\\operatorname{tsize}_{\\mathrm{ex}} \\to \\operatorname{quote}_{\\mathrm{nbbo}} \\to \\operatorname{quote}_{\\mathrm{ex}} \\to \\newline \\operatorname{depth}_{\\mathrm{nbbo}} \\to \\operatorname{depth}_{\\mathrm{ex}} \\to \\operatorname{rtick}_{\\mathrm{all}}$\", lw=1, zorder=100)\n",
"\n",
"ax[1].axvline(x=pd.Timestamp('2015-11-05'), linestyle='--', color='grey', linewidth=0.5)\n",
"\n",
"#ax[1].legend(frameon=False, loc=\"lower center\", ncols=2, bbox_to_anchor=(0.5, -1))\n",
"\n",
"# y-axis\n",
"ax[0].set_ylabel(\"Accuracy\")\n",
"ax[1].set_ylabel(\"Accuracy\")\n",
"ax[0].set_ylim(0,100)\n",
"ax[0].yaxis.set_major_formatter(PercentFormatter(100.0,decimals=2))\n",
"\n",
"# first ise and last cboe\n",
"ax[0].set_xlim(accuracies_over_time_ise.index[0],accuracies_over_time_cboe.index[-1])\n",
"\n",
"# bins_dt = [pd.Timestamp(\"2000-01-01 00:00:00\"), pd.Timestamp(\"2013-10-24 23:59:00\"), pd.Timestamp(\"2015-11-05 23:59:00\"),pd.Timestamp(\"2099-12-31 23:59:59\")]\n",
"# else:\n",
"# bins_dt = [pd.Timestamp(\"2000-01-01 00:00:00\"), pd.Timestamp(\"2015-06-15 23:59:00\"), pd.Timestamp(\"2016-10-12 23:59:00\"),pd.Timestamp(\"2099-12-31 23:59:59\")]\n",
"\n",
"handles, labels = ax[1].get_legend_handles_labels()\n",
"order = [0, 1, 2, 3]\n",
"ax[1].legend([handles[idx] for idx in order],[labels[idx] for idx in order], frameon=False, loc=\"lower center\", ncols=2, bbox_to_anchor=(0.5, -1))\n",
"\n",
"ax[0].set_title('ISE')\n",
"ax[1].set_title('CBOE')\n",
"\n",
"# x-axis\n",
"# ax.set_xlabel(\"Date\")\n",
"date_form = DateFormatter(\"%b %Y\")\n",
"ax[0].xaxis.set_major_formatter(date_form)\n",
"\n",
"# plt.xlabel(\"common X\")\n",
"# plt.ylabel(\"Accuracy\")\n",
"\n",
"plt.tight_layout()\n",
"plt.savefig(\"../reports/Graphs/accuracies_over_time_ise_cboe.pdf\", bbox_inches=\"tight\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand Down
Loading

0 comments on commit f04b70b

Please sign in to comment.