<!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Archiving and Interchange DTD v1.0 20120330//EN" "JATS-archivearticle1.dtd">
<article xmlns:xlink="http://www.w3.org/1999/xlink">
  <front>
    <journal-meta>
      <journal-title-group>
        <journal-title>International Journal of Sys</journal-title>
      </journal-title-group>
    </journal-meta>
    <article-meta>
      <article-id pub-id-type="doi">10.1109/EuroSPW.2019.00029</article-id>
      <title-group>
        <article-title>AITA: A new framework for Trading Forward Testing with an Artificial Intelligence Engine</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Ivan Letteri</string-name>
          <email>ivan.letteri@univaq.it</email>
          <xref ref-type="aff" rid="aff0">0</xref>
          <xref ref-type="aff" rid="aff1">1</xref>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>System</institution>
          ,
          <addr-line>Algorithmic Trading, Backtesting, Forwardtesting</addr-line>
        </aff>
        <aff id="aff1">
          <label>1</label>
          <institution>University of L'Aquila</institution>
          ,
          <addr-line>via Vetoio snc, Coppito (AQ), 67100</addr-line>
          ,
          <institution>Italy - Department of Information Engineering</institution>
          ,
          <addr-line>Computer Science and Maths</addr-line>
        </aff>
      </contrib-group>
      <pub-date>
        <year>2017</year>
      </pub-date>
      <volume>01</volume>
      <fpage>29</fpage>
      <lpage>31</lpage>
      <abstract>
        <p>In general, traders test their trading strategies by applying them to historical market data (backtesting), and then reapply those that have made the most profit on that past data. In this article, we propose AITA (Artificial Intelligence Trading Assistant ), our framework for generating trading systems by applying the new trading strategy called DNN-forwardtesting [1] by determining the best strategy based on the prediction issued by a deep neural network. In this work, we show the experiment with AITA involves the use of 10 stocks that are first ifltered according to their volatility using the Kmean++ model. Having determined the assets with average volatility, we use this historical data to train a deep feed-forward neural network to predict price trends over the next 30 days of the open stock market. Finally, the trading system, created by AITA, calculates the most efective technical indicator by applying it to the DNN forecasts to generate the trading strategy.</p>
      </abstract>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>1. Introduction</title>
      <p>Stock market forecasting is considered a field of research
with promising returns for investors. However, there
rately and suficiently precisely due to their complexity,
chaotic and non-linear nature. In fact, traditional
statistical models, which have been widely applied to market
trend forecasting so far, can easily handle only linear or
stationary sequences.</p>
      <p>
        In our experiment, we used as benchmark the ARIMA
which is strength being in its robustness and eficiency
in terms of short-term forecasting [
        <xref ref-type="bibr" rid="ref2">2</xref>
        ] but showed poor
results. On the other hand, artificial intelligence models
are currently employed in a variety of tasks, e.g. to
classify cyber attacks [
        <xref ref-type="bibr" rid="ref3">3</xref>
        ], predict network trafic anomalies
[4, 5]. Among such artificial intelligence methods and, in
particular, Deep Neural Networks (DNNs) have proven
suitable for dealing with complex non-linear problems
with multiple influencing factors [ 6].
      </p>
      <p>In this paper we propose AITA, our framework that
uses historical stock price data to train a set of DNNs to
predict future (next month) stock prices. These
predictions are exploited in a new way to determine the most  
() &lt;  
(ℎ) and  
()
,  
() ∈ [ 
()
,  
(ℎ)
,  
()
,  
()
,  
(ℎ)].</p>
      <p>() ) , where</p>
      <sec id="sec-1-1">
        <title>2.2. Volatility Estimators used</title>
        <p>Volatility measures1.</p>
        <p>Volatility quantifies the dispersion of returns.
Unfortunately, this dispersion can not be measured and volatility
is not directly observable, but it is possible to estimate it
[8]. AITA framework is designed to use the Historical
- The Parkinson (PK) estimator incorporates the
stock’s daily high and low prices as follow:   =
1
√ 4 2</p>
        <p>tor
√
∑=1 (  (ℎ)

 
() )2. It is derived from the assumption
that the true volatility of the asset is proportional to the
(ℎ) and low</p>
        <p>()

 
 
()
() )2.</p>
        <p>=
prices of  observations.
logarithm ( ) of the ratio of the high</p>
        <p>The</p>
        <p>Garman-Klass
(GK)
is
calculated
as</p>
        <p>follows:
 (ℎ)
 
1 ∑=1 2</p>
        <p>1

(</p>
        <p>() )2 − 1 ∑=1 (2(2) − 1)(
This method is robust for opening jumps in price and
trend movements. However, the estimator assumes that
price movements are log-normally distributed, which
may not always be the case in practice.</p>
        <p>- The Rogers-Satchell (RS) estimator uses the range
of prices within a given time interval as a proxy
for the volatility of the asset as follows:  =
√

1 ∑=1 ((  (ℎ)
() )(  (ℎ)
() ) + (  
()
() )(</p>
        <p>()
 
 
 
 
that the range of prices within the interval is a good
proxy for the volatility of the asset, which may not
always be the case. Additionally, the estimator may be
sensitive to outliers and extreme price movements.
() ). RS assumes
The</p>
        <p>Yang-Zhang
(YZ)
estimator
may have limitations in certain situations, and it is often
recommended to use multiple estimators and compare
their results to gain a more complete understanding of
the underlying volatility.</p>
      </sec>
      <sec id="sec-1-2">
        <title>2.3. Trading Strategies implemented</title>
        <p>Two distinct trading strategy classes are used in AITA
framework:</p>
        <p>- Trend Following. One way to trade a trend is to look
at an asset with a resistance line. Once the price breaks
through resistance, a trader places an order in the
direction of the breakout2. Trend-following, or momentum,
strategies have the attractive property of generating
trading returns with a positively skewed statistical
distribution. Consequently, they tend to hold on to their profits
and are unlikely to have severe ‘drawdowns’ ([10]).</p>
        <p>- Mean Reversion. The idea of mean reversion strategies
is that the maximum and minimum price of a security is
temporary, and that it will tend to the average over time
(see [11]). Elliott et al.[12] explains how mean-reverting
processes might be used in pairs trading and developed
several methods for parameter estimation.
estima- version strategies, although theoretically opposing ideas,</p>
        <p>It is worth noting that trend following and mean
reare not in conflict with each other and they are therefore
both applicable at the same time to the same security.
[9] in- Sortino ratio (SoR) is a variant of the risk-adjusted profit</p>
      </sec>
      <sec id="sec-1-3">
        <title>2.4. Metrics applied</title>
        <p>Profit and risk metrics are crucial considerations in
trading AITA framework evaluates the following, for the
potential profitability of the investments and to manage
the risk exposure.</p>
        <p>(i) The Maximum drawdown (MDD) measures the
largest decline from the peak in the whole trading
period, to show the worst case, as follows:   =

 ∈(0,) [
∈(0, )</p>
        <p>a risk-adjusted profit measure, which refers to the return</p>
        <p>−  ]. (ii) The Sharpe ratio (SR) is
per unit of deviation as follows:  =
[]
[] . (iii) The
measure, which applies DD as risk measure:  =
(iv) The Calmar ratio (CR) is another variant of the
riskadjusted profit measure, which applies MDD as risk
mea[] .

  ()</p>
        <p>To check the goodness of trades, we mainly focused
in the time interval ( = 1, ..., ) , where   = 
on the Total Returns   () for each stock ( = 1, ..., )
  (+Δ)−  () , and furthermore analysing the
standard () =
ized returns   = (  −   )/  , with ( = 1, ..., ) , where
overtime for the studied period.
2https://en.wikipedia.org/wiki/Breakout_(technical_analysis)
corporates
2

√ ℎ 
 =</p>
        <p>0.34
1.34+  +1

.
studies have shown that the YZ estimator can perform
well in a variety of settings, including in the presence
of jumps and in the presence of non-normality in the
1https://dynamiproject.files.wordpress.com/2016/01/measuring_
historic_volatility.pdf
data. However, like any estimator, it is not perfect and   is the standard deviation of  
, e   denote the average</p>
      </sec>
    </sec>
    <sec id="sec-2">
      <title>3. Dataset Pre-processing</title>
      <sec id="sec-2-1">
        <title>3.1. Volatility Stock Clustering</title>
        <p>are almost completely uncorrelated. However, this is a
measure of the global synchrony in the overall period.</p>
        <p>(ii) The Dynamic Time Warping (DTW) algorithm
calculates the optimal match between the two series by
minimising the Euclidean distance between pairs of samples
at the same time. The minimum path cost is  = 209.95 ,
and such a large distance between the two stocks
supports our hypothesis of a complete absence of influence
between them.</p>
      </sec>
    </sec>
    <sec id="sec-3">
      <title>4. Forecasting Methods</title>
      <sec id="sec-3-1">
        <title>4.1. ARIMA model as benchmark</title>
        <p>In this section, we maintain the same forecasting
objective of Section 4.1, i.e.,  = 30 days following the training
date. We empirically found that the neural network
performs better is the Multi Layer Perceptron when its input
layer is fed with the  = 5 previous values, i.e., the prices
of the previous market week. In other words, to forecast
the price of a day  , the input neurons will be presented
to the prices of days  − 1, … ,  − 5 , respectively. The
network then outputs its price prediction via a single
3.2. Stocks Selected neuron in the output layer.</p>
        <p>
          ANF and EOG are certainly assets with a sometimes con- The resulting optimal geometry has two hidden layers
troversial trend and consequently well profitable if rightly composed by 10 ∗  and 5 ∗  neurons, respectively, as
analyzed. In order to prove that, the dataset is general in [
          <xref ref-type="bibr" rid="ref3">3</xref>
          ] and [5]. In addition, to help reducing overfitting
enough to model a variety of diferent shares with more we applied a dropout of 0.2% on each of the two internal
or less the same volatility coeficient (   ), AITA frame- layers [15] and, to introduce non-linearity between layers,
work also proves that the price time series corresponding we used ReLU as the activation function. To estimate
to the selected assets are completely uncorrelated, i.e., the network learning performance during the training
ANF and EOG does not influence each other. Therefore, we use the L1loss function, which measures the mean
we evaluated the synchrony between the two financial absolute error (MAE) between each predicted value and
assets using (i) the Pearson coeficient [14] and the result the corresponding real one. The optimisation algorithm
is 0.28 (see Fig. 3), which confirms that the two stocks used to minimise such loss function during the training
is the adaptive moment (Adam).
        </p>
      </sec>
    </sec>
    <sec id="sec-4">
      <title>5. The Experiment</title>
      <p>After showing that DNNs are the best forecast technique
for our stock prices dataset, we can introduce the novel
trading system of AITA framework.</p>
      <p>The AITA (algorithmic) trading strategy is encoded
in a set of entry and exit trading rules which are in
turn based on the value of a single indicator chosen
from a set of twelve common technical indicators, i.e.,
Simple Moving Average (SMA), Exponential Moving
Average (EMA), Moving Average Convergence
Divergence (MACD), Bollinger Bands (BBs), Stochastics (ST),
William %R (W%R), Momentum (MO), Relative Strength
Index (RSI), Average True Range (ATR), Price
Oscillator (PO) (see [16]), Triple Exponential Moving
Average (TEMA, [17]) and Average Directional Index (ADX).
We also tested some further meaningful combinations
of the above indicators, like in [18], and [19], such as
ST+MO+MACD, PO+W%R and PO+RSI.</p>
      <p>AITA performed a DNN-forwardtesting of the
strategies based on each of the above indicators on the the
30(( () &lt;  
(( () &gt;  
() ) ∨ ( (ℎ) &lt;  
() ) ∨ ( (ℎ) &gt;  
(ℎ))) ∧ (( () &lt;  
(ℎ))) ∧ (( () &gt;  
() ) ∨ ( () &lt;  
() ) ∨ ( () &gt;  
() ))
() ))
(+ &gt; − ) ∧ ( &gt; 25)
(− &gt; + ) ∧ ( &gt; 25)</p>
    </sec>
    <sec id="sec-5">
      <title>6. Conclusions</title>
      <p>days price forecasts following the training date ending
on October 16th, 2021, generated by the DNNs developed
in Section 4.2. In this paper, we propose AITA framework, a stock
mar</p>
      <p>
        Our results show that the best indicator for ANF is ket trading system that exploits deep neural networks
the Triple Exponential Moving Average, whereas the Av- as part of its main components, improving on previous
erage Directional Index is more suitable for EOG. The work [
        <xref ref-type="bibr" rid="ref1">20, 1</xref>
        ].
corresponding trading rules, based on such indicators, The novelty of the approach implemented in AITA
are shown in Figure 6, where () , (ℎ), () , () refer to the framework lies in the indicator selection technique that
OHLC prices, respectively, and  is the current (open- is completely diferent from the usual backtesting or
realing, highest, etc.) price. Such rules were applied to the time forwardtesting. AITA framework determines the
possible future during the forwardtesting. most profitable indicator on the probable future predicted
by a deep neural network trained on historical data.
      </p>
      <p>Table 4 As discussed, neural networks outperform the most
Performance of AITA forwardtesting-selected indicators. common statistical methods in stock price forecasting
predicting future allows for a very accurate selection
#Trades TR ($) ShR SoR CaR of the indicator to be applied, which takes into account
ANF 3 6.126 2.194 3.340 12.403 trends that would be very dificult to capture through
EOG 3 1.374 1.253 2.556 5.814 backtesting.</p>
      <p>To validate this claim, we applied our methodology on
two very diferent assets with medium volatility, and the
results show that our DNN-forwardtesting-based trading
system achieves a profit equal to or higher than that of a
traditional backtesting-based.</p>
      <p>Given the promising potential of this approach, we
will further test its reliability with more refined feature
selection (e.g., [21, 4]) and balancing (buy, sell and hold
trades) strategies (e.g., [22, 23]).</p>
      <p>Finally, since such neural networks can be seen as
black-box decision-making systems, we could also study
the monitoring of machine ethics and the rules [24, 25, 26]
related to their activity.</p>
      <p>Then, we evaluated the profit deriving from the
application of such a strategy on the real data of the 30-day
trading period following October 16th, 2021, having as
starting point a budget of $100 invested in compound
mode. The results are shown in Table 4.</p>
      <p>As a baseline to compare such metrics, we re-evaluated
the same set of technical indicators through the
traditional backtesting technique on the historical data for
the 30 days before October 16th, 2021, to see if it would
result in diferent choices and maybe diferent profits.</p>
      <p>The results show that a trader using backtesting would
choose ADX for the EOG share, as with our
forwardtesting technique, so the profit would be the same in this
case. However, the TEMA indicator would not be chosen
for the ANF share. Indeed, the most promising indicator,
given the past 30 days of market, would be RSI (with
overbought 70 and oversell 30). However, if applied to
the future, it would result in a loss of 1.16%, as shown in
Table 5.</p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          [1]
          <string-name>
            <given-names>I.</given-names>
            <surname>Letteri</surname>
          </string-name>
          ,
          <string-name>
            <given-names>G. D.</given-names>
            <surname>Penna</surname>
          </string-name>
          ,
          <string-name>
            <given-names>G. D.</given-names>
            <surname>Gasperis</surname>
          </string-name>
          ,
          <string-name>
            <given-names>A.</given-names>
            <surname>Dyoub</surname>
          </string-name>
          ,
          <article-title>Dnn-forwardtesting: A new trading strategy validation using statistical timeseries analysis and deep neural networks</article-title>
          ,
          <year>2022</year>
          .
          <article-title>a r X i v : 2 2 1 0 . 1 1 5 3 2</article-title>
          .
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          [2]
          <string-name>
            <given-names>A. A.</given-names>
            <surname>Adebiyi</surname>
          </string-name>
          ,
          <string-name>
            <given-names>A. O.</given-names>
            <surname>Adewumi</surname>
          </string-name>
          ,
          <string-name>
            <given-names>C. K.</given-names>
            <surname>Ayo</surname>
          </string-name>
          ,
          <article-title>Comparison of arima and artificial neural networks models for stock price prediction</article-title>
          ,
          <source>Journal of Applied Mathematics</source>
          <year>2014</year>
          (
          <year>2014</year>
          )
          <fpage>1</fpage>
          -
          <lpage>7</lpage>
          . URL: https: //EconPapers.repec.org/RePEc:hin:jnljam:
          <fpage>614342</fpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          [3]
          <string-name>
            <given-names>I.</given-names>
            <surname>Letteri</surname>
          </string-name>
          ,
          <string-name>
            <given-names>G. D.</given-names>
            <surname>Penna</surname>
          </string-name>
          ,
          <string-name>
            <given-names>G. D.</given-names>
            <surname>Gasperis</surname>
          </string-name>
          ,
          <article-title>Botnet detection in software defined networks by deep learn-</article-title>
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>