FEMIB2023, https://dblp.org/db/conf/femib/femib2023.html
Keywords: Neural Networks, Machine Learning, Stock Trading, Stock Market Prediction, Quantitative Finance, Algo-
rithmic Trading, Technical Analysis.
Abstract: Traders commonly test their trading strategies by applying them on the historical market data (backtesting),
and then reuse on their (future) trades the strategy that achieved the maximum profit on such past data. In
this paper, we propose a novel technique, that we shall call forwardtesting, that determines the strategy to
apply by testing it on the possible future predicted by a deep neural network that has been designed to perform
stock price forecasts and trained with the market historical data. Our results confirm that neural networks
outperform classical statistical techniques when performing such forecasts, and their predictions allow us to
select a trading strategy that, when applied to the real future, results equally or more profitable than the strategy
that would be selected through traditional backtesting.
2. Roadmap
● Traders test trading strategies on historical data (backtesting)
● Successful strategies from backtesting are reused in future trades
● A new technique called "forwardtesting" is proposed
● Our Forwardtesting involves testing strategies on prediction by DNNs
● Neural networks outperform traditional statistical methods in forecasting future market
trends
● We select a profitable strategy through forwardtesting results profits compared to
traditional backtesting
3. THE DATASET (Historical data)
● The dataset contains 10 years
of OHLC prices (2537 days)
○ from October 30th, 2011
○ to November 30th, 2021
● ANF and EOG stocks listed on NYSE not appear suitable for a passive B&H
strategy
4. THE DATASET (Outliers & Synchrony between TS)
● trend anomalies on the assets:
○ observing the monthly trend
of the closing price
○ financial returns through
the TSOD library
● test of uncurrelation:
○ Pearson Coefficient
0.28
○ Dynamic Time Warping
○ 209.95
5. THE DATASET (Stationarity Test))
● Stationarity is rarely observed in practice in
this field, but still needs to be established
○ Augmented Dickey Fuller (ADF) test is
used by analyzing the p-value and
critical value at various confidence
intervals
○ The number of lags in the ADF test is
automatically selected through the
Akaike Information Criterion (AIC)
○ P-values above the selected threshold
indicate that the time series is not
stationary
● Stationary characteristic of a time series refers to the constancy of statistical properties like mean,
variance, and covariance over time
6. ARIMA model Forecasting
● Settings: num. of AR terms p, num. of non-seasonal differences required for
stationarity d,and the num. of lagged forecast errors in the prediction equation q.
● Stationarity is rarely observed in practice in
this field, but still needs to be established
○ Augmented Dickey Fuller (ADF) test is
used by analyzing the p-value and
critical value at various confidence
intervals
○ The number of lags in the ADF test is
automatically selected through the
Akaike Information Criterion (AIC)
○ P-values above the selected threshold
indicate that the time series is not
stationary
7. Prophet model Forecasting
● Prophet captures non-linear
trends:
○ yearly | weekly | daily
seasonality
● EOG qui il testo Inserisci qui il
testo
● Robust to:
○ missing data
○ variations in the trend
○ outlier handling
● Components:
○ trend | seasonality | holidays
8. Deep Neural Networks Forecasting
● forecasting objective (i.e., n = 30
days)
● MLP geometry:
○ with 5 input neurons
○ with 1 output neuron
○ two hidden layers:
■ 10*t and 5*t neurons
● MLP hyperparameters:
○ dropout 0.2%
○ ReLU act.function
○ L1loss function
○ optimizer Adam
9. Deep Learning-based Trading System with Forwardtesting
● TEMA for ANF stocks
● ADX for EOG stocks
● Experiment:
○ 100$ of budget
○ Profit and Risk metrics:
■ #trades
■ Sharpe Ratio
■ Sortino Ratio
■ Expectation Ratio
■ Calmar Ratio
● set of entry and exit trading rules using 12 technical indicators (SMA, EMA, MACD, BBs, William
R, RSI, ATR, TEMA, ADX, etc…)
10. Conclusions & Future Work
● A new stock market trading system is proposed
● Deep neural networks are utilized to improve previous works
● Technical indicators are selected using a forwardtesting approach
● A neural network predicts probable future trends to guide trades
● The approach outperforms traditional backtesting methods
● Profits equal to or higher than those obtained through backtesting are achieved
11. Conclusions & Future Work
● The approach will be tested on other stock markets, including cryptocurrencies and
defi-tokens
● Refined feature selection and balancing strategies will be used in testing
● More complex neural networks will be explored to further improve forecasting.