diff --git a/notebooks/6.0a-mb-visualizations.ipynb b/notebooks/6.0a-mb-visualizations.ipynb index 5ab4958d..f520d75a 100644 --- a/notebooks/6.0a-mb-visualizations.ipynb +++ b/notebooks/6.0a-mb-visualizations.ipynb @@ -104,7 +104,7 @@ "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", + "ax[0].plot(accuracies_over_time_ise[\"trade_size(ex)->quote(best)->quote(ex)->depth(best)->depth(ex)->rev_tick(all)\"], label=r\"$\\operatorname{gsu}$\", 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", @@ -113,7 +113,7 @@ "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", + "ax[1].plot(accuracies_over_time_cboe[\"trade_size(ex)->quote(best)->quote(ex)->depth(best)->depth(ex)->rev_tick(all)\"], label=r\"$\\operatorname{gsu}$\", lw=1, zorder=100)\n", "\n", "ax[1].axvline(x=pd.Timestamp('2015-11-05'), linestyle='--', color='grey', linewidth=0.5)\n", "\n", @@ -148,7 +148,7 @@ "# plt.ylabel(\"Accuracy\")\n", "\n", "plt.tight_layout()\n", - "plt.savefig(\"../reports/Graphs/accuracies_over_time_ise_cboe.pdf\", bbox_inches=\"tight\")" + "plt.savefig(\"../reports/Graphs/accuracies_over_time.pdf\", bbox_inches=\"tight\")" ] }, { diff --git "a/references/obsidian/\360\237\223\226chapters/\360\237\217\205Results.md" "b/references/obsidian/\360\237\223\226chapters/\360\237\217\205Results.md" index 91ab06bf..5288dbb0 100644 --- "a/references/obsidian/\360\237\223\226chapters/\360\237\217\205Results.md" +++ "b/references/obsidian/\360\237\223\226chapters/\360\237\217\205Results.md" @@ -1,3 +1,41 @@ +## Trade Classification Rules + +We now estimate the accuracy of classical trade classification rules on the gls-ise and gls-cboe sample. We estimate the performance of the tick and quote rule, as well as the gls-LR algorithm, gls-EMO rule and gls-CLNV method in their classical and reversed formulation. Additionally, we consider two stacked combinations of ([[@grauerOptionTradeClassification2022]]) due to their state-of-the-art-performance on the validation set, as derived in cref-[[💡Hyperparameter Tuning]]. Namely, $\operatorname{quote}_{\mathrm{nbbo}} \to \operatorname{quote}_{\mathrm{ex}} \to \operatorname{rtick}_{\mathrm{all}}$ and $\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}}$ or in short $\operatorname{gsu}_{\mathrm{small}}$ and $\operatorname{gsu}_{\mathrm{large}}$. + +We report in cref-table-ise accuracies for the entire data set and separate subsets spanning the periods of train, validation, and test set. Doing so, allows us to compare against previous works, but also provide meaningful estimates on the test set relevant for benchmarking purposes. + +Our results are approximately similar to ([[@grauerOptionTradeClassification2022]]29-33). Minor deviations exist, which can linked to differences in handling of unclassified trades and non-positive spreads, as well divergent implementations of the depth rule.-footnote(Correspondence with the author.) + +From all rules, tick-based algorithms perform worst when applied to trade prices at the trading venue with accuracies of a random guess, percentage-49.67 or percentage-51.47. For comparison, a simple majority vote would achieve percentage-51.40 accuracy. The application to trade prices at the inter-exchange level marginally improves over a random / dummy classification, achieving accuracies of percentage-55.25 for the reversed tick test. Due to the poor performance, of tick-based algorithms at the exchange level, we estimate all hybrids with $\operatorname{tick}_{\mathrm{all}}$ or $\operatorname{rtick}_{\mathrm{all}}$. + +![[classical-ise-results.png]] + +Quote-based algorithms, outperform tick-based algorithms delivering accuracy up to percentage-63.71, when estimated on the gls-NBBO. The superiority of quote-based algorithms in option trade classification has previously been documented in ([[@savickasInferringDirectionOption2003]]) and ([[@grauerOptionTradeClassification2022]]). + +The performance of hybrids, such as the gls-LR algorithm, hinges with the reliance on the tick test. Thus, the gls-emo rules and to a lesser extent the gls-clnv rules perform worst, achieving accuracies between percentage-55.42 and percentage-57.57. In turn, variants of the gls-LR, which uses the quote rule for most trades, is among the best performing algorithms. By extension, $\operatorname{gsu}_{\mathrm{small}}$ further reduces the dependence on tick-based methods through the successive applications of quote rules, here $\operatorname{quote}_{\mathrm{nbbo}} \to \operatorname{quote}_{\mathrm{ex}}$. + +Notably, the combination of ([[@grauerOptionTradeClassification2022]]33) including overrides from the trade size and depth rules performs best, achieving percentage-67.20 accuracy on the gls-ise test set and percentage-75.03 on the entire dataset. Yet, the performance deteriorates most sharply between sets. + +**Finding 1: Accuracy of tick-based algorithms is downward-biased by missingness** +- grauer et al trace back low accuracy of tick-based algorithms to illiquidity in option markets. +- We do not have the time to previous trades. One would expect higher performance for more frequently traded options. Results of Grauer doe not indicate such a behaviour. +- Theoretical coverage reported in Grauer matches. Practically, coverage is much smaller due to minimal filter set. +- Simple experiment filter only for trades that can be classified by all trade classification rules +- Thus, we conclude tick-based algorithms are downward-biased +- Practically, coverage is much smaller e. g., negative / zero spreads, missingness of quotes etc. +- missingness as key driver to performance +- Plot missing trade prices and quotes over time. +- contemplate the results +- quote nbbo is far smaller for cboe then for ise. could this be the reason why the order reverses? + +**Finding 2: Accuracy comes from depth** +- building on finding 1, depth enables strong models, as classification is not performed using fallback criterion +- visualize which layer was used in classification +- inverse experiment. What happens if we work on filtered trades only? How does this affect the accuracy of hybrids? + +**Finding 3: Fee structures affect accuracy over time** +- performance fluctuates / diminishes over time and is affected by fee structure (see argument in [[@grauerOptionTradeClassification2022]]) +- track down fee structure changes with patterns in time series. We report accuracies for train, validation set and test set and entire set @@ -29,16 +67,22 @@ For example, if the 50,000 transactions misclassi"ed by the Lee and Ready method We report the accurac -## Summary -- start coarse-grained then report fine-grained results -- explain why results differ compared to Grauer et al -- think about reporting classical rules on the entire dataset -- report train, validation and test accuracies also over time (mark in graph where beginning and ned) +Aside from these high-level observations, we focus three findings in greater detail. -![[summarized-results.png]] +We repeat the analysis on the gls-cboe dataset in cref-table-cboe and observe a similar ranking to cref-table-ise. Overall, the performance of classical trade classification rules further diminishes strengthening the need for alternative classifiers. Tick-based rules trail the performance of quote-based approaches, and the accuracy of hybrids varies with the dependence on the tick test. Different from the gls-ise sample, the quote rule estimated on the gls-NBBO, $\operatorname{quote}_{\mathrm{nbbo}}$, leads to a lower performance than the quote rule applied to gls-CBOE quotes. Parts of this is due to the fact, that $\operatorname{quote}_{\mathrm{nbbo}}$ achieves a considerably lower coverage of percentage-94.77 compared to percentage-99.89 in the gls-ise sample, with fewer trades classified by the fallback criterion. In a filtered common sample, where trades are classified by both rules, performance is approximately similar. Again, $\operatorname{gsu}_{\mathrm{small}}$ and $\operatorname{gsu}_{\mathrm{large}}$ perform best. footnote-(Performance on gls-cboe, can be improved, if the order of quote rules is reversed. For full combinatoric coverage see ([[@grauerOptionTradeClassification2022]]33). To avoid overfitting the test set by classical rules, we keep the baseline constant following our reasoning from cref-[[💡Hyperparameter Tuning]].) On the test subsample, performance improvements from the trade size and depth rule are considerably smaller than in the gls-ISE dataset. +![[Pasted image 20230606072617.png]] +![[accuracies_classical.png]] + +For example, if the 50,000 transactions misclassi"ed by the Lee and Ready method constitute a representative cross-section of the entire sample, then the misclassi"cation will simply add noise to the data. In this case, the 85% accuracy rate is quite good. If, on the other hand, the Lee and Ready method systematically misclassi"es certain types of transactions, a bias could result. + + +![[summarized-results.png]] + + +Our remaining analysis is focused on the test set. ## Sub-samples @@ -48,56 +92,16 @@ visualize classical rules over time - -**Classical ISE:** -| | | tick(all) | quote(ex) | lr(ex) | emo(ex) | clnv(ex) | quote(best)->quote(ex) | trade_size(ex)->quote(best)->quote(ex)->depth(best)->depth(ex)->rev_tick(all) | | | -|-------------------|--------------|-----------|-----------|-----------|------------------------|-------------------------------------------------------------------------------|-----------|-----------| -| Option Type | C | 53.566483 | 56.338657 | 56.416520 | 53.500982 | 54.338435 | 58.881009 | 66.995000 | -| | P | 53.086524 | 57.748410 | 57.797980 | 54.118193 | 55.227019 | 60.772429 | 67.442413 | -| Security Type | Index option | 51.543849 | 53.728014 | 53.788502 | 51.280161 | 51.725311 | 57.797688 | 58.524483 | -| | Others | 53.255024 | 62.402034 | 62.494080 | 57.510196 | 59.066922 | 65.242783 | 70.137410 | -| | Stock option | 53.405332 | 54.870101 | 54.923804 | 52.328385 | 53.061654 | 57.588565 | 66.150581 | -| Trade Size | (0,1] | 52.850289 | 55.288035 | 55.418330 | 51.930230 | 52.957108 | 58.219535 | 68.780466 | -| | (1,3] | 52.825320 | 55.312322 | 55.398067 | 51.948962 | 52.864432 | 58.172238 | 68.845596 | -| | (3,5] | 52.401723 | 55.723949 | 55.768923 | 52.821732 | 53.604825 | 58.488028 | 68.958994 | -| | (5,11] | 53.636487 | 59.893257 | 59.899878 | 57.168629 | 57.977015 | 62.292800 | 63.295412 | -| | >11 | 55.555200 | 60.714690 | 60.695406 | 57.231189 | 58.461494 | 63.427558 | 64.547913 | -| Year | 2015 | 52.783955 | 54.902913 | 54.892890 | 52.851584 | 53.315622 | 56.143249 | 63.349227 | -| | 2016 | 53.284415 | 57.571543 | 57.635410 | 54.270965 | 55.222778 | 59.896339 | 67.117888 | -| | 2017 | 53.665234 | 56.367496 | 56.459133 | 52.986116 | 54.147313 | 60.676194 | 68.701844 | -| Time to Maturity | <= 1 | 53.073395 | 57.301220 | 57.362873 | 54.417911 | 55.223769 | 60.579671 | 67.111616 | -| | (1-2] | 53.404881 | 57.744957 | 57.762882 | 53.547187 | 54.776254 | 60.546956 | 68.117541 | -| | (2-3] | 53.697592 | 57.086186 | 57.179021 | 52.890993 | 54.140812 | 59.715752 | 67.886100 | -| | (3-6] | 53.868526 | 56.015521 | 56.110247 | 52.001021 | 53.348644 | 57.877722 | 67.452554 | -| | (6-12] | 54.269323 | 56.418807 | 56.472172 | 51.953456 | 53.581516 | 57.676192 | 67.470964 | -| | > 12 | 54.883085 | 52.696504 | 52.850764 | 51.198376 | 52.073364 | 50.941699 | 64.706435 | -| Moneyness | <= 0.7 | 54.502433 | 60.341653 | 60.421858 | 58.257767 | 58.981319 | 61.450529 | 64.113542 | -| | (0.7-0.9] | 55.491002 | 60.382149 | 60.573694 | 57.566221 | 58.607257 | 63.633651 | 67.868621 | -| | (0.9-1.1] | 52.950755 | 57.083316 | 57.112069 | 53.144508 | 54.335962 | 60.238270 | 68.152214 | -| | (1.1-1.3] | 51.621348 | 49.939075 | 49.998204 | 49.857566 | 49.670232 | 50.021966 | 61.661661 | -| | > 1.3 | 52.038059 | 48.723613 | 48.811119 | 50.046064 | 48.785237 | 48.722381 | 59.973687 | -| Location to Quote | at mid | 51.034217 | 49.998387 | 50.611316 | 51.028068 | 51.029882 | 55.950353 | 65.902387 | -| | inside | 52.408920 | 57.153707 | 57.153707 | 52.411885 | 53.793190 | 60.205206 | 64.242773 | -| | at quotes | 57.728367 | 59.971382 | 59.971382 | 59.970566 | 59.971127 | 59.969340 | 78.213062 | -| | outside | 62.363283 | 66.080655 | 65.745152 | 62.316312 | 62.235791 | 66.610750 | 64.892975 | -| | unknown | 52.459802 | 50.133425 | 52.500855 | 52.398221 | 52.480328 | 76.346220 | 76.442012 | -| All trades | all | 53.342427 | 56.996762 | 57.061417 | 53.789110 | 54.753246 | 59.763967 | 67.203863 | - - Unknown's are these where bid (ex) or ask (ex) is NaN. Grauer et al don't report these separately. They must be included somewhere else. - Makes sense that unknowns are close to 50 % for e. g., quote rule (ex). - Stacking adds robustness. It looks suspicious that combinations e. g., quote + quote, GSU reach highest classification accuracies. - - - % TODO: These proxies have in common that they factor in the order book imbalance the relative depth quoted at the best bid and ask prices. If traders care about transaction costs, the relatively wide ask-side spread deters buyers, whereas the tight bid-side spread may attract sellers. There are then more traders submitting market orders at the bid side, and the true effective spread is, on average, smaller than the average midpoint effective spread. % TODO: Derive in greater detail why orderbook imbalance makes sense! See my notes from Hagströmer - Perform an error analysis. For which classes does CatBoost do so poorly? See some ideas here. https://elitedatascience.com/feature-engineering-best-practises - - Akin to selecting the machine learning classifiers, we determine our classical baselines on the gls-ISE validation set. This guarantees a challenging baselines, while maintaining consistency between both paradigms. For the same reason, baselines are kept constant in the transfer setting on the gls-CBOE sample. Solely for reference, we also report accuracies of the gls-tick, gls-quote, gls-lr, due to their widespread adoption in finance. (insert table here) @@ -114,7 +118,6 @@ Calculate average rank ![[performance-degradations.png]] -- Think about using ensembles - - What are the findings? Find appropriate visualisation (e. g., tables, charts) - For each tuned configuration, we run 15 experiments with different random seeds and report the performance on the test set. For some algorithms, we also report the performance of default configurations without hyperparameter tuning. [[@gorishniyRevisitingDeepLearning2021]] diff --git "a/references/obsidian/\360\237\226\274\357\270\217Media/classical-ise-results.png" "b/references/obsidian/\360\237\226\274\357\270\217Media/classical-ise-results.png" new file mode 100644 index 00000000..a129da00 Binary files /dev/null and "b/references/obsidian/\360\237\226\274\357\270\217Media/classical-ise-results.png" differ diff --git a/reports/Content/data-preprocessing.tex b/reports/Content/data-preprocessing.tex index 79742753..3c52e923 100644 --- a/reports/Content/data-preprocessing.tex +++ b/reports/Content/data-preprocessing.tex @@ -103,7 +103,7 @@ \subsubsection{Data Preprocessing}\label{sec:data-preprocessing} Features and feature sets are documented in \cref{tab:feature-sets}. We aid the models by estimating the change in trade price between the previous and successive distinguishable trades. This is identical to the criterion used in the (reverse) tick rule, but in a non-quantized fashion to enforce a richer decision boundary and to surpass hard cut-off points. Similarly, the proximity of the trade price to the quotes, which is the decisive criterion in the quote rule and hybrids' thereof is added. The feature value ranges from $\left(-\infty,\infty\right)$ and is $-1$ for trades at the bid, 0 for trades at the mid, and 1 for trades at the ask. Quotes and trade prices are also incorporated as-is. -\todo{add reasoning. depth rule and trade size rule yield significant improvements and must be considered state of the art. Thus, extend feature set} +\todo{add reasoning. depth rule and trade size rule yield significant improvements and must be considered state of the art. Thus, extend feature set. See e.g., Savickas p. 889} Our second feature set extends the first feature set by the trade size and size of the quotes, required to estimate hybrid rules involving the depth rule and trade size rule. Both rules are state-of-the-art when paired with hybrid algorithms and are thus both benchmark and source of features. We model the depth rule as the ratio between ask and bid sizes and the trade size rule as the ratio between the size of the trade and the quoted bid and ask sizes. Since features are not discretized, we obtain a generic formulation of the trade size rule, where part of the quoted size can remain unfilled. The trade price and midspread required for the depth rule are already encompassed in the first feature set. diff --git a/reports/Content/diff-cboe_transfer_test.tex b/reports/Content/diff-cboe_transfer_test.tex deleted file mode 100644 index 82080e83..00000000 --- a/reports/Content/diff-cboe_transfer_test.tex +++ /dev/null @@ -1,50 +0,0 @@ -\begin{table} -\centering -\caption[short-diff-cboe_transfer_test]{long-diff-cboe_transfer_test} -\label{tab:diff-cboe_transfer_test} -\begin{tabular}{llSSSSSS} -\toprule -{} & {} & \multicolumn{2}{r}{gbm(classical)} & \multicolumn{2}{r}{gbm(classical-size)} & \multicolumn{2}{r}{gbm(ml)} \\ -{} & {} & {nom} & {pm} & {nom} & {pm} & {nom} & {pm} \\ -\midrule -\multirow[c]{2}{*}{Option Type} & C & 65.512657 & 5.750000 & 71.752108 & 6.660000 & 74.326804 & 9.230000 \\ - & P & 66.606767 & 5.480000 & 72.306912 & 5.900000 & 74.451890 & 8.040000 \\ -\cline{1-8} -\multirow[c]{3}{*}{Security Type} & Index option & 60.309635 & 6.990000 & 67.469911 & 1.730000 & 72.346139 & 6.600000 \\ - & Others & 69.039887 & 4.770000 & 74.160293 & 6.100000 & 75.569654 & 7.510000 \\ - & Stock option & 65.318447 & 5.850000 & 71.559532 & 6.850000 & 74.093552 & 9.390000 \\ -\cline{1-8} -\multirow[c]{5}{*}{Trade Size} & (0,1] & 62.838447 & 6.180000 & 70.814533 & 7.560000 & 73.435935 & 10.180000 \\ - & (1,3] & 64.907873 & 5.570000 & 71.349116 & 7.160000 & 73.647650 & 9.460000 \\ - & (3,5] & 65.530185 & 5.450000 & 72.022665 & 6.570000 & 74.190970 & 8.730000 \\ - & (5,11] & 66.584846 & 5.600000 & 71.632683 & 6.160000 & 74.157743 & 8.680000 \\ - & >11 & 71.162306 & 5.110000 & 74.596742 & 3.730000 & 76.754620 & 5.890000 \\ -\cline{1-8} -\multirow[c]{3}{*}{Year} & 2015 & 65.686244 & 4.830000 & 71.517005 & 7.420000 & 74.244782 & 10.150000 \\ - & 2016 & 65.599281 & 5.760000 & 71.689210 & 7.340000 & 74.197954 & 9.850000 \\ - & 2017 & 66.489807 & 5.590000 & 72.401584 & 5.070000 & 74.599385 & 7.270000 \\ -\cline{1-8} -\multirow[c]{6}{*}{Time to Maturity} & <= 1 & 66.871548 & 5.370000 & 72.041871 & 6.060000 & 74.239008 & 8.260000 \\ - & (1-2] & 67.586737 & 5.930000 & 72.695265 & 6.100000 & 75.288671 & 8.690000 \\ - & (2-3] & 66.036792 & 6.040000 & 72.431363 & 6.020000 & 74.814515 & 8.400000 \\ - & (3-6] & 65.029245 & 6.270000 & 72.896311 & 7.060000 & 75.145620 & 9.310000 \\ - & (6-12] & 64.199075 & 5.890000 & 71.966191 & 6.930000 & 74.428193 & 9.390000 \\ - & > 12 & 56.015639 & 5.560000 & 66.891540 & 7.670000 & 71.214760 & 12.000000 \\ -\cline{1-8} -\multirow[c]{5}{*}{Moneyness} & <= 0.7 & 65.757089 & 5.770000 & 73.047039 & 5.030000 & 75.613996 & 7.590000 \\ - & (0.7-0.9] & 66.286506 & 5.860000 & 72.245056 & 6.040000 & 74.703549 & 8.500000 \\ - & (0.9-1.1] & 66.989236 & 5.580000 & 72.658136 & 6.300000 & 74.765376 & 8.410000 \\ - & (1.1-1.3] & 58.149819 & 5.170000 & 66.258707 & 7.770000 & 69.844057 & 11.350000 \\ - & > 1.3 & 56.912370 & 6.090000 & 64.579940 & 7.230000 & 70.634098 & 13.280000 \\ -\cline{1-8} -\multirow[c]{5}{*}{Location to Quote} & at mid & 61.013630 & 6.750000 & 67.961360 & 8.610000 & 69.818239 & 10.460000 \\ - & inside & 68.837832 & 3.590000 & 72.024322 & 6.710000 & 73.714183 & 8.400000 \\ - & at quotes & 54.152059 & 16.000000 & 74.856559 & 2.510000 & 81.415458 & 9.070000 \\ - & outside & 70.802418 & -2.820000 & 70.149766 & -1.770000 & 70.644408 & -1.280000 \\ - & unknown & 83.626840 & 1.070000 & 83.392035 & 0.720000 & 83.997110 & 1.330000 \\ -\cline{1-8} -All trades & all & 66.010410 & 5.630000 & 72.004510 & 6.310000 & 74.383710 & 8.690000 \\ -\cline{1-8} -\bottomrule -\end{tabular} -\end{table} diff --git a/reports/Content/diff-ise_supervised_test.tex b/reports/Content/diff-ise_supervised_test.tex deleted file mode 100644 index c56238b4..00000000 --- a/reports/Content/diff-ise_supervised_test.tex +++ /dev/null @@ -1,50 +0,0 @@ -\begin{table} -\centering -\caption[short-diff-ise_supervised_test]{long-diff-ise_supervised_test} -\label{tab:diff-ise_supervised_test} -\begin{tabular}{llSSSSSS} -\toprule -{} & {} & \multicolumn{2}{r}{gbm(classical)} & \multicolumn{2}{r}{gbm(classical-size)} & \multicolumn{2}{r}{gbm(ml)} \\ -{} & {} & {nom} & {pm} & {nom} & {pm} & {nom} & {pm} \\ -\midrule -\multirow[c]{2}{*}{Option Type} & C & 62.889592 & 4.010000 & 71.895259 & 4.900000 & 73.624730 & 6.630000 \\ - & P & 64.544991 & 3.770000 & 72.892594 & 5.450000 & 74.593715 & 7.150000 \\ -\cline{1-8} -\multirow[c]{3}{*}{Security Type} & Index option & 56.308184 & -1.490000 & 57.640799 & -0.880000 & 58.100126 & -0.420000 \\ - & Others & 68.405530 & 3.160000 & 76.385942 & 6.250000 & 77.551217 & 7.410000 \\ - & Stock option & 61.866828 & 4.280000 & 70.962294 & 4.810000 & 72.919301 & 6.770000 \\ -\cline{1-8} -\multirow[c]{5}{*}{Trade Size} & (0,1] & 61.886324 & 3.670000 & 72.589837 & 3.810000 & 74.242395 & 5.460000 \\ - & (1,3] & 62.455088 & 4.280000 & 73.006333 & 4.160000 & 74.813673 & 5.970000 \\ - & (3,5] & 62.683294 & 4.200000 & 72.766890 & 3.810000 & 74.557255 & 5.600000 \\ - & (5,11] & 65.941513 & 3.650000 & 71.771961 & 8.480000 & 73.383853 & 10.090000 \\ - & >11 & 67.305363 & 3.880000 & 71.307368 & 6.760000 & 73.084679 & 8.540000 \\ -\cline{1-8} -\multirow[c]{3}{*}{Year} & 2015 & 60.396806 & 4.250000 & 69.028053 & 5.680000 & 71.423694 & 8.070000 \\ - & 2016 & 63.737864 & 3.840000 & 72.560975 & 5.440000 & 74.235176 & 7.120000 \\ - & 2017 & 64.587031 & 3.910000 & 73.018742 & 4.320000 & 74.603733 & 5.900000 \\ -\cline{1-8} -\multirow[c]{6}{*}{Time to Maturity} & <= 1 & 64.456091 & 3.880000 & 72.770627 & 5.660000 & 74.560803 & 7.450000 \\ - & (1-2] & 64.596545 & 4.050000 & 72.885430 & 4.770000 & 73.865438 & 5.750000 \\ - & (2-3] & 62.979868 & 3.260000 & 71.797757 & 3.910000 & 72.946987 & 5.060000 \\ - & (3-6] & 61.803170 & 3.930000 & 71.302394 & 3.850000 & 72.719581 & 5.270000 \\ - & (6-12] & 61.849926 & 4.170000 & 71.222635 & 3.750000 & 73.093080 & 5.620000 \\ - & > 12 & 55.148148 & 4.210000 & 68.602077 & 3.900000 & 72.039005 & 7.330000 \\ -\cline{1-8} -\multirow[c]{5}{*}{Moneyness} & <= 0.7 & 65.551797 & 4.100000 & 71.843131 & 7.730000 & 72.438812 & 8.330000 \\ - & (0.7-0.9] & 67.636359 & 4.000000 & 74.290189 & 6.420000 & 75.357081 & 7.490000 \\ - & (0.9-1.1] & 64.063302 & 3.830000 & 72.990099 & 4.840000 & 74.414466 & 6.260000 \\ - & (1.1-1.3] & 54.203956 & 4.180000 & 66.292506 & 4.630000 & 70.268926 & 8.610000 \\ - & > 1.3 & 52.572955 & 3.850000 & 63.007743 & 3.030000 & 70.550826 & 10.580000 \\ -\cline{1-8} -\multirow[c]{5}{*}{Location to Quote} & at mid & 62.620494 & 6.670000 & 72.155374 & 6.250000 & 74.659713 & 8.760000 \\ - & inside & 62.608299 & 2.400000 & 68.336275 & 4.090000 & 70.249568 & 6.010000 \\ - & at quotes & 67.805369 & 7.840000 & 86.648398 & 8.440000 & 87.273077 & 9.060000 \\ - & outside & 60.497886 & -6.110000 & 60.377105 & -4.520000 & 63.067839 & -1.830000 \\ - & unknown & 78.583647 & 2.240000 & 78.371536 & 1.930000 & 79.131030 & 2.690000 \\ -\cline{1-8} -All trades & all & 63.662370 & 3.900000 & 72.360838 & 5.160000 & 74.077074 & 6.870000 \\ -\cline{1-8} -\bottomrule -\end{tabular} -\end{table} diff --git a/reports/Content/effective-spread.tex b/reports/Content/effective-spread.tex index bb3cafcb..542e0182 100644 --- a/reports/Content/effective-spread.tex +++ b/reports/Content/effective-spread.tex @@ -1,28 +1,27 @@ \begin{threeparttable} \begin{tabular}{@{}lSSSS@{}} - {} & \multicolumn{2}{l}{\textbf{Panel A:} \gls{ISE} Dataset} & \multicolumn{2}{l}{\textbf{Panel B:} \gls{CBOE} Dataset} \\ \toprule - {} & {Eff. Spread} & {Eff. Spread} & {Eff. Spread} & {Eff. Spread} \\ - {} & {(in \$)} & {(in \%)} & {(in \$)} & {(in \%)} \\ \midrule - Tick Test & 1.556755 & 1.073441 \tnote{*} & 1.398457 & 2.286679 \tnote{*} \\ - Quote Rule & 16.333263 & 16.207394 \tnote{*} & 12.538848 & 14.209334 \tnote{*} \\ - \gls{LR} Algorithm & 16.333263 & 16.207394 \tnote{*} & 12.538848 & 14.209334 \tnote{*} \\ - \gls{EMO} Rule & 4.646510 & 8.443125 \tnote{*} & 4.086547 & 7.418858 \tnote{*} \\ - \gls{CLNV} Method & 11.625950 & 13.283967 \tnote{*} & 8.673450 & 11.051837 \tnote{*} \\ - \gls{GSU} Method & 1.415065 & 4.292678 \tnote{*} & 5.204582 & 7.027343 \tnote{*} \\ \midrule - \gls{GBRT} (FS1) & 7.413810 & 9.185910 \tnote{*} & 6.107553 & 9.557821 \tnote{*} \\ - \gls{GBRT} (FS2) & 4.247477 & 6.982754 \tnote{*} & 3.640036 & 7.152729 \tnote{*} \\ - \gls{GBRT} (FS3) & 3.740719 & 6.512824 \tnote{*} & 3.470571 & 6.688818 \tnote{*} \\ - FT-Transformer (FS1) & & \tnote{*} & & \tnote{*} \\ - FT-Transformer (FS2) & & \tnote{*} & & \tnote{*} \\ - FT-Transformer (FS3) & & \tnote{*} & & \tnote{*} \\ \midrule - \gls{GBRT} (FS1) & & \tnote{*} & & \tnote{*} \\ - \gls{GBRT} (FS2) & & \tnote{*} & & \tnote{*} \\ - \gls{GBRT} (FS3) & & \tnote{*} & & \tnote{*} \\ - FT-Transformer (FS1) & & \tnote{*} & & \tnote{*} \\ - FT-Transformer (FS2) & & \tnote{*} & & \tnote{*} \\ - FT-Transformer (FS3) & & \tnote{*} & & \tnote{*} \\ \midrule - True Effective Spread & 0.492556 & 3.715891 & 1.221870 & 2.512159 \\ \bottomrule + {} & \multicolumn{2}{c}{Effective Spread at \gls{ISE}} & \multicolumn{2}{c}{Effective Spread at \gls{CBOE}} \\ \cmidrule(lr){2-3}\cmidrule(lr){4-5} + {Classifier} & {in \$} & {in \%} & {in \$} & {in \%} \\ \midrule + $\operatorname{tick}_{\mathrm{ex}}$ & 99.99 & 99.99 \tnote{*} & 99.99 & 99.99 \tnote{*} \\ + $\operatorname{quote}_{\mathrm{ex}}$ & & \tnote{*} & & \tnote{*} \\ + $\operatorname{lr}_{\mathrm{ex}}$ & & \tnote{*} & & \tnote{*} \\ + $\operatorname{emo}_{\mathrm{ex}}$ & & \tnote{*} & & \tnote{*} \\ + $\operatorname{clnv}_{\mathrm{ex}}$ & & \tnote{*} & & \tnote{*} \\ + $\operatorname{gsu}$ & & \tnote{*} & & \tnote{*} \\ \midrule + \gls{GBRT} (FS1) & & \tnote{*} & & \tnote{*} \\ + \gls{GBRT} (FS2) & & \tnote{*} & & \tnote{*} \\ + \gls{GBRT} (FS3) & & \tnote{*} & & \tnote{*} \\ + FT-Transformer (FS1) & & \tnote{*} & & \tnote{*} \\ + FT-Transformer (FS2) & & \tnote{*} & & \tnote{*} \\ + FT-Transformer (FS3) & & \tnote{*} & & \tnote{*} \\ \midrule + \gls{GBRT} (Semi) (FS1) & & \tnote{*} & & \tnote{*} \\ + \gls{GBRT} (Semi) (FS2) & & \tnote{*} & & \tnote{*} \\ + \gls{GBRT} (Semi) (FS3) & & \tnote{*} & & \tnote{*} \\ + FT-Transformer (Semi) (FS1) & & \tnote{*} & & \tnote{*} \\ + FT-Transformer (Semi) (FS2) & & \tnote{*} & & \tnote{*} \\ + FT-Transformer (Semi) (FS3) & & \tnote{*} & & \tnote{*} \\ \midrule + True Effective Spread & 0.492556 & 3.715891 & 1.221870 & 2.512159 \\ \bottomrule %Quoted Spread & & \\ \midrule \end{tabular} \begin{tablenotes}\footnotesize diff --git a/reports/Content/results.tex b/reports/Content/results.tex index 63ea2068..16a54979 100644 --- a/reports/Content/results.tex +++ b/reports/Content/results.tex @@ -1,52 +1,106 @@ \section{Results}\label{sec:results} +This chapter compares the results of rule-based trade classification with machine learning-based classification. The results suggest a supremacy of machine learning-based classifiers. + \subsection{Results of Rule-Based Approaches}\label{sec:result-of-rule-based-approaches} -\gls{ISE} -\begin{table}[H] +We now estimate the accuracy of classical trade classification rules on the \gls{ISE} and \gls{CBOE} sample. We consider the tick and quote rule, as well as the \gls{LR} algorithm, \gls{EMO} rule and \gls{CLNV} method in their classical and reversed formulation. Additionally, we consider two stacked combinations of \textcite[][12--14]{grauerOptionTradeClassification2022} due to their state-of-the-art performance on the validation set, as derived in \cref{sec:hyperparameter-tuning}. Namely, $\operatorname{quote}_{\mathrm{nbbo}} \to \operatorname{quote}_{\mathrm{ex}} \to \operatorname{rtick}_{\mathrm{all}}$ and $\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}}$ or in short $\operatorname{gsu}_{\mathrm{small}}$ and $\operatorname{gsu}_{\mathrm{large}}$. + +We report in \cref{tab:ise_supervised_all-master} accuracies for the entire data set and separate subsets spanning the periods of train, validation, and test set as defined in \cref{sec:train-test-split}. Doing so enables comparisons with previous works, but also provides meaningful estimates on the test set relevant for benchmarking purposes. + +Our results are approximately similar to \textcite[][29--33]{grauerOptionTradeClassification2022}. Minor deviations exist, which can be pinned down to differences in handling of unclassified trades and non-positive spreads, as well as divergent implementations of the depth rule.\footnote{Correspondence with the author.} + +From all rules, the tick rule performs worst when applied to trade prices at the trading venue with accuracies of a random guess, \SI{49.67}{\percent}. For comparison, a simple majority vote achieves \SI{51.40}{\percent} accuracy. The tick test performs best when estimated on the consecutive trade prices, and additionally, when estimated at the inter-exchange level marginally improves over a random classification, achieving accuracies of \SI{55.25}{\percent} for the reversed tick test. Due to the poor performance, of tick-based algorithms at the exchange level, we estimate all hybrids with $\operatorname{tick}_{\mathrm{all}}$ or $\operatorname{rtick}_{\mathrm{all}}$. + +\begin{table}[ht] \centering - \caption[tbd]{tbd ise} + \caption[Accuracies of Rule-Based Approaches On \glsentryshort{ISE}]{This table shows the accuracy of common trade classification rules and their variations for option trades on \gls{ISE} sample. Unclassifiable trades by the respective rule are assigned randomly as buy or sell. Hybrid methods are estimated using trade prices across all exchanges. We report the percentage of classifiable trades and the overall accuracy for subsets based on our train-test split and the entire dataset. Best rule in \textbf{bold}.} \label{tab:ise_supervised_all-master} - \begin{tabular}{@{}p{5.7cm}SSSSS@{}} + \begin{tabular}{@{}lSSSSS@{}} \toprule - {} & {Coverage in \%} & \multicolumn{4}{c}{Accuracy in \%} \\ \cmidrule(lr){2-2} \cmidrule(lr){3-6} - {Trade Classification Rule} & {All} & {Train} & {Val} & {Test} & {All} \\\midrule - % {Trade Classification Rule} & {\makecell{{\gls{ISE} Train} \\ {10/05 -- 10/13}}} & {\makecell{{\gls{ISE} Val}\\{10/13 -- 11/15}}} & {\makecell{{\gls{ISE} Test}\\{11/15 -- 5/17}}} & {All} \\\midrule - $\operatorname{tick}_{\mathrm{all}}$ & 97.8500 & 52.8954 & 54.5403 & 53.3412 & 53.3134 \\ - $\operatorname{rtick}_{\mathrm{all}}$ & 96.7000 & 55.9539 & 54.4020 & 53.9891 & 55.2500 \\ \midrule - $\operatorname{tick}_{\mathrm{ex}}$ & 91.5800 & 49.1842 & 50.5441 & 50.2394 & 49.6674 \\ - $\operatorname{rtick}_{\mathrm{ex}}$ & 90.3500 & 52.1701 & 50.3068 & 50.5258 & 51.4682 \\ - $\operatorname{quote}_{\mathrm{ex}}$ & 94.6900 & 66.2659 & 57.5174 & 56.9997 & 62.6606 \\ - $\operatorname{lr}_{\mathrm{ex}}$ & 99.8800 & 66.1320 & 57.5550 & 57.0623 & 62.6004 \\ - $\operatorname{rlr}_{\mathrm{ex}}$ & 99.7200 & 66.3858 & 57.6456 & 57.1372 & 62.7857 \\ - $\operatorname{emo}_{\mathrm{ex}}$ & 98.7300 & 56.5416 & 53.7133 & 53.7864 & 55.4243 \\ - $\operatorname{remo}_{\mathrm{ex}}$ & 98.9500 & 57.1490 & 53.6360 & 54.1495 & 55.8459 \\ - $\operatorname{clnv}_{\mathrm{ex}}$ & 98.7000 & 60.1181 & 55.2305 & 54.7502 & 58.0656 \\ - $\operatorname{rclnv}_{\mathrm{ex}}$ & 95.0000 & 60.8498 & 55.3888 & 55.0784 & 58.6019 \\ \midrule - $\operatorname{quote}_{\mathrm{nbbo}}$ & 99.8900 & 66.8153 & 58.5520 & 59.5565 & 63.7093 \\ - $\operatorname{lr}_{\mathrm{nbbo}}$ & 99.7900 & 66.6404 & 58.5902 & 59.6145 & 63.6236 \\ - $\operatorname{rlr}_{\mathrm{nbbo}}$ & 98.7200 & 66.8250 & 58.6446 & 59.6458 & 63.7515 \\ - $\operatorname{emo}_{\mathrm{nbbo}}$ & 98.3900 & 58.2850 & 54.8106 & 55.9278 & 57.1183 \\ - $\operatorname{remo}_{\mathrm{nbbo}}$ & 98.9000 & 58.9415 & 54.8198 & 56.2168 & 57.5718 \\ - $\operatorname{clnv}_{\mathrm{nbbo}}$ & 98.9000 & 61.5439 & 56.3371 & 57.0753 & 59.6079 \\ - $\operatorname{rclnv}_{\mathrm{nbbo}}$ & 98.7000 & 62.2628 & 56.5928 & 57.4307 & 60.1614 \\ \midrule - $\operatorname{quote}_{\mathrm{nbbo}} \to \operatorname{quote}_{\mathrm{ex}} \to \operatorname{rtick}_{\mathrm{all}}$ & 99.8400 & 66.7098 & 58.7642 & 59.8383 & 63.7449 \\ - $\operatorname{gsu}$ & \bfseries 100.000 & \bfseries 79.7126 & \bfseries 68.8358 & \bfseries 67.2039 & \bfseries 75.0322 \\ + {} & {Coverage in \%} & \multicolumn{4}{c}{Accuracy in \%} \\ \cmidrule(lr){2-2} \cmidrule(lr){3-6} + {Trade Classification Rule} & {All} & {Train} & {Val} & {Test} & {All} \\\midrule + $\operatorname{tick}_{\mathrm{ex}}$ & 91.5800 & 49.1842 & 50.5441 & 50.2394 & 49.6674 \\ + $\operatorname{rtick}_{\mathrm{ex}}$ & 90.3500 & 52.1701 & 50.3068 & 50.5258 & 51.4682 \\ + $\operatorname{quote}_{\mathrm{ex}}$ & 94.6900 & 66.2659 & 57.5174 & 56.9997 & 62.6606 \\ + $\operatorname{lr}_{\mathrm{ex}}$ & 99.8800 & 66.1320 & 57.5550 & 57.0623 & 62.6004 \\ + $\operatorname{rlr}_{\mathrm{ex}}$ & 99.7200 & 66.3858 & 57.6456 & 57.1372 & 62.7857 \\ + $\operatorname{emo}_{\mathrm{ex}}$ & 98.7300 & 56.5416 & 53.7133 & 53.7864 & 55.4243 \\ + $\operatorname{remo}_{\mathrm{ex}}$ & 98.9500 & 57.1490 & 53.6360 & 54.1495 & 55.8459 \\ + $\operatorname{clnv}_{\mathrm{ex}}$ & 98.7000 & 60.1181 & 55.2305 & 54.7502 & 58.0656 \\ + $\operatorname{rclnv}_{\mathrm{ex}}$ & 95.0000 & 60.8498 & 55.3888 & 55.0784 & 58.6019 \\ \midrule + $\operatorname{tick}_{\mathrm{all}}$ & 97.8500 & 52.8954 & 54.5403 & 53.3412 & 53.3134 \\ + $\operatorname{rtick}_{\mathrm{all}}$ & 96.7000 & 55.9539 & 54.4020 & 53.9891 & 55.2500 \\ \midrule + $\operatorname{quote}_{\mathrm{nbbo}}$ & 99.8900 & 66.8153 & 58.5520 & 59.5565 & 63.7093 \\ + $\operatorname{lr}_{\mathrm{nbbo}}$ & 99.7900 & 66.6404 & 58.5902 & 59.6145 & 63.6236 \\ + $\operatorname{rlr}_{\mathrm{nbbo}}$ & 98.7200 & 66.8250 & 58.6446 & 59.6458 & 63.7515 \\ + $\operatorname{emo}_{\mathrm{nbbo}}$ & 98.3900 & 58.2850 & 54.8106 & 55.9278 & 57.1183 \\ + $\operatorname{remo}_{\mathrm{nbbo}}$ & 98.9000 & 58.9415 & 54.8198 & 56.2168 & 57.5718 \\ + $\operatorname{clnv}_{\mathrm{nbbo}}$ & 98.9000 & 61.5439 & 56.3371 & 57.0753 & 59.6079 \\ + $\operatorname{rclnv}_{\mathrm{nbbo}}$ & 98.7000 & 62.2628 & 56.5928 & 57.4307 & 60.1614 \\ \midrule + $\operatorname{gsu}_{\mathrm{small}}$ & 99.8400 & 66.7098 & 58.7642 & 59.8383 & 63.7449 \\ + $\operatorname{gsu}_{\mathrm{large}}$ & \bfseries 100.000 & \bfseries 79.7126 & \bfseries 68.8358 & \bfseries 67.2039 & \bfseries 75.0322 \\ \bottomrule \end{tabular} \end{table} -\todo{Add results of classical rules over entire data set and test set.} +\todo{How can the coverage of the gsu method be smaller than quote nbbo alone?} + +Quote-based algorithms outperform tick-based algorithms delivering accuracy up to \SI{63.71}{\percent}, when estimated on the \gls{NBBO}. The superiority of quote-based algorithms in option trade classification has previously been documented in \textcites{savickasInferringDirectionOption2003}{grauerOptionTradeClassification2022}. + +The performance of hybrids, such as the \gls{LR} algorithm, hinges on the reliance on the tick test. Thus, the \gls{EMO} rules and to a lesser extent the \gls{CLNV} rules perform worst, achieving accuracies between \SI{55.42}{\percent} and \SI{57.57}{\percent}. In turn, variants of the \gls{LR}, which uses the quote rule for most trades, are among the best-performing algorithms. By extension, $\operatorname{gsu}_{\mathrm{small}}$ further reduces the dependence on tick-based methods through the successive applications of quote rules, here $\operatorname{quote}_{\mathrm{nbbo}} \to \operatorname{quote}_{\mathrm{ex}}$. -\todo{Add table with table with performance on set before test, test set} +Notably, $\operatorname{gsu}_{\mathrm{large}}$, the combination of \textcite[][33]{grauerOptionTradeClassification2022} including overrides from the trade size and depth rules performs best, achieving \SI{67.20}{\percent} accuracy on the \gls{ISE} test set and \SI{75.03}{\percent} on the entire dataset. Yet, the performance deteriorates most sharply between sets, as visualised in \cref{fig:classical-accuracies-over-time}. -\todo{Similar to Grinzsjastin Enumerate findings. Finding 1 (Trades at the quotes + incentives for limit orders. Go through archive.org and pin down fees and mark changes in fee structures) Finding 2 (missingness as key driver to performance). Plot missing trade prices and quotes over time.} +\begin{figure}[ht] + \centering + \includegraphics{classical-accuracies-over-time.pdf} + \caption[Accuracy Of Rule-Based Classifiers On \glsentryshort{ISE} and \glsentryshort{CBOE} Over Time]{Accuracy of rule-based classifiers on \gls{ISE} and \gls{CBOE} sample over time. The dashed bar \myline{} indicates the beginning of a new subset based on the train-test split.} + \label{fig:classical-accuracies-over-time} +\end{figure} + +Aside from these high-level observations, we focus on three findings in greater detail. -\todo{Do separately for CBOE and ISE.} +\textbf{Finding 1: Accuracy of Tick-Based Algorithms Is Downward-Biased by Missingness} -\todo{Add bar below line plot to indicate beginning and end of test set.} +\textbf{Finding 2: Accuracy Comes From Depth} -\todo{Facated view. Decompose stacked rules into subrules look, how they change over time} +\textbf{Finding 3: Fee Structures Affect Accuracy Over Time} + +\begin{table}[ht] + \centering + \caption[Accuracies of Rule-Based Approaches On \glsentryshort{CBOE}]{This table shows the accuracy of common trade classification rules and their variations for option trades on \gls{CBOE} sample. Unclassifiable trades by the respective rule are assigned randomly as buy or sell. Hybrid methods are estimated using trade prices across all exchanges. We report the percentage of classifiable trades and the overall accuracy for subsets based on our train-test split and the entire dataset. Best rule in \textbf{bold}.} + \label{tab:cboe_supervised_all-master-cboe} + \begin{tabular}{lSSSS} + \toprule + {} & {Coverage in \%} & \multicolumn{3}{c}{Accuracy in \%} \\ \cmidrule(lr){2-2}\cmidrule(lr){3-5} + {Trade Classification Rule} & {All} & {Pre-Test} & {Test} & {All} \\\midrule + $\operatorname{tick}_{\mathrm{ex}}$ & 91.450 & 48.6156 & 48.9969 & 48.7469 \\ + $\operatorname{rtick}_{\mathrm{ex}}$ & 90.280 & 51.0857 & 50.5432 & 50.8989 \\ + $\operatorname{quote}_{\mathrm{ex}}$ & 94.460 & 62.6691 & 62.0558 & 62.4580 \\ + $\operatorname{lr}_{\mathrm{ex}}$ & 99.850 & 62.4250 & 61.7483 & 62.1921 \\ + $\operatorname{rlr}_{\mathrm{ex}}$ & 99.530 & 62.7111 & 62.0071 & 62.4687 \\ + $\operatorname{emo}_{\mathrm{ex}}$ & 97.960 & 49.3923 & 48.6489 & 49.1364 \\ + $\operatorname{remo}_{\mathrm{ex}}$ & 97.320 & 49.8883 & 49.9529 & 49.9105 \\ + $\operatorname{clnv}_{\mathrm{ex}}$ & 98.440 & 54.2644 & 53.2492 & 53.9149 \\ + $\operatorname{rclnv}_{\mathrm{ex}}$ & 94.040 & 55.1506 & 54.5686 & 54.9502 \\\midrule + $\operatorname{tick}_{\mathrm{all}}$ & 97.210 & 51.4199 & 50.4403 & 51.0827 \\ + $\operatorname{rtick}_{\mathrm{all}}$ & 96.030 & 54.2521 & 52.7056 & 53.7197 \\ \midrule + $\operatorname{quote}_{\mathrm{nbbo}}$ & 94.770 & 61.3146 & 59.7952 & 60.7915 \\ + $\operatorname{lr}_{\mathrm{nbbo}}$ & 99.870 & 61.0947 & 59.5427 & 60.5604 \\ + $\operatorname{rlr}_{\mathrm{nbbo}}$ & 99.710 & 61.2959 & 59.7516 & 60.7643 \\ + $\operatorname{emo}_{\mathrm{nbbo}}$ & 98.120 & 51.6420 & 51.6299 & 51.6378 \\ + $\operatorname{remo}_{\mathrm{nbbo}}$ & 97.780 & 52.4847 & 53.0735 & 52.6874 \\ + $\operatorname{clnv}_{\mathrm{nbbo}}$ & 98.540 & 55.3058 & 54.1294 & 54.9008 \\ + $\operatorname{rclnv}_{\mathrm{nbbo}}$ & 98.350 & 56.3217 & 55.4032 & 56.0055 \\\midrule + $\operatorname{gsu}_{\mathrm{small}}$ & 99.780 & 61.6223 & 60.3459 & 61.1829 \\ + $\operatorname{gsu}_{\mathrm{large}}$ & \bfseries 100.000 & \bfseries 73.8949 & \bfseries 65.6943 & \bfseries 71.0717 \\\bottomrule + \end{tabular} +\end{table} + +We repeat the analysis on the \gls{CBOE} dataset in \cref{tab:cboe_supervised_all-master-cboe} and observe a similar ranking to \cref{tab:ise_supervised_all-master}. Overall, the performance of classical trade classification rules further diminishes strengthening the need for alternative classifiers. Tick-based rules trail the performance of quote-based approaches, and the accuracy of hybrids varies with the dependence on the tick test. Different from the \gls{ISE} sample, the quote rule estimated on the \gls{NBBO}, $\operatorname{quote}_{\mathrm{nbbo}}$, leads to a lower performance than the quote rule applied to \gls{CBOE} quotes. Parts of this is due to the fact, that $\operatorname{quote}_{\mathrm{nbbo}}$ achieves a considerably lower coverage of \SI{94.77}{\percent} compared to \SI{99.89}{\percent} in the \gls{ISE} sample, with fewer trades classified by the fallback criterion. In a filtered common sample, where trades are classified by both rules, performance is approximately similar. Again, $\operatorname{gsu}_{\mathrm{small}}$ and $\operatorname{gsu}_{\mathrm{large}}$ perform best, the strong outperformance does not carry over to the test set \cref{fig:classical-accuracies-over-time}.\footnote{Performance on \gls{CBOE} can be improved if the order of quote rules is reversed. For full combinatoric coverage see \textcite[][33]{grauerOptionTradeClassification2022}. To avoid overfitting the test set by classical rules, we keep the baseline constant following our reasoning from \cref{sec:hyperparameter-tuning}.} + +\todo{Doesn't this contradict the hidden order idea of Grauer?} \begin{table}[H] \centering @@ -89,66 +143,7 @@ \subsection{Results of Rule-Based Approaches}\label{sec:result-of-rule-based-app \subsection{Results of Supervised Models}\label{sec:results-of-supervised-models} -% \begin{table} -% \centering -% \caption[master-short]{master-long} -% \label{tab:cboe_transfer_test-master-classical} -% \begin{tabular}{lSSSSSSS} -% \toprule -% {} & {Tick (Ex)} & {Quote (Ex)} & {\gls{LR} (Ex)} & {\gls{EMO} (Ex)} & {\gls{CLNV} (Ex)} & {Quote (Best) $\to$ Quote (Ex)} & {\gls{GSU}} \\ -% \midrule -% \multicolumn{1}{l}{Option Type} \\ -% \tabindent C & 48.6386 & 61.8605 & 61.5274 & 48.5108 & 53.1980 & 59.7593 & \bfseries 65.0963 \\ -% \tabindent P & 49.4365 & 62.2855 & 62.0100 & 48.8053 & 53.2937 & 61.1276 & \bfseries 66.4105 \\ -% \cmidrule{1-7} -% \multicolumn{1}{l}{Security Type} \\ -% \tabindent Index Option & 48.1625 & 53.8752 & 53.6416 & 42.0030 & 43.5518 & 53.3387 & \bfseries 65.7456 \\ -% \tabindent Others & 48.7365 & 66.0832 & 65.6695 & 50.2498 & 55.1471 & 64.2657 & \bfseries 68.0604 \\ -% \tabindent Stock Option & 49.1950 & 61.1928 & 60.9229 & 48.6376 & 53.4123 & 59.4683 & \bfseries 64.7064 \\ -% \cmidrule{1-7} -% \multicolumn{1}{l}{Trade Size} \\ -% \tabindent (0,1] & 48.8039 & 58.8373 & 58.6298 & 46.8828 & 50.7216 & 56.6566 & \bfseries 63.2595 \\ -% \tabindent (1,3] & 48.9448 & 62.0334 & 61.7327 & 48.5434 & 52.8834 & 59.3317 & \bfseries 64.1855 \\ -% \tabindent (3,5] & 48.7100 & 62.4241 & 62.1303 & 48.9953 & 53.4790 & 60.0877 & \bfseries 65.4561 \\ -% \tabindent (5,11] & 48.8370 & 62.7963 & 62.4460 & 48.7128 & 53.6204 & 60.9859 & \bfseries 65.4738 \\ -% \tabindent >11 & 49.6791 & 65.3706 & 64.9572 & 50.7667 & 56.4256 & 66.0498 & \bfseries 70.8678 \\ -% \cmidrule{1-7} -% \multicolumn{1}{l}{Year} \\ -% \tabindent 2015 & 48.7962 & 63.9554 & 63.5456 & 49.6553 & 54.2843 & 60.8559 & \bfseries 64.0997 \\ -% \tabindent 2016 & 48.8950 & 62.8512 & 62.5217 & 48.9013 & 53.4273 & 59.8428 & \bfseries 64.3460 \\ -% \tabindent 2017 & 49.1409 & 60.9673 & 60.6973 & 48.2461 & 52.9145 & 60.8995 & \bfseries 67.3316 \\ -% \cmidrule{1-7} -% \multicolumn{1}{l}{Time To Maturity} \\ -% \tabindent <= 1 & 48.9681 & 62.8632 & 62.4864 & 49.3758 & 53.8885 & 61.5021 & \bfseries 65.9826 \\ -% \tabindent (1-2] & 49.7662 & 62.8410 & 62.6221 & 49.5022 & 54.0575 & 61.6563 & \bfseries 66.5978 \\ -% \tabindent (2-3] & 48.9832 & 61.8603 & 61.6079 & 47.6567 & 52.6264 & 60.0202 & \bfseries 66.4157 \\ -% \tabindent (3-6] & 48.7972 & 61.1299 & 60.8658 & 47.1231 & 52.1967 & 58.7646 & \bfseries 65.8335 \\ -% \tabindent (6-12] & 48.6674 & 60.6878 & 60.5440 & 46.9392 & 51.9522 & 58.3030 & \bfseries 65.0348 \\ -% \tabindent > 12 & 48.4385 & 54.3230 & 54.2450 & 44.8763 & 48.2958 & 50.4561 & \bfseries 59.2183 \\ -% \cmidrule{1-7} -% \multicolumn{1}{l}{Moneyness} \\ -% \tabindent <= 0.7 & 49.7225 & 56.2652 & 55.9378 & 47.7972 & 50.8738 & 59.9979 & \bfseries 68.0207 \\ -% \tabindent (0.7-0.9] & 48.3985 & 60.7275 & 60.3139 & 48.0956 & 52.0827 & 60.4261 & \bfseries 66.2027 \\ -% \tabindent (0.9-1.1] & 49.2799 & 63.6517 & 63.3631 & 49.1110 & 54.1991 & 61.4061 & \bfseries 66.3599 \\ -% \tabindent (1.1-1.3] & 47.8749 & 55.8400 & 55.6525 & 46.9308 & 49.9467 & 52.9996 & \bfseries 58.4909 \\ -% \tabindent > 1.3 & 47.4849 & 53.7090 & 53.4551 & 45.6819 & 47.9778 & 50.8283 & \bfseries 57.3531 \\ -% \cmidrule{1-7} -% \multicolumn{1}{l}{Proximity} \\ -% \tabindent At Mid & 45.3192 & 49.9209 & 46.9842 & 45.3807 & 45.3882 & 54.2637 & \bfseries 59.3570 \\ -% \tabindent Inside & 49.5803 & \bfseries 68.0898 & \bfseries 68.0898 & 50.9957 & 57.0791 & 65.2444 & 65.3122 \\ -% \tabindent At Quotes & 48.5476 & 38.1581 & 38.1335 & 38.1632 & 38.1332 & 38.1500 & \bfseries 72.3496 \\ -% \tabindent Outside & 53.0434 & 70.6581 & 69.6276 & 56.8013 & 56.8013 & \bfseries 73.5023 & 71.9222 \\ -% \tabindent Unknown & 50.3116 & 49.6433 & 50.9347 & 50.9979 & 51.0611 & \bfseries 82.7689 & 82.6876 \\ -% \cmidrule{1-7} -% \multicolumn{1}{l}{All Trades} \\ -% \tabindent All & 49.0016 & 62.0538 & 61.7470 & 48.6448 & 53.2415 & 60.3818 & \bfseries 65.6942 \\ -% \bottomrule -% \end{tabular} -% \end{table} - -\textbf{Gradient Boosting} - -\textbf{FT-Transformer} +Our models establish a new state-of-the-art for classification on the \gls{ISE} and \gls{CBOE} dataset, as we show. \begin{figure}[ht] \centering @@ -163,12 +158,256 @@ \subsection{Results of Supervised \subsection{Results of Semi-Supervised Models}\label{sec:results-of-semi-supervised-models} + + \textbf{Gradient Boosting With Self-Training} \textbf{FT-Transformer With Pretraining} \subsection{Robustness of Results}\label{sec:robustness-checks} +\todo{Again, results are not 100 \% comparaable due to grouping.} +\todo{Compare improvements with other works. Improvments much greater than ronen et al. } + +\textbf{Gradient Boosting} + +\begin{table}[ht] + \centering + \caption[short-diff-ise-supervised-test-gbm]{long-diff-ise-supervised-test-gbm} + \label{tab:diff-ise_supervised_test} + \begin{tabular}{lSSSSSS@{}} + \toprule + {} & \multicolumn{2}{c}{FS Classical} & \multicolumn{2}{c}{FS Classical-Size} & \multicolumn{2}{c}{FS Option} \\ \cmidrule(lr){2-3}\cmidrule(lr){4-5}\cmidrule(lr){6-7} + {} & {Acc. in \%} & {Chg.} & {Acc. in \%} & {Chg.} & {Acc. in \%} & {Chg.} \\\midrule + \multicolumn{7}{l}{ Option Type} \\ + \tabindent C & 62.890486 & 3.930000 & 71.884647 & 4.890000 & 73.647971 & 6.650000 \\ + \tabindent P & 64.557394 & 3.720000 & 72.867874 & 5.430000 & 74.660185 & 7.220000 \\ + \cmidrule(rl){1-7} + \multicolumn{7}{l}{ Security Type} \\ + \tabindent Index option & 56.345043 & -1.440000 & 57.474458 & -1.050000 & 58.649239 & 0.130000 \\ + \tabindent Others & 68.399095 & 3.080000 & 76.369535 & 6.230000 & 77.590573 & 7.450000 \\ + \tabindent Stock option & 61.877752 & 4.210000 & 70.946999 & 4.800000 & 72.956919 & 6.810000 \\ + \cmidrule(rl){1-7} + \multicolumn{7}{l}{ Trade Size} \\ + \tabindent (0,1] & 61.892029 & 3.570000 & 72.564793 & 3.780000 & 74.245655 & 5.470000 \\ + \tabindent (1,3] & 62.473959 & 4.230000 & 72.965377 & 4.120000 & 74.857610 & 6.010000 \\ + \tabindent (3,5] & 62.696932 & 4.120000 & 72.755628 & 3.800000 & 74.647279 & 5.690000 \\ + \tabindent (5,11] & 65.928967 & 3.590000 & 71.752039 & 8.460000 & 73.450299 & 10.150000 \\ + \tabindent >11 & 67.310266 & 3.840000 & 71.337373 & 6.790000 & 73.145472 & 8.600000 \\ + \cmidrule(rl){1-7} + \multicolumn{7}{l}{ Year} \\ + \tabindent 2015 & 60.446922 & 4.230000 & 69.000296 & 5.650000 & 71.512360 & 8.160000 \\ + \tabindent 2016 & 63.736474 & 3.760000 & 72.555638 & 5.440000 & 74.290527 & 7.170000 \\ + \tabindent 2017 & 64.596306 & 3.860000 & 72.977560 & 4.280000 & 74.604216 & 5.900000 \\ + \cmidrule(rl){1-7} + \multicolumn{7}{l}{ Time To Maturity} \\ + \tabindent <= 1 & 64.458297 & 3.790000 & 72.756774 & 5.650000 & 74.604553 & 7.490000 \\ + \tabindent(1-2] & 64.612677 & 4.040000 & 72.869099 & 4.750000 & 73.947396 & 5.830000 \\ + \tabindent (2-3] & 63.015912 & 3.250000 & 71.743691 & 3.860000 & 72.997282 & 5.110000 \\ + \tabindent (3-6] & 61.788369 & 3.840000 & 71.288086 & 3.840000 & 72.750293 & 5.300000 \\ + \tabindent (6-12] & 61.911555 & 4.190000 & 71.199996 & 3.730000 & 73.130453 & 5.660000 \\ + \tabindent > 12 & 55.126547 & 4.050000 & 68.572852 & 3.870000 & 72.004951 & 7.300000 \\ + \cmidrule(rl){1-7} + \multicolumn{7}{l}{ Moneyness} \\ + \tabindent <= 0.7 & 65.531247 & 3.980000 & 71.917341 & 7.800000 & 72.307517 & 8.190000 \\ + \tabindent (0.7-0.9] & 67.642270 & 3.940000 & 74.254665 & 6.390000 & 75.433765 & 7.570000 \\ + \tabindent (0.9-1.1] & 64.059687 & 3.750000 & 72.975308 & 4.820000 & 74.457482 & 6.310000 \\ + \tabindent (1.1-1.3] & 54.294722 & 4.160000 & 66.220667 & 4.560000 & 70.375579 & 8.720000 \\ + \tabindent > 1.3 & 52.623795 & 3.790000 & 63.075529 & 3.100000 & 70.489510 & 10.510000 \\ + \cmidrule(rl){1-7} + \multicolumn{7}{l}{ Proximity To Quotes} \\ + \tabindent At Mid & 62.644890 & 5.950000 & 72.164951 & 6.260000 & 74.685118 & 8.780000 \\ + \tabindent Inside & 62.605233 & 2.400000 & 68.301819 & 4.060000 & 70.295127 & 6.050000 \\ + \tabindent At Quotes & 67.828443 & 7.860000 & 86.667541 & 8.450000 & 87.313763 & 9.100000 \\ + \tabindent Outside & 61.350064 & -5.420000 & 61.846608 & -3.050000 & 64.034087 & -0.860000 \\ + \tabindent Unknown & 78.638385 & 2.190000 & 78.275744 & 1.830000 & 78.816285 & 2.370000 \\ + \cmidrule(rl){1-7} + \multicolumn{7}{l}{ All} \\ + \tabindent All & 63.668637 & 3.830000 & 72.343640 & 5.140000 & 74.120496 & 6.920000 \\ + \bottomrule + \end{tabular} +\end{table} + + + +\begin{table}[ht] + \centering + \caption[short-diff-cboe-transfer-test]{long-diff-cboe-gbm-tbd} + \label{tab:diff-cboe_transfer-gbm} + \begin{tabular}{lSSSSSS@{}} + \toprule + {} & \multicolumn{2}{c}{FS Classical} & \multicolumn{2}{c}{FS Classical-Size} & \multicolumn{2}{c}{FS Option} \\ \cmidrule(lr){2-3}\cmidrule(lr){4-5}\cmidrule(lr){6-7} + {} & {Acc. in \%} & {Chg.} & {Acc. in \%} & {Chg.} & {Acc. in \%} & {Chg.} \\\midrule + \multicolumn{7}{l}{ Option Type} \\ + \tabindent C & 65.505083 & 5.780000 & 71.707057 & 6.610000 & 74.283388 & 9.190000 \\ + \tabindent P & 66.597419 & 5.510000 & 72.245014 & 5.830000 & 74.484832 & 8.070000 \\ + \cmidrule(rl){1-7} + \multicolumn{7}{l}{ Security Type} \\ + \tabindent Index Option & 60.365562 & 7.050000 & 67.298912 & 1.550000 & 72.394792 & 6.650000 \\ + \tabindent Others & 69.054857 & 4.860000 & 74.137168 & 6.080000 & 75.534837 & 7.470000 \\ + \tabindent Stock Option & 65.293961 & 5.850000 & 71.506273 & 6.800000 & 74.089988 & 9.380000 \\ + \cmidrule(rl){1-7} + \multicolumn{7}{l}{ Trade Size} \\ + \tabindent (0,1] & 62.831155 & 6.200000 & 70.756340 & 7.500000 & 73.423543 & 10.160000 \\ + \tabindent (1,3] & 64.895723 & 5.590000 & 71.318816 & 7.130000 & 73.634574 & 9.450000 \\ + \tabindent (3,5] & 65.549362 & 5.500000 & 71.956770 & 6.500000 & 74.174579 & 8.720000 \\ + \tabindent(5,11] & 66.577620 & 5.630000 & 71.566680 & 6.090000 & 74.143799 & 8.670000 \\ + \tabindent >11 & 71.136074 & 5.140000 & 74.549126 & 3.680000 & 76.765762 & 5.900000 \\ + \cmidrule(rl){1-7} + \multicolumn{7}{l}{ Year} \\ + \tabindent 2015 & 65.689585 & 4.850000 & 71.445193 & 7.340000 & 74.317847 & 10.220000 \\ + \tabindent 2016 & 65.579978 & 5.770000 & 71.638148 & 7.290000 & 74.178699 & 9.830000 \\ + \tabindent 2017 & 66.491658 & 5.640000 & 72.349451 & 5.020000 & 74.591947 & 7.260000 \\ + \cmidrule(rl){1-7} + \multicolumn{7}{l}{ Time To Maturity} \\ + \tabindent <= 1 & 66.863272 & 5.410000 & 72.005520 & 6.020000 & 74.272153 & 8.290000 \\ + \tabindent (1-2] & 67.553775 & 5.950000 & 72.584599 & 5.990000 & 75.237684 & 8.640000 \\ + \tabindent (2-3] & 66.061857 & 6.080000 & 72.349461 & 5.930000 & 74.713903 & 8.300000 \\ + \tabindent(3-6] & 65.007308 & 6.250000 & 72.855935 & 7.020000 & 75.086134 & 9.250000 \\ + \tabindent(6-12] & 64.184403 & 5.890000 & 71.908786 & 6.870000 & 74.389885 & 9.360000 \\ + \tabindent > 12 & 56.065976 & 5.580000 & 66.802260 & 7.580000 & 71.092148 & 11.870000 \\ + \cmidrule(rl){1-7} + \multicolumn{7}{l}{ Moneyness} \\ + \tabindent <= 0.7 & 65.722320 & 5.740000 & 72.842929 & 4.820000 & 75.645703 & 7.630000 \\ + \tabindent (0.7-0.9] & 66.272446 & 5.900000 & 72.187575 & 5.980000 & 74.768887 & 8.570000 \\ + \tabindent (0.9-1.1] & 66.977290 & 5.610000 & 72.619255 & 6.260000 & 74.739508 & 8.380000 \\ + \tabindent (1.1-1.3] & 58.197013 & 5.190000 & 66.153817 & 7.660000 & 69.833429 & 11.340000 \\ + \tabindent > 1.3 & 56.958403 & 6.070000 & 64.569317 & 7.220000 & 70.478616 & 13.130000 \\ + \cmidrule(rl){1-7} + \multicolumn{7}{l}{ Proximity To Quotes} \\ + \tabindent At Mid & 60.997665 & 7.130000 & 67.848014 & 8.490000 & 69.845251 & 10.490000 \\ + \tabindent Inside & 68.822448 & 3.580000 & 71.987785 & 6.680000 & 73.698272 & 8.390000 \\ + \tabindent At Quotes & 54.187224 & 16.010000 & 74.756821 & 2.410000 & 81.426352 & 9.080000 \\ + \tabindent Outside & 70.719978 & -4.170000 & 70.369607 & -1.550000 & 69.648255 & -2.270000 \\ + \tabindent Unknown & 83.771336 & 1.130000 & 83.608778 & 0.970000 & 84.213854 & 1.570000 \\ + \cmidrule(rl){1-7} + \multicolumn{7}{l}{ All} \\ + \tabindent All & 66.002029 & 5.660000 & 71.951794 & 6.260000 & 74.375033 & 8.680000 \\ + \bottomrule + \end{tabular} +\end{table} + + +\textbf{FT-Transformer} + +\begin{table}[ht] + \centering + \caption[short-diff-ise-supervised-test-fttransformer]{long-diff-ise-supervised-test-fttransformer} + \label{tab:diff-ise_supervised-test} + \begin{tabular}{lSSSSSS@{}} + \toprule + {} & \multicolumn{2}{c}{FS Classical} & \multicolumn{2}{c}{FS Classical-Size} & \multicolumn{2}{c}{FS Option} \\ \cmidrule(lr){2-3}\cmidrule(lr){4-5}\cmidrule(lr){6-7} + {} & {Acc. in \%} & {Chg.} & {Acc. in \%} & {Chg.} & {Acc. in \%} & {Chg.} \\\midrule + \multicolumn{7}{l}{ Option Type} \\ + \tabindent C & 62.991514 & 4.030000 & 72.099064 & 5.100000 & 73.484904 & 6.490000 \\ + \tabindent P & 64.687031 & 3.840000 & 73.131667 & 5.690000 & 74.420786 & 6.980000 \\ + \cmidrule(rl){1-7} + \multicolumn{7}{l}{ Security Type} \\ + \tabindent Index option & 56.519890 & -1.260000 & 58.457380 & -0.070000 & 58.641678 & 0.120000 \\ + \tabindent Others & 68.443599 & 3.120000 & 76.549050 & 6.410000 & 77.590109 & 7.450000 \\ + \tabindent Stock option & 62.019384 & 4.350000 & 71.196166 & 5.050000 & 72.674763 & 6.520000 \\ + \cmidrule(rl){1-7} + \multicolumn{7}{l}{ Trade Size} \\ + \tabindent (0,1] & 62.127137 & 3.800000 & 72.877007 & 4.100000 & 73.967386 & 5.190000 \\ + \tabindent(1,3] & 62.654716 & 4.410000 & 73.321548 & 4.480000 & 74.721308 & 5.880000 \\ + \tabindent (3,5] & 62.839285 & 4.270000 & 73.161769 & 4.200000 & 74.715927 & 5.760000 \\ + \tabindent (5,11] & 65.756057 & 3.410000 & 71.877263 & 8.580000 & 73.441354 & 10.150000 \\ + \tabindent >11 & 67.380602 & 3.910000 & 71.237293 & 6.690000 & 72.584805 & 8.040000 \\ + \cmidrule(rl){1-7} + \multicolumn{7}{l}{ Year} \\ + \tabindent 2015 & 60.620179 & 4.410000 & 69.609946 & 6.260000 & 71.861077 & 8.510000 \\ + \tabindent 2016 & 63.851905 & 3.870000 & 72.798245 & 5.680000 & 74.138951 & 7.020000 \\ + \tabindent 2017 & 64.688426 & 3.950000 & 73.077731 & 4.380000 & 74.111711 & 5.410000 \\ + \cmidrule(rl){1-7} + \multicolumn{7}{l}{ Time To Maturity} \\ + \tabindent <= 1 & 64.546416 & 3.880000 & 72.976628 & 5.860000 & 74.450445 & 7.340000 \\ + \tabindent(1-2] & 64.736461 & 4.170000 & 73.043470 & 4.930000 & 73.692560 & 5.570000 \\ + \tabindent (2-3] & 63.152545 & 3.380000 & 72.063690 & 4.180000 & 72.896064 & 5.010000 \\ + \tabindent (3-6] & 61.887659 & 3.940000 & 71.531191 & 4.080000 & 72.287641 & 4.830000 \\ + \tabindent (6-12] & 62.021518 & 4.300000 & 71.325950 & 3.860000 & 72.466903 & 5.000000 \\ + \tabindent > 12 & 55.669126 & 4.590000 & 69.313656 & 4.610000 & 72.282466 & 7.580000 \\ + \cmidrule(rl){1-7} + \multicolumn{7}{l}{ Moneyness} \\ + \tabindent <= 0.7 & 65.196444 & 3.650000 & 71.762641 & 7.650000 & 71.689001 & 7.580000 \\ + \tabindent (0.7-0.9] & 67.618182 & 3.910000 & 74.318808 & 6.450000 & 74.876535 & 7.010000 \\ + \tabindent (0.9-1.1] & 64.141472 & 3.830000 & 73.115683 & 4.960000 & 74.236648 & 6.080000 \\ + \tabindent (1.1-1.3] & 54.943206 & 4.810000 & 67.505754 & 5.850000 & 70.929706 & 9.270000 \\ + \tabindent > 1.3 & 53.468351 & 4.630000 & 64.293219 & 4.320000 & 71.424038 & 11.450000 \\ + \cmidrule(rl){1-7} + \multicolumn{7}{l}{ Proximity To Quotes} \\ + \tabindent At Mid & 62.490146 & 5.790000 & 72.138236 & 6.230000 & 74.022892 & 8.120000 \\ + \tabindent Inside & 62.566010 & 2.360000 & 68.807735 & 4.560000 & 70.429973 & 6.190000 \\ + \tabindent At Quotes & 68.608870 & 8.640000 & 86.087938 & 7.870000 & 86.165327 & 7.950000 \\ + \tabindent Outside & 63.228880 & -3.540000 & 63.792525 & -1.100000 & 65.610951 & 0.720000 \\ + \tabindent Unknown & 78.268902 & 1.820000 & 77.824153 & 1.380000 & 78.522066 & 2.070000 \\ + \cmidrule(rl){1-7} + \multicolumn{7}{l}{ All} \\ + \tabindent All & 63.783020 & 3.940000 & 72.581107 & 5.380000 & 73.921795 & 6.720000 \\ + \bottomrule + \end{tabular} +\end{table} + +\begin{table}[ht] + \centering + \caption[short-diff-cboe-transfer-test-fttransformer]{long-diff-cboe-transfer-test-fttransformer} + \label{tab:diff-cboe_transfer_test} + \begin{tabular}{lSSSSSS@{}} + \toprule + {} & \multicolumn{2}{c}{FS Classical} & \multicolumn{2}{c}{FS Classical-Size} & \multicolumn{2}{c}{FS Option} \\ \cmidrule(lr){2-3}\cmidrule(lr){4-5}\cmidrule(lr){6-7} + {} & {Acc. in \%} & {Chg.} & {Acc. in \%} & {Chg.} & {Acc. in \%} & {Chg.} \\\midrule + \multicolumn{7}{l}{ Option Type} \\ + \tabindent C & 65.628907 & 5.900000 & 71.945453 & 6.850000 & 74.579113 & 9.480000 \\ + \tabindent P & 66.845425 & 5.760000 & 72.402406 & 5.990000 & 73.917935 & 7.510000 \\ + \cmidrule(rl){1-7} + \multicolumn{7}{l}{ Security Type} \\ + \tabindent Index option & 61.207800 & 7.890000 & 67.170125 & 1.420000 & 69.051358 & 3.310000 \\ + \tabindent Others & 69.266211 & 5.070000 & 74.427252 & 6.370000 & 75.859396 & 7.800000 \\ + \tabindent Stock option & 65.395694 & 5.950000 & 71.703855 & 7.000000 & 74.141068 & 9.430000 \\ + \cmidrule(rl){1-7} + \multicolumn{7}{l}{ Trade Size} \\ + \tabindent (0,1] & 63.135782 & 6.500000 & 71.074930 & 7.820000 & 73.362654 & 10.100000 \\ + \tabindent (1,3] & 64.993995 & 5.690000 & 71.513064 & 7.330000 & 73.846381 & 9.660000 \\ + \tabindent (3,5] & 65.605000 & 5.560000 & 72.070498 & 6.610000 & 74.237799 & 8.780000 \\ + \tabindent (5,11] & 66.701471 & 5.750000 & 71.890991 & 6.420000 & 73.979636 & 8.510000 \\ + \tabindent >11 & 71.378727 & 5.380000 & 74.552019 & 3.680000 & 76.246445 & 5.380000 \\ + \cmidrule(rl){1-7} + \multicolumn{7}{l}{ Year} \\ + \tabindent 2015 & 65.830149 & 4.990000 & 71.843643 & 7.740000 & 74.755266 & 10.650000 \\ + \tabindent 2016 & 65.786999 & 5.970000 & 71.935076 & 7.590000 & 74.353864 & 10.010000 \\ + \tabindent 2017 & 66.648330 & 5.790000 & 72.424788 & 5.090000 & 74.138831 & 6.810000 \\ + \cmidrule(rl){1-7} + \multicolumn{7}{l}{ Time To Maturity} \\ + \tabindent<= 1 & 66.927563 & 5.470000 & 72.081695 & 6.100000 & 74.167407 & 8.180000 \\ + \tabindent(1-2] & 67.642166 & 6.040000 & 72.576488 & 5.980000 & 74.914699 & 8.320000 \\ + \tabindent (2-3] & 66.550561 & 6.570000 & 72.383470 & 5.970000 & 73.512089 & 7.100000 \\ + \tabindent (3-6] & 65.257500 & 6.500000 & 73.243404 & 7.410000 & 75.241041 & 9.410000 \\ + \tabindent (6-12] & 64.630833 & 6.330000 & 72.430785 & 7.400000 & 74.759232 & 9.720000 \\ + \tabindent > 12 & 56.949258 & 6.460000 & 68.451314 & 9.230000 & 71.975430 & 12.760000 \\ + \cmidrule(rl){1-7} + \multicolumn{7}{l}{ Moneyness} \\ + \tabindent <= 0.7 & 65.747181 & 5.770000 & 72.938769 & 4.920000 & 75.030310 & 7.010000 \\ + \tabindent (0.7-0.9] & 66.501088 & 6.130000 & 72.160406 & 5.960000 & 73.928341 & 7.730000 \\ + \tabindent (0.9-1.1] & 67.105536 & 5.740000 & 72.698844 & 6.340000 & 74.754866 & 8.400000 \\ + \tabindent (1.1-1.3] & 58.732468 & 5.720000 & 67.827369 & 9.340000 & 70.847531 & 12.360000 \\ + \tabindent > 1.3 & 57.597394 & 6.700000 & 66.397443 & 9.050000 & 71.088957 & 13.740000 \\ + \cmidrule(rl){1-7} + \multicolumn{7}{l}{ Proximity To Quotes} \\ + \tabindent At Mid & 60.688727 & 6.820000 & 67.528635 & 8.170000 & 69.104800 & 9.750000 \\ + \tabindent Inside & 68.679525 & 3.440000 & 72.284311 & 6.970000 & 73.930387 & 8.620000 \\ + \tabindent At Quotes & 56.479734 & 18.300000 & 74.815580 & 2.470000 & 79.999142 & 7.650000 \\ + \tabindent Outside & 73.145095 & -1.740000 & 72.581753 & 0.660000 & 71.908491 & -0.010000 \\ + \tabindent Unknown & 83.807460 & 1.160000 & 83.220446 & 0.580000 & 83.491375 & 0.850000 \\ + \cmidrule(rl){1-7} + \multicolumn{7}{l}{ All} \\ + \tabindent All & 66.182348 & 5.840000 & 72.153338 & 6.460000 & 74.278318 & 8.580000 \\ + \bottomrule + \end{tabular} +\end{table} + +\todo{When the analysis was repeated using only the Lee and Radhakrishna subsample, the results were equally as strong or stronger, with two exceptions. Using their subsample, time between transactions is no longer a statistically signi"cant determinant of misclassi"cation and large trades are misclassi"ed slightly more frequently than small trades (odderswhite)} +\todo{Our focus is on ... rules.} +\todo{Improvements are particularily high for trades that are notourisly hard to classify by classical trade classification algorithms.} + \subsection{Feature Importance}\label{sec:feature-importance} \newpage diff --git a/reports/Content/rule-approaches.tex b/reports/Content/rule-approaches.tex index 3ef66e38..17227daf 100644 --- a/reports/Content/rule-approaches.tex +++ b/reports/Content/rule-approaches.tex @@ -212,7 +212,7 @@ \subsubsection{Stacked Rule}\label{sec:stacked-rule} The previous algorithms are static concerning the used base rules and their alignment. Combining arbitrary rules into a single algorithm requires a generic procedure. \textcite[][18]{grauerOptionTradeClassification2022} combine basic and hybrid rules through stacking. In this setting, the trade traverses a stack of pre-defined rules until a rule can classify the trade or the end of the stack is reached~\footnote{For a trade, which cannot be classified by any classifier, one may fallback on a random assignment or the majority class if the distribution of trades is imbalanced.}. The classification is now dependent on the employed rules but also on their relative ordering. -The most basic application is in the \gls{LR} algorithm, combining $\operatorname{quote} \to \operatorname{tick}$, whereby the quote rule is applied first as indicated by the arrow. For a more complex example consider the hybrid rule consisting of $\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}}$ popularized in \textcite[][18]{grauerOptionTradeClassification2022}. We refer to this specific combination as the \gls{GSU} rule. Only a fraction of all trades are classifiable by the trade size rule, which is the primary rule, due to a narrow domain, and classification is deferred to lower rules in the stack, specifically the quote rule at the \gls{NBBO}, which by design has larger coverage. Theoretically, stacked rules can grow to great depth with an arbitrary arrangement. In practice, rules may be ordered greedily and new rules added if there are unclassified trades. +The most basic application is in the \gls{LR} algorithm, combining $\operatorname{quote} \to \operatorname{tick}$, whereby the quote rule is applied first as indicated by the arrow. For a more complex example consider the hybrid rule consisting of $\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}}$ popularized in \textcite[][18]{grauerOptionTradeClassification2022}. Only a fraction of all trades are classifiable by the trade size rule, which is the primary rule, due to a narrow domain, and classification is deferred to lower rules in the stack, specifically the quote rule at the \gls{NBBO}, which by design has larger coverage. Theoretically, stacked rules can grow to great depth with an arbitrary arrangement. In practice, rules may be ordered greedily and new rules added if there are unclassified trades. \textcite[][3811]{chakrabartyTradeClassificationAlgorithms2007} and \textcite[][18]{grauerOptionTradeClassification2022} continue the trend for more complex classification rules, leading to a higher fragmented decision surface, and eventually resulting in improved classification accuracy. Since the condition, for the selection of the base rule, is inferred from \emph{static} cut-off points at the decile boundaries of the spread including the midspread and quotes. This raises the question of whether classifiers trained on price and quote data can adapt to the data and improve upon classical trade classification rules. diff --git a/reports/Content/training-tuning.tex b/reports/Content/training-tuning.tex index f8700e7f..ce3c136c 100644 --- a/reports/Content/training-tuning.tex +++ b/reports/Content/training-tuning.tex @@ -119,8 +119,8 @@ \subsubsection{Training of Supervised Classical trade classification rules serve as a benchmark in our work. We implement them as a classifier that combines arbitrary trade classification rules through stacking, as covered in \cref{sec:semi-supervised-approaches}. -% FIXME: They write that they classify randomly, but they don't do so. -In cases where classification is not feasible due to missing data or the rules' definition itself, we resort to a random classification, which achieves an average accuracy of \SI{50}{\percent}. In this regard, we deviate from \textcite[][29--32]{grauerOptionTradeClassification2022}, who consider unclassified trades as falsely classified, in \SI{0}{\percent} accuracy. In our context, such a procedure would bias towards machine learning classifiers, which we avidly avoid. +In cases where classification is not feasible due to missing data or the rules' definition itself, we resort to a random classification, which achieves an average accuracy of \SI{50}{\percent}. The approach is adopted from \textcite[][887]{savickasInferringDirectionOption2003}. +% In this regard, we deviate from \textcite[][29--32]{grauerOptionTradeClassification2022}, who consider unclassified trades as falsely classified, in \SI{0}{\percent} accuracy. In our context, such a procedure would bias towards machine learning classifiers, which we avidly avoid. \subsubsection{Training of Semi-Supervised Models}\label{sec:training-of-semi-supervised-models} @@ -217,7 +217,7 @@ \subsubsection{Hyperparameter Tuning}\label{sec:hyperparameter-tuning} \textbf{Gradient Boosting With Self-Training} -The search space for the semi-supervised variant is identical to the supervised gradient boosting. To conserve space, we only report the tabulated results in \cref{tab:solutions-GBRT-self-training}. Visualisations of the hyperparameter search space are available online.\footnote{FS 1: \url{https://wandb.ai/fbv/thesis/runs/37lymmzc}\newline FS 2: \url{https://wandb.ai/fbv/thesis/runs/324v3uv5}\newline FS 3: \url{https://wandb.ai/fbv/thesis/runs/t55nd8r0}} +The search space for the semi-supervised variant is identical to the supervised gradient boosting. To conserve space, we only report the tabulated results in \cref{tab:solutions-GBRT-self-training}. Visualisations of the hyperparameter search space are available online.\footnote{See \url{https://wandb.ai/fbv/thesis/runs/37lymmzc} for FS 1, \url{https://wandb.ai/fbv/thesis/runs/324v3uv5} for FS3, and \url{https://wandb.ai/fbv/thesis/runs/t55nd8r0} for FS 3.} \begin{table}[H] \centering @@ -322,7 +322,7 @@ \subsubsection{Hyperparameter Tuning}\label{sec:hyperparameter-tuning} \end{tabular} \end{table} -Results are tabulated in \cref{tab:solutions-transformer-pretraining}. Visualisations of the hyperparameter search space are available online.\footnote{FS 1: \url{https://wandb.ai/fbv/thesis/runs/tbd} \newline FS 2: \url{https://wandb.ai/fbv/thesis/runs/tbd} \newline FS 3: \url{https://wandb.ai/fbv/thesis/runs/tbd}} +Results are tabulated in \cref{tab:solutions-transformer-pretraining}. Visualisations of the hyperparameter search space are available online.\footnote{See \url{https://wandb.ai/fbv/thesis/runs/tbd} for FS 1, for \url{https://wandb.ai/fbv/thesis/runs/tbd} for FS 2 and \url{https://wandb.ai/fbv/thesis/runs/tbd} for FS 3 for details.} \todo{Comment results.} @@ -330,18 +330,17 @@ \subsubsection{Hyperparameter Tuning}\label{sec:hyperparameter-tuning} Akin to selecting the machine learning classifiers, we select our classical baselines on the \gls{ISE} validation set. This prevents \gls{overfitting} the test set and maintains consistency between both paradigms. For the same reason, baselines are kept constant in the transfer setting on the \gls{CBOE} sample. - Optimising hybrids of trade classification rules through Bayesian search is experimentally feasible by the stacking paradigm of \cref{sec:rule-based-approaches} and by treating the rules as a tunable hyperparameter. We consider all rules from \cref{sec:rule-based-approaches} learned on adjacent quotes of the exchange and \gls{NBBO} level or adjacent prices at the exchange and inter-exchange level and stack up to six rules. To model simple rules, consisting of a single or few rules, we add an identity mapping, $\operatorname{Id}$, that defers classification to later rules in the stack. A caveat of this approach is that sampled combinations may not be economically meaningful e.g., applying depth rule after tick rule, or not effective e.g., quote rule after tick rule, assuming complete data. Despite being unexplored, a conditional search space or human-in-the-loop sampling could account for this. -After all, we find no outperformance over hybrid rules already reported in the literature, as documented online.\footnote{For FS 1 our best combination of $\operatorname{quote}_{\mathrm{nbbo}} \to \operatorname{quote}_{\mathrm{ex}} \to \operatorname{rtick}_{\mathrm{all}}$ (simplified) reaches a validation accuracy of \SI{58.76225138074204}{\percent} equalling the solution of \textcite[][13]{grauerOptionTradeClassification2022}. For FS 2/3 the best search solution is $\operatorname{tsize}_{\mathrm{ex}} \to \operatorname{depth}_{\mathrm{ex}} \to \operatorname{quote}_{\mathrm{nbbo}} \to \operatorname{rtick}_{\mathrm{all}}$ (simplified) with \SI{68.53130707534115}{\percent} accuracy. The combination of \textcite[][15]{grauerOptionTradeClassification2022} reaches with $\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}}$ an accuracy of \SI{68.83590892498269}{\percent}. See \url{https://wandb.ai/fbv/thesis/runs/339j16i4} and \url{https://wandb.ai/fbv/thesis/runs/359ee3rp} for details. Experiments are run with \num{500} trials each.} Our combinations match or trail the accuracies of rules from \textcite[][13--15]{grauerOptionTradeClassification2022} on the \gls{ISE} validation set. Subsequently, we adopt their combinations as our benchmark, considering them to be the most challenging. +After all, we find no outperformance over hybrid rules already reported in the literature, as documented online.\footnote{For FS 1 our best combination of $\operatorname{quote}_{\mathrm{nbbo}} \to \operatorname{quote}_{\mathrm{ex}} \to \operatorname{rtick}_{\mathrm{all}}$ (simplified) reaches a validation accuracy of \SI{58.76225138074204}{\percent} equalling the solution of \textcite[][12]{grauerOptionTradeClassification2022}. For FS 2/3 the best search solution is $\operatorname{tsize}_{\mathrm{ex}} \to \operatorname{depth}_{\mathrm{ex}} \to \operatorname{quote}_{\mathrm{nbbo}} \to \operatorname{rtick}_{\mathrm{all}}$ (simplified) with \SI{68.53130707534115}{\percent} accuracy. The combination of \textcite[][14]{grauerOptionTradeClassification2022} reaches with $\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}}$ an accuracy of \SI{68.83590892498269}{\percent}. See \url{https://wandb.ai/fbv/thesis/runs/339j16i4} and \url{https://wandb.ai/fbv/thesis/runs/359ee3rp} for details. Experiments are run with \num{500} trials each.} Our combinations match or trail the accuracies of rules from \textcite[][12--14]{grauerOptionTradeClassification2022} on the \gls{ISE} validation set. Subsequently, we adopt their combinations as our benchmark, considering them to be the most challenging. -From all classical rules, a combination of the quote rule, $\operatorname{quote}_{\mathrm{nbbo}} \to \operatorname{quote}_{\mathrm{ex}} \to \operatorname{rtick}_{\mathrm{all}}$, where the quote rule first applied to the \gls{NBBO} and then to quotes of the \gls{ISE} followed by the reverse tick rule at inter-exchange level, performs best reaching a validation accuracy of \SI{58.76225138074204}{\percent}. The rule can be estimated using features from feature set one, which qualifies it as a benchmark. +From all candidate algorithms, a combination of the quote rule, $\operatorname{quote}_{\mathrm{nbbo}} \to \operatorname{quote}_{\mathrm{ex}} \to \operatorname{rtick}_{\mathrm{all}}$, where the quote rule first applied to the \gls{NBBO} and then to quotes of the \gls{ISE} followed by the reverse tick rule at inter-exchange level, performs best reaching a validation accuracy of \SI{58.76225138074204}{\percent}. The rule can be estimated using features from feature set one, which qualifies it as a benchmark. -For the second feature set involving size-related rules, we consider rules that involve the trade size or depth rule. Consistent with the recommendation of \textcite[][14]{grauerOptionTradeClassification2022}, we find that a deep stack of the $\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}}$ achieves the highest validation accuracy. Like before, we refer to this specific combination as the \gls{GSU} method. Much of the performance gains are owed to the trade size and depth rules, which reduce the dependence on the reverse tick test as a last resort and provide overrides for trades at the quotes, improving validation accuracy to \SI{68.8359}{\percent}. Due to the extended use of the quoted sizes and trade sizes, it is our benchmark for the second feature set. +For the second feature set involving size-related rules, we consider rules that involve the trade size or depth rule. Consistent with the recommendation of \textcite[][14]{grauerOptionTradeClassification2022}, we find that a deep stack of the $\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}}$ achieves the highest validation accuracy. Much of the performance gains are owed to the trade size and depth rules, which reduce the dependence on the reverse tick test as a last resort and provide overrides for trades at the quotes, improving validation accuracy to \SI{68.8359}{\percent}. Due to the extended use of the quoted sizes and trade sizes, it is our benchmark for the second feature set. % By extension, we also estimate rule combinations involving overrides from the trade size rule ($\operatorname{tsize}$) and the depth rule ($\operatorname{depth}$) on the top-performing baselines of feature set one. The tick test applied to trade prices at the trading venue performs worst with an accuracy below a random guess. Against this backdrop, we estimate all hybrid rules involving the tick rule over all exchanges ($\operatorname{tick}_{\mathrm{all}}$). -In the absence of other baselines, we repeatedly compare against \gls{GSU} method as a baseline for the third feature set, even if it doesn't involve option-specific features. +In the absence of other baselines, we repeatedly compare against the same method as a baseline for the third feature set, even if it doesn't involve option-specific features. Entirely for reference, we also report accuracies of the tick rule, quote rule, \gls{EMO} rule, and \gls{LR} algorithm, due to their widespread adoption in literature. diff --git a/reports/Graphs/classical-accuracies-over-time.pdf b/reports/Graphs/classical-accuracies-over-time.pdf index 190c1cee..ae96217b 100644 Binary files a/reports/Graphs/classical-accuracies-over-time.pdf and b/reports/Graphs/classical-accuracies-over-time.pdf differ diff --git a/reports/thesis.tex b/reports/thesis.tex index 82633908..c7304999 100644 --- a/reports/thesis.tex +++ b/reports/thesis.tex @@ -47,6 +47,8 @@ width=0.2cm,minimum height=0.2cm,inner sep=0pt] at (0,0) {};}} \newcommand{\bestcircle}{\tikz{\node[circle,draw=darkgray, fill=white, line width=0.5pt, minimum width=0.2cm,minimum height=0.2cm, inner sep=0pt, draw opacity=.2] at (0,0){};}} +\newcommand{\myline}{\tikz{\draw[dashed, gray, line width=0.5pt] (0,0) -- (0,0.3);}} + % Tables and Graphs \usepackage{makecell} %Connected rows \usepackage{booktabs} % Improves the design of the tables @@ -139,6 +141,7 @@ % --------------------------------- Definition of hyperlinks --------------------------------- % Hyperreferences \usepackage{hyperref} +\urlstyle{tt} % typewriter font for urls \definecolor{darkblue}{rgb}{0,0,.5} \hypersetup{ pdfstartview={FitH}, diff --git a/src/otc/models/classical_classifier.py b/src/otc/models/classical_classifier.py index 46cfdbcc..f43eede4 100644 --- a/src/otc/models/classical_classifier.py +++ b/src/otc/models/classical_classifier.py @@ -14,12 +14,7 @@ from sklearn.base import BaseEstimator, ClassifierMixin from sklearn.utils import check_random_state from sklearn.utils.multiclass import check_classification_targets -from sklearn.utils.validation import ( - _check_sample_weight, - check_array, - check_is_fitted, - check_X_y, -) +from sklearn.utils.validation import _check_sample_weight, check_is_fitted, check_X_y allowed_func_str = ( "tick", @@ -236,8 +231,8 @@ def _is_at_ask_xor_bid(self, subset: Literal["best", "ex"]) -> pd.Series: Returns: pd.Series: boolean series with result. """ - at_ask = self.X_["TRADE_PRICE"] == self.X_[f"ask_{subset}"] - at_bid = self.X_["TRADE_PRICE"] == self.X_[f"bid_{subset}"] + at_ask = np.isclose(self.X_["TRADE_PRICE"], self.X_[f"ask_{subset}"], atol=1e-4) + at_bid = np.isclose(self.X_["TRADE_PRICE"], self.X_[f"bid_{subset}"], atol=1e-4) return at_ask ^ at_bid def _is_at_upper_xor_lower_quantile( @@ -365,10 +360,18 @@ def _trade_size(self, *args: Any) -> npt.NDArray: Returns: npt.NDArray: result of the trade size rule. Can be np.NaN. """ - bid_eq_ask = self.X_["ask_size_ex"] == self.X_["bid_size_ex"] + bid_eq_ask = np.isclose( + self.X_["ask_size_ex"], self.X_["bid_size_ex"], atol=1e-4 + ) - ts_eq_bid = (self.X_["TRADE_SIZE"] == self.X_["bid_size_ex"]) & -bid_eq_ask - ts_eq_ask = (self.X_["TRADE_SIZE"] == self.X_["ask_size_ex"]) & -bid_eq_ask + ts_eq_bid = ( + np.isclose(self.X_["TRADE_SIZE"], self.X_["bid_size_ex"], atol=1e-4) + & ~bid_eq_ask + ) + ts_eq_ask = ( + np.isclose(self.X_["TRADE_SIZE"], self.X_["ask_size_ex"], atol=1e-4) + & ~bid_eq_ask + ) return np.where(ts_eq_bid, 1, np.where(ts_eq_ask, -1, np.nan)) @@ -386,7 +389,7 @@ def _depth(self, subset: Literal["best", "ex"]) -> npt.NDArray: Returns: npt.NDArray: result of depth rule. Can be np.NaN. """ - at_mid = self._mid(subset) == self.X_["TRADE_PRICE"] + at_mid = np.isclose(self._mid(subset), self.X_["TRADE_PRICE"], atol=1e-4) return np.where( at_mid & (self.X_["ask_size_ex"] > self.X_["bid_size_ex"]), @@ -503,7 +506,7 @@ def predict(self, X: npt.NDArray | pd.DataFrame) -> npt.NDArray: rs = check_random_state(self.random_state) - X = check_array(X, accept_sparse=False, force_all_finite=False) + # X = check_array(X, accept_sparse=False, force_all_finite=False) self.X_ = pd.DataFrame(data=X, columns=self.columns_)