Supervised Autoencoder MLP
Supervised Autoencoder MLP
March 4, 2024
Bartosz Bieganowski, Robert Ślepaczuk (WNE UW) SAE-MLP For Financial Time Series Forecasting March 4, 2024 1 / 33
Table of Contents
2 Feature Engineering
6 Sensitivity Analysis
7 Conclusion
Bartosz Bieganowski, Robert Ślepaczuk (WNE UW) SAE-MLP For Financial Time Series Forecasting March 4, 2024 2 / 33
Aim
The aim of this study is to verify whether the following machine-learning related techniques
can improve trading strategy performance:
Noise augmentation - originally developed for Computer Vision problems, it has been
noted that adding noise to the input data helps with generalization on image classification
tasks.
Supervised Autoencoder - originally developed for Natural Language Processing
problems, we test if SAE-MLP architecture can be applied in algorithmic trading
strategies.
Triple Barrier Labeling - although already mentioned in the literature, we expand on
this specific labeling method by developing an optimization metric that resembles the
strategy return better.
Bartosz Bieganowski, Robert Ślepaczuk (WNE UW) SAE-MLP For Financial Time Series Forecasting March 4, 2024 3 / 33
Research Questions
RQ2: Does the triple barrier labeling with correct optimization metric improve
strategy performance as expressed by Information Ratio?
Bartosz Bieganowski, Robert Ślepaczuk (WNE UW) SAE-MLP For Financial Time Series Forecasting March 4, 2024 4 / 33
Literature Review
Efficient Market Hypothesis (EMH) suggests stock prices reflect all available information,
making them unpredictable.
Studies by Fama (1970) and Malkiel (2005) support EMH, while Barberis and Thaler
(2002) suggest market inefficiencies.
Machine learning (ML) techniques like LSTM outperform traditional methods in stock
price prediction (Kryńska and Ślepaczuk, 2022).
LSTM models show promise in forecasting, but challenges remain in handling
non-stationary data and parameter sensitivity.
Hybrid models combining LSTM and GRU demonstrate improved performance in
forecasting financial assets (Baranovhnikov and Ślepaczuk, 2022)
ML models, particularly deep learning, excel in predicting Bitcoin prices, indicating their
relevance in cryptocurrency trading (Michanków et. al., 2022).
Bartosz Bieganowski, Robert Ślepaczuk (WNE UW) SAE-MLP For Financial Time Series Forecasting March 4, 2024 5 / 33
Data
S&P500 - Low volatility compared to individual stocks, correlated with economic growth
indicators, right-skewed return distribution.
Bartosz Bieganowski, Robert Ślepaczuk (WNE UW) SAE-MLP For Financial Time Series Forecasting March 4, 2024 6 / 33
Toolset
Hardware: GeForce RTX 2080 SUPER, Intel Core i7-9700K, Patriot 32GB RAM
Bartosz Bieganowski, Robert Ślepaczuk (WNE UW) SAE-MLP For Financial Time Series Forecasting March 4, 2024 7 / 33
Features - ICSA, Oil, Gas
Bartosz Bieganowski, Robert Ślepaczuk (WNE UW) SAE-MLP For Financial Time Series Forecasting March 4, 2024 8 / 33
Features - Corn, Gold, Copper
Bartosz Bieganowski, Robert Ślepaczuk (WNE UW) SAE-MLP For Financial Time Series Forecasting March 4, 2024 9 / 33
Features - Presumed Impact on Economy
Bartosz Bieganowski, Robert Ślepaczuk (WNE UW) SAE-MLP For Financial Time Series Forecasting March 4, 2024 10 / 33
Feature Engineering Question
What do we do with our features before we put them into the machine learning model?
Should we differentiate the time series (d=1, losing the memory aspect)?
Bartosz Bieganowski, Robert Ślepaczuk (WNE UW) SAE-MLP For Financial Time Series Forecasting March 4, 2024 11 / 33
Fractionally differentiated features
We can apply ARFIMA (Granger, C. W. J.; Joyeux, Roselyne, 1980) assumptions to machine learning
features. We consider the backshift operator B applied to a time series of a feature {Xt } such that
B k Xt = Xt−k .
It follows that the difference between current and last feature’s value can be expressed as (1 − B)Xt . For
example, (1 − B)2 = 1 − 2B + B 2 , where B 2 Xt = Xt−2 so that (1 − B)2 Xt = Xt − 2Xt−1 + Xt−2 .
Bartosz Bieganowski, Robert Ślepaczuk (WNE UW) SAE-MLP For Financial Time Series Forecasting March 4, 2024 12 / 33
Fractionally differentiated features
is the binomial series. In a model where d is allowed to be a real number, the binomial series
can be expanded into a series of weights which can be applied to feature values:
k−1
( )
d(d − 1) d(d − 1)(d − 1) Y d −i
ω = 1, −d, , , ..., (−1)k (3)
2! 3! k!
i=0
Bartosz Bieganowski, Robert Ślepaczuk (WNE UW) SAE-MLP For Financial Time Series Forecasting March 4, 2024 13 / 33
Optimal Differentiation Order
Bartosz Bieganowski, Robert Ślepaczuk (WNE UW) SAE-MLP For Financial Time Series Forecasting March 4, 2024 14 / 33
Optimal Differentiation Order
Bartosz Bieganowski, Robert Ślepaczuk (WNE UW) SAE-MLP For Financial Time Series Forecasting March 4, 2024 15 / 33
Triple Barrier Labeling
Whenever we try to express trading problem as a machine learning problem, we have to think
long and hard about what do we want our model to really predict (Y).
Bartosz Bieganowski, Robert Ślepaczuk (WNE UW) SAE-MLP For Financial Time Series Forecasting March 4, 2024 16 / 33
Triple Barrier Labeling
Bartosz Bieganowski, Robert Ślepaczuk (WNE UW) SAE-MLP For Financial Time Series Forecasting March 4, 2024 17 / 33
Triple Barrier Labeling
1,
if max(St , ..., St+n ) ≥ St · (1 + λ)
Pt = −1, if min(St , ..., St+n ) ≤ St · (1 − λ) (4)
0, otherwise
(Idea: λ was a constant for this study, but it might work well to base it on an estimate of future volatility)
Bartosz Bieganowski, Robert Ślepaczuk (WNE UW) SAE-MLP For Financial Time Series Forecasting March 4, 2024 18 / 33
Payoff Table
Pred/True 1 0 -1
1 λ (−λ, λ) −λ
0 0 0 0
-1 −λ (−λ, λ) λ
Bartosz Bieganowski, Robert Ślepaczuk (WNE UW) SAE-MLP For Financial Time Series Forecasting March 4, 2024 19 / 33
Derived Optimization Metric
We define directly correct count as the number of times the model entered correct position
which resulted in return of λ. We can similarly define directly incorrect count as the number
of times the model entered incorrect position:
Bartosz Bieganowski, Robert Ślepaczuk (WNE UW) SAE-MLP For Financial Time Series Forecasting March 4, 2024 20 / 33
Derived Optimization Metric
λ TEC
Φδ = (1 + λ)DCC · (1 − λ)DIC · 1 − (8)
δ
where δ > λ. In our study, we set δ arbitrarily to 20, indicating that twenty timed exits are
considered equally undesirable as one direct incorrect classification
(Note: Accurate prediction of zeros could also be taken advantage of with an option butterfly)
Bartosz Bieganowski, Robert Ślepaczuk (WNE UW) SAE-MLP For Financial Time Series Forecasting March 4, 2024 21 / 33
Data Augmentation in CV
Bartosz Bieganowski, Robert Ślepaczuk (WNE UW) SAE-MLP For Financial Time Series Forecasting March 4, 2024 22 / 33
Supervised Autoencoder
Bartosz Bieganowski, Robert Ślepaczuk (WNE UW) SAE-MLP For Financial Time Series Forecasting March 4, 2024 23 / 33
Supervised Autoencoder
Enhanced Feature Representation: Supervised autoencoders can learn more relevant and discriminative
features for the task at hand because they are trained to not only reconstruct the input data but also to
optimize for an additional task-specific loss (like classification or regression).
Regularization Effect: Incorporating the reconstruction objective alongside the task-specific objective
(like classification accuracy) can act as a form of regularization. This helps in preventing overfitting to the
training data by ensuring that the learned representations maintain information about the input data,
leading to more generalized models.
Efficiency in Data Use: By leveraging unlabeled data for the reconstruction part and labeled data for the
task-specific part, supervised autoencoders can make efficient use of datasets where obtaining labeled data
is expensive or time-consuming. This can be particularly beneficial in semi-supervised learning scenarios,
where the model can learn general features from a large pool of unlabeled data and fine-tune the
representations for the task with a smaller set of labeled examples.
Bartosz Bieganowski, Robert Ślepaczuk (WNE UW) SAE-MLP For Financial Time Series Forecasting March 4, 2024 24 / 33
Approaches Comparison
Bartosz Bieganowski, Robert Ślepaczuk (WNE UW) SAE-MLP For Financial Time Series Forecasting March 4, 2024 25 / 33
Drawdown-adjusted information ratio
We use the information ratio as our main metric, originally proposed by Kość et al. (2019)
which is a modification of the Information Ratio measure. This measure also takes into
account the sign of the portfolio’s rate of return and the maximum drawdown:
ARC 2 · sign(ARC )
IR ∗∗ = (9)
ASD · MDD
Bartosz Bieganowski, Robert Ślepaczuk (WNE UW) SAE-MLP For Financial Time Series Forecasting March 4, 2024 26 / 33
Results - Eq. Weight Portfolio of Strategies - IRR**
Bartosz Bieganowski, Robert Ślepaczuk (WNE UW) SAE-MLP For Financial Time Series Forecasting March 4, 2024 27 / 33
Sensitivity Analysis - Triple Barrier Labelling
Y - window height λ X-window length (minutes)
Bartosz Bieganowski, Robert Ślepaczuk (WNE UW) SAE-MLP For Financial Time Series Forecasting March 4, 2024 28 / 33
Sensitivity Analysis - Supervised Autoencoder
Y - Gaussian nosie rate X - Bottleneck size (% of feature count)
Bartosz Bieganowski, Robert Ślepaczuk (WNE UW) SAE-MLP For Financial Time Series Forecasting March 4, 2024 29 / 33
Sensitivity Analysis - Supervised Autoencoder
Bartosz Bieganowski, Robert Ślepaczuk (WNE UW) SAE-MLP For Financial Time Series Forecasting March 4, 2024 30 / 33
Research Question Findings
Bartosz Bieganowski, Robert Ślepaczuk (WNE UW) SAE-MLP For Financial Time Series Forecasting March 4, 2024 31 / 33
Further elaboration ideas
Dynamic lambda - setting lambda (TBL window size) to be a dynamic estimate of future
volatility.
Dynamic window length - setting dynamic length size based on estimate of market activity.
Zero-classifications - Accurate predictions of the price staying the same can be taking advantage
of with options (theta decay).
Other architectures - More elaborate models than MLP can be stacked on top of SAE (Random
Forest, ADABoost, CatBoost).
Feature engineering - more elaborate feature engineering to see how SAE reacts to greater
number of features.
Bartosz Bieganowski, Robert Ślepaczuk (WNE UW) SAE-MLP For Financial Time Series Forecasting March 4, 2024 32 / 33
Conclusion
Thank you!
Q&A
Bartosz Bieganowski, Robert Ślepaczuk (WNE UW) SAE-MLP For Financial Time Series Forecasting March 4, 2024 33 / 33