=Paper=
{{Paper
|id=Vol-3182/paper14
|storemode=property
|title=Portfolio Optimization and Trading Strategies: a Simulation Approach
|pdfUrl=https://ceur-ws.org/Vol-3182/paper8.pdf
|volume=Vol-3182
|authors=Alessio Emanuele Biondo,Laura Mazzarino,Damiano Rossello
|dblpUrl=https://dblp.org/rec/conf/jurix/BiondoMR21
}}
==Portfolio Optimization and Trading Strategies: a Simulation Approach==
Portfolio Optimization and Trading Strategies: a
simulation approach
*
Alessio Emanuele Biondo1 , Laura Mazzarino2, and Damiano Rossello1,*
1
Department of Economics and Business, University of Catania, Italy
2
Department of Physics and Astronomy, University of Catania, Italy
Abstract
This paper describes a community of investors forming their expectations with heterogeneous strategies
in order to optimize their portfolios by means of a Sharpe ratio maximization. Traders are distinguished
according to their methodology used in forecasting. Twelve acknowledged algorithms of technical
analysis have been implemented to compare portfolios performances and assess profitability of each
technique.
Keywords
Sharpe ratio, Financial markets, Portfolio performance, Simulations
1. Introduction
One of the main purposes of financial traders is to choose the optimal allocation of their money
among possible investments. The first important contribution to the Portfolio Selection Theory
was made by Markowitz [1], who based his studies on a mean-variance model in which each
investor could choose the optimal composition of his portfolio. Despite the scientific importance
of the classical Markowitz model, its adoption by investors has been truly contained due to its
numerous limits, such as the large amount of data required to implement the model and the
high estimation error [2] leading to biased portfolios toward few assets.
A number of models have been proposed to overcome these limits, such as the Capital
Asset Pricing Model (capm) developed by Sharpe [3] and later also by Lintner [4] and Mossin
[5]. Sharpe observed the link between stock price and market index performance, ensuring
a reduction in the amount of data that are used to obtain the efficient portfolio. With capm,
financial assets can be evaluated in a market equilibrium context, in which a risk-free asset is
also considered. One of the assumptions of this model is the homogeneity of investors who
have the same expectations, which leads them to have a combination of two assets only, i.e., the
market portfolio and the risk-free asset (Two-Fund Separation Theorem, [6]). Other attempts
have been made to reduce the estimation error and to improve portfolio performance, as in
Black and Litterman ([7],[8]), who developed a model in which the capm equilibrium portfolio
is used to estimate assets return. The main innovation of their model was the implementation
AMPM’21: First Workshop in Agent-based Modeling & Policy-Making, December 8, 2021, Vilnius, Lithuania
*
Corresponding author. This paper results from the joint cooperation among authors. All text is by aeb and lm;
section 2.1 is by aeb, lm, and dr. Simulative model by aeb. Data collection and simulations by lm.
$ ae.biondo@unict.it (A. E. Biondo); laura.mazzarino@phd.unict.it (L. Mazzarino); rossello@unict.it (D. Rossello)
© 2021 Copyright for this paper by its authors. Use permitted under Creative Commons License Attribution 4.0 International (CC BY 4.0).
CEUR
Workshop
Proceedings
http://ceur-ws.org
ISSN 1613-0073
CEUR Workshop Proceedings (CEUR-WS.org)
of opinions (views) of analysts about the market. Obtained results lead to more stable and
diversified optimal portfolio into the Markowitz model. This model was studied by [9], [10],
[11] and [12], among many others.
Another way to find the optimal portfolio is based on the maximization of a portfolio perfor-
mance index, as the Sharpe ratio ([13],[14]), which is defined as a ratio of the expected portfolio
return relative to his standard deviation. Actually, it was Roy [15] who first suggested a portfolio
valuation strategy based on a risk-return index; later, Sharpe applied his idea to the Markowitz
approach by creating his famous index, which is one of the most used one, despite it is based
on unrealistic hypotheses (among which, for instance, the assumption of Gaussian-distributed
returns).
Since standard deviation is not always an appropriate measure of risk, many alternatives
to the Sharpe ratio have been advanced. Among others, the Treynor ratio [16] substitutes the
standard deviation with the portfolio beta, while the Sortino ratio [17] uses the downside risk
as a risk measure, and the ratio of Bodnar and Zabolotskyy [18] replaces standard deviation
with var. Other portfolio performance indices have also been developed, such as Jensen’s alpha
[19] and many measures based on portfolios weights, as in [20], [21], [22] and [23].
Financial markets can be seen as complex systems ([24], [25]) in which agents cannot be
described as copies of the representative agent [26] endowed with rational expectations ([27],
[28] and [29]), but have heterogeneous features and base their behaviour on a bounded rationality
([30], [31]) and interact with each other ([32], [33]). Agent-based models (abm) allow treatment of
complex systems by putting the evidence on the relevance of interactions and the unpredictable
sequentiality governing the system dynamics. The application of such a methodology to
Economics is called Agent-based Computational Economics (ace), defined by Tesfatsion [34] as
“the computational study of economic processes modelled as dynamic systems of interacting
agents”. This methodology has been fruitfully applied to the study of financial markets, as in
[35], [36], [37], [38], [39], [40], [41], [42], [43], [44] and [45], among others, as surveyed by
LeBaron [46]. It is important to mention the work of [47] in which they used an agent-based
model for a portfolio optimization. In this field, [48] made an experimental study to assess the
effect of complexity on asset trading.
Heterogeneous expectations and behaviours are often studied in related literature, by referring
to the endogeneity of the signal followed to form expectations (i.e., between fundamentalists
-who maintain a view on an exogenous signal- and chartists -who define the expected dynamics
by inferring the trend of past prices). A vast body of references can be reported, among
which: Alfarano et al. [49] created an agent based model in which agents can switch between
fundamentalist and chartist strategies; Alfi et al. [50] analysed price dynamics considering the
presence of forces due to trend adverse and trend following strategies; Flaschel et al. [51] showed
how chartists tend to destabilize the economy; Lux and Marchesi [52] developed a model in
which fundamentalists, optimistic and pessimistic trend followers can switch between strategies,
thus giving rise to more instability independently of expected news; Lux and Marchesi [53]
studied the volatility clustering; Westerhoff [54] and Chiarella et al. [55] considered multi-asset
markets, in which the interaction between them causes clustered volatility and fat tail of asset
returns; Westerhoff and Reitz [56] estimated an heterogeneous agent model underlying the
impact of fundamentalists.
The present paper proposes a model based on the Sharpe ratio maximization, in which agents
form their expectations by following heterogeneous strategies, in order to optimize their portfo-
lio. More precisely, we propose a set of behavioural rules of prediction widely acknowledged
in technical analysis (see [57], [58], [59], [60], [61], [62], [63], [64], [65]): three variants of the
Moving Average Convergence Divergence model - macd; the Relative Strength Index - rsi; Rate
of Change - roc; Crossover; Stochastica; Linear Forecasting; and Compound Forecasting. Finally,
we consider also fundamentals, chartists and the completely random approach, proposed in [66],
[67], [68], [69], as detailed below. All algorithms have been implemented to create portfolios
whose values have been compared in order to assess the profitability of each technique. In
literature, there are some papers that compare the performance of different strategies, among
others: [70],[71],[72],[73],[74],[75]. The paper is organized as follows: section two contains the
model, section three shows results of simulations; section four presents concluding remarks.
2. Model Description
The model simulates different processes of expectations formation, each using a different
technique. Such expected values will be used in Sharpe-ratio optimization procedures by traders
in order to determine the quantities of two assets in the optimal portfolio. All common caveats
of Markowitzian optimization hold: first of all, we assume that each investor allocates all
her wealth in both assets - thus assuming that any possible decision inherent to saving has
been already taken and the investor has decided the amount of resources for financial trading;
secondly, we admit that the whole informative set consists in the available data on market
dynamics - this will have an exception for one category of investors, as it will be detailed below;
finally, we are not considering any interaction or imitation among traders - thus, no exchange
of information or influence is playing here.
2.1. Performances and Sharpe-ratio
The evaluation of portfolio performances is aimed to check whether given return and risk
requirements have been met by fund management. This assessment is usually operated with
reference to asset classes, i.e., major categories of assets (stocks, bonds and money market
instruments), industrial sectors for a portfolio of national equities, or countries for portfolios of
international equities. The measure of portfolio performance should be increasing with respect
to the expected return and decreasing with respect to the estimated risk. The Sharpe ratio (sr) is
one of the most discussed metrics within the class of reward-to-variability measures, as related
to the classical mean-variance model of portfolio selection. In fact, under mild assumptions, the
optimization problem of finding the maximum expected portfolio return, given a target level of
risk as measured by the variance of portfolio return, is equivalent to the maximization of sr.
In the current paper we build a dynamic discrete time model where asset prices vary within
a fixed time horizon [0, 𝑇 ], 𝑇 > 0. In term of performance evaluation, financial institutions
usually split the strategic horizon [0, 𝑇 ] into sub-periods of the same length, and try to predict
the optimal sequence of portfolio weights maximizing its performance at the final date 𝑇 . Then,
let us choose sr as the relevant measure of performance and use subscripts to denote any integer
time 𝑡 ∈ [0, 𝑇 ]. The market price of the 𝑖th asset from time 𝑡 − 1 to time 𝑡 is represented by 𝑝𝑖𝑡 ,
the rate of return is 𝑟𝑡𝑖 = (𝑝𝑖𝑡 − 𝑝𝑖𝑡−1 )/𝑝𝑖𝑡−1 and the investment horizon [0, 𝑇 ] is a sequence of
sub-intervals [𝑡 − 1, 𝑡] for 𝑡 = 1, 2, . . . , 𝑇 .
An sr-optimizer trader maximizes the performance, measured by means of the sr, of her
portfolio, composed by allocating,
∑︀ at time 𝑡, the personal endowment 𝑊𝑡 to two assets, according
to optimal weights 𝑥𝑖𝑡 , with 𝑖 𝑥𝑖𝑡 = 1.
The multi-period optimization problem solved by each trader at each time step can be stated
as:
E(r𝑇 x𝑇 )
argmaxx (1)
sd(r𝑇 x𝑇 )
subject to
(1 + r𝑡 x𝑡 )𝑊𝑡−1 = 𝑊𝑡 𝑡 = 1, . . . , 𝑇 (2)
x𝑡 e = 1 𝑡 = 1, . . . , 𝑇. (3)
The objective function is the sr, i.e., the ratio of the expected return of the portfolio to its
standard deviation. The control variable is x = (x𝑡 )𝑡∈𝑁 , which represents the result of different
trading strategies to be set up for both assets at each time 𝑡 and e is a vector of ones. Eq.(2)
describes capital accumulation, i.e., the decision to invest the wealth’s fraction 𝑊𝑡𝑖 in the asset 𝑖
at time 𝑡 after the asset return 𝑟𝑡𝑖 has been realized. Eq.(3) stands for no-leverage. The objective
function can be written as
(︁ )︁
E 𝑊0 ·((1+r1 x𝑊1 )···(1+r
𝑇
𝑇 x𝑇 ))
− 1
(︁ )︁ ,
𝑊𝑇
sd 𝑊0 ·((1+r1 x1 )···(1+r𝑇 x𝑇 )) − 1
where the final portfolio return is expressed in term of the final wealth. A similar problem,
for the maximization of the final portfolio return by keeping the final variance of portfolio
return lower or equal to a positive given value, has been presented in [76], by using dynamic
programming. Our model describes the sequence of optimization problems executed by all
traders, at each time step 𝑡 ∈ [0, 𝑇 ], aimed at maximizing their sr.
The numerical implementation of problem (1) is then based on a sequence of one-time maxi-
mization problems within the horizon,
max √ x 𝑡 m𝑡
x𝑡 C𝑡 x𝑡
(4)
x𝑡
s.t. x𝑡 e = 1. (5)
where m𝑡 is the vector of expected returns, such that 𝑚𝑖 = E(𝑟𝑡𝑖 ) and C𝑡 = [𝑐𝑖𝑗 𝑡 ] is the
𝑖𝑗 𝑗
covariance matrix of the returns r𝑡 , i.e. 𝑐𝑡 := cov(𝑟𝑡 , 𝑟𝑡 ) for each 𝑖 and 𝑗.
𝑖
The problem can be simplified as follows:
min 1
2 w𝑡 C𝑡 w𝑡 (6)
w𝑡
s.t. w𝑡 e =𝜅 (7)
w𝑡 m𝑡 =1 (8)
𝜅 ⩾ 0. (9)
The switching is based on the scaling w𝑡 := 𝜅 x𝑡 ,, where 𝜅 > 0 is the scaling factor, and
presuming the extra hypotheses that there is a feasible portfolio x𝑡 such that x𝑡 m𝑡 > 0 and the
obvious normalization w𝑡 m𝑡 = 1. The optimal solution is:
m𝑡 C−1
x𝑡 = 𝑡
, (10)
m𝑡 C−1
𝑡 e
where C−1
𝑡 is the inverse of C𝑡 . The quantity of each asset in the portfolio, is
𝑥𝑖𝑡 𝑊𝑡−1
𝑞𝑡𝑖 = , for 𝑡 = 1, . . . , 𝑇 and 𝑖 = 1, 2.
𝑝𝑖𝑡
Since the model designs the existence of 𝑁 heterogeneous agents, we assume different, sub-
jective, probability spaces (Ω𝑠 , 𝐹 𝑠 , P𝑠 ), for 𝑠 = 1, 2, ..., 𝑁 . More precisely, each probability
measure P𝑠 pertains to trader 𝑠-th and it is defined through what he expects from different
hypotheses on market movements. Thus, different traders have the diverse expectations about
future prices and fundamental values. Expectations are then used to define the probabilities
P𝑠 themselves, see [77] and [78]. Ω𝑠 can be considered as individual conception of the ideal
experiment associated to forecasting future prices, while actual experiments only reveal the
level of traders observation. Therefore, for each trader (based on his subjective judgment) there
is a different expectation m𝑡 at time 𝑡. In order to compute it, each trader adopts a given strategy
and make a forecast for the price for the next time step, thus obtaining the expected return.
2.2. Trading strategies
The basic setting is built upon nine different trader types, adopting the following strategies: 1)
fundamentalists; 2) chartists; 3) macd traders (in turn divided in three groups, i.e., 3.1) macd-
basic, 3.2) macd-plus, and 3.3) macd-divergence); 4) crossover traders; 5) rsi traders; 6) random
traders; 7) stochastic traders; 8) roc traders; 9) two econometric forecasting approaches, i.e.,
9.1) linear traders and 9.2) compound traders. Strategies 2), 3), 4), 5), 7) and 8) are based on
descriptions given in relevant related literature (see [57] for further details). In this paper, for
each strategy, is considered a single trader who will decide to buy if the expected price is higher
than the current market price and sell in the opposite case.
2.2.1. Fundamentalists
Fundamentalists consider the fundamental value of the asset, 𝐹 𝑉𝑡 , as the relevant indicator to
infer the dynamics of the price time series. Such a fundamental value is, according to their view,
the true value of the asset, which embeds the “correct” evaluation of all relevant information and
also includes the effects of the dividend yields. It is defined as an exogenous random variable
whose dynamics may be assumed as a martingale-dividend-driven. Thus, the expected price,
for a fundamentalist can be written as:
𝐹 𝑉𝑡 = 𝐹 𝑉𝑡−1 + D𝑡 (11)
where 𝐹 𝑉0 = 𝜑 ¯ and D𝑡 is a random variable extracted from a normal distribution with zero
mean and standard deviation 𝜎𝐹 , which is assumed to follow a random walk and represent the
yearly yield of the asset. Thus the expectation of a fundamentalist is:
𝑒𝑥𝑝
𝐹 𝑝𝑡 = 𝐹 𝑉𝑡 + Θ𝐹 (12)
where Θ𝐹 is randomly chosen in the interval (−𝜃𝐹 , 𝜃𝐹 ), in order to account for the heterogeneity
of investors. This implies that when the expected price is greater (resp., smaller) than the
observed current market price she decides to buy (resp., sell), because she is expecting that the
asset always converges to its fundamental.
2.2.2. Chartists
The second type of investos has been designed as momentum trader. Momenutm is the name
of a very broad category of investment strategies, based on the observation of past values of
financial time series. In particular, a very general definition of a momentum oscillator is given
by:
𝑀 = 𝑝𝑡 − 𝑝𝑡−𝑥 (13)
where the comparison between the current market price 𝑝𝑡 and the past price registered a given
𝑥 number of periods ago, 𝑝𝑡−𝑥 is used to infer the future dynamics. In particular, the basic
momentum strategy is based on the sign changes of 𝑀 :
− → + buy
{︂
(14)
+ → − sell
Related literature calls "chartists” one of possible expressions of such a kind of strategy: a group
of technical analysts who found their trading decision on the observation of trends and past
dynamics of financial prices. More precisely, each of them refers to a time window, whose
length is individually heterogeneous, and compute a reference value 𝑅𝑉𝑡 , computed at any
𝑡 by averaging prices included in a time window of length 𝑆, different for each chartist and
randomly chosen in the interval (2, 𝑇𝑚𝑎𝑥 ):
𝑡
1 ∑︁
𝑅𝑉𝑡 = 𝑝𝑗 . (15)
𝑆
𝑗=𝑡−𝑆
Thus, the expectation determined by the chartist is
𝑒𝑥𝑝
𝐶 𝑝𝑡 = 𝑝𝑡 ± (𝑝𝑡 − 𝑅𝑉𝑡 ) (16)
where the choice of setting ± in the formula depends on whether 𝑝𝑡 is respectively greater or
less than 𝑅𝑉𝑡 .
2.2.3. macd traders
The set of financial oscillators is very wide and a complete survey of them goes far beyond the
scope of the present paper. Nonetheless, the model includes also other three kinds of traders
based on technical analysis adopting the so-called Moving-Average-Convergence-Divergence
(aka macd) strategy, developed by Gerald Appel. Such an oscillator combines exponential
moving averages, 𝐸𝑀 𝐴𝑑 , referred to different time intervals, 𝑑.
The basic computation is considered as the difference between the averages over 𝑑 = 12 and
𝑑 = 26 days:
𝑀 𝐴𝐶𝐷 = 𝐸𝑀 𝐴12𝑑 − 𝐸𝑀 𝐴26𝑑 (17)
𝑡
where 𝐸𝑀 𝐴𝑑𝑡 = 𝐸𝑀 𝐴𝑑𝑡−1 + 𝑤 𝑝𝑡 − 𝐸𝑀 𝐴𝑑𝑡−1 , with 𝐸𝑀 𝐴𝑑0 = 𝑝𝑖 /𝑑, and 𝑤 = 𝑑+1
2
.
(︀ )︀ ∑︀
𝑖=𝑡−𝑑
Oscillations of the two moving averages are different: the wider the days interval over which it
is calculated, the slower it moves. Thus the slower is used to observe the trend, whereas the
faster provides the trigger signal: when the latter crosses the former from the bottom (top),
it is a bullish (bearish) signal. Such an oscillator is used according to three different versions,
basically responding to the same rationale with different levels of refinement and data usage.
The first, henceforth named macd-basic, is:
𝑀 𝐴𝐶𝐷 > 0 → buy
{︂
(18)
𝑀 𝐴𝐶𝐷 < 0 → sell
The second one, henceforth named macd-plus, is augmented by a third moving average, com-
puted over an interval of 𝑑 = 9 days, 𝐸𝑀 𝐴9𝑑 , adopted as the trigger:
𝑀 𝐴𝐶𝐷 > 𝐸𝑀 𝐴9𝑑 → buy
{︂
(19)
𝑀 𝐴𝐶𝐷 < 𝐸𝑀 𝐴9𝑑 → sell
Finally, the third version, henceforth named macd-divergence, is based on a more detailed data
observation, which is based on divergences. In particular, in a windowed period of past days,
the original time series of the asset price and the correspondent macd time series are compared.
If either the two maximum points or the two minimum points in the interval of both series are
oriented in the same direction of the trend in the same interval, then there is not a divergence.
If, instead, a divergence exists, then it serves as a trigger. Let us indicate by 𝛼𝑆 the slope of the
trend inferred by the time series and by 𝛼𝑀 the slope of the line joining the two local extrema
included in the considered time window. The signalling role on the trading strategy played by
the divergence can be described as:
𝛼𝑆 < 0 ∧ 𝛼𝑀 > 0 → buy
{︂
(20)
𝛼𝑆 > 0 ∧ 𝛼𝑀 < 0 → sell
2.2.4. Crossover traders
The Crossover method, inspired by the triple crossover method mentioned for the first time
by R.C. Allen ([79], [80]), requires exponential moving averages for different time periods (d),
𝐸𝑀 𝐴𝑑 , as for the case of macd strategies. More precisely, this method considers three moving
averages, with 𝑑 = 12, 𝑑 = 20 and 𝑑 = 26, calculated as above described. A buy signal will
occur in a downtrend, in which the shorter average (12 day) is bigger than both the medium (20
day) and the longer ones (26 day). A sell signal, instead, will occur in the opposite situation, in
which the longer average is the biggest one.
𝐸𝑀 𝐴26𝑑 < 𝑚𝑖𝑛(𝐸𝑀 𝐴20𝑑 ; 𝐸𝑀 𝐴12𝑑 ) → buy
{︂
(21)
𝐸𝑀 𝐴26𝑑 > 𝑚𝑎𝑥(𝐸𝑀 𝐴20𝑑 ; 𝐸𝑀 𝐴12𝑑 ) → sell
2.2.5. rsi traders
Inspired by the Relative Strength Index, introduced by Wilder [62], our corresponding trading
strategy considers once a time window of the recent past 𝑆 = 30 values of the time series to
infer possible forecasts on future dynamics. In particular, the index is computed as
100
𝑅𝑆𝐼 = 100 − (22)
1 + 𝑅𝑆
where: 𝑅𝑆 = 𝜇↑ /𝜇↓ ; 𝜇↑ = (1/𝑆) 𝑆𝑘=1 𝑝𝑘 ∀𝑝𝑠 > 𝑝𝑠−1 ; 𝜇↓ = (1/𝑆) 𝑆𝑘=1 𝑝𝑘 ∀𝑝𝑠 < 𝑝𝑠−1 ;
∑︀ ∑︀
and 𝐾 ≤ 𝑆. The simplified strategy here adopted is based on the comparison between the
rsi series referred to the entire original price series and the rsi series referred to the given
interval of observation. The local trend of the index within the given time window and the
global one may exhibit a divergence or not. If a divergence exists, the difference between the
two highest local peaks is added (resp. subtracted) to the current price if the trend of the global
rsi is increasing (resp. decreasing), in order to create the expectation.
2.2.6. Random traders
The role of random traders has been investigated in several contributions under the names “zero-
intelligence”, “noise”, etc. They are defined as traders who decide when/how to invest at random.
For such a reason, they have been used as the representation of the lack on influence/imitation
in order to challenge the normal financial dynamics and show interesting insights to dampen
market fluctuations, i.e., reducing volatility. In the present model, random traders are the sole
group that will not use a portfolio optimization: they will simply decide whether to buy or
to sell by tossing a fair coin. The quantity of both assets to have is extracted randomly by
the algorithm governing the simulations, in such a way that both weights, 𝑤1 ∈ [0, 1] and
𝑤2 ∈ [0, 1], always sum up to 1.
2.2.7. Stochastic
The stochastic oscillator, popularized by George Lane, is based on the idea that when prices rise,
closing prices tend to approach the upper end of the price range. The opposite occurs where
prices fall. We present a simplified computational version of this method, that we implement as
follow. Recent past values of prices are selected in order to compute two indexes:
𝐶 − 𝐿5 𝐻3
𝐾 = 100 · and 𝐷 = 100 · (23)
𝐻5 − 𝐿5 𝐿3
where: 𝐶 is the last price; 𝐿5 is the minimum value in the last 5 days; 𝐻5 is the maximum
value in the last 5 days; 𝐻3 is the sum of the last 3 days of 𝐶 − 𝐿5; 𝐿3 is the sum of the last 3
days of 𝐻5 − 𝐿5. The strategy can therefore be described as:
⎧
⎨ 𝐾 > 80 ∧ 𝐷 > 80
20 < 𝐾 < 80 ∧ 𝐷 > 80 → buy (24)
𝐾 > 80 ∧ 20 < 𝐷 < 80
⎩
⎧
⎪
⎪ 20 < 𝐾 < 80 ∧ 20 < 𝐷 < 80
𝐾 < 20 ∧ 20 < 𝐷 < 80
⎨
→ sell (25)
⎪
⎪ 20 < 𝐾 < 80 ∧ 𝐷 < 20
𝐾 < 20 ∧ 𝐷 < 20
⎩
2.2.8. roc traders
The rate of change (roc) is a ratio which assumes increasing values in cases of an upward trend
and decreasing values in cases of downward trend. It is computed as follows:
𝑉
𝑅𝑂𝐶 = (26)
𝑉𝑥
where: 𝑉 is the latest close price and 𝑉 𝑥 is the former closing price. Once defined a given
threshold 𝑐 = 0.05, roc traders’ strategy has been simply modelled as follows:
𝑟𝑜𝑐 ≥ 1 + 𝑐 → buy
{︂
(27)
𝑟𝑜𝑐 < 1 + 𝑐 → sell
2.2.9. Econometrician forecasters
Two last techniques adopt ols estimation in order to predict future prices, by means of a linear
and a compound model. In the first case, the prediction is obtained by:
𝑌 =𝑎+𝑏·𝑡 (28)
where 𝑎 and 𝑏 are, respectively, the constant and the slope of the trend-line, and 𝑡 indicates
time, thus implying a constant growth.
The second approach assumes, instead, that the variable grows by a constant proportion each
period. In this case, the prediction is obtained by:
𝑌 = 𝑐 · 𝑑𝑡 (29)
where 𝑐 and 𝑑 indicate a constant and the growth proportion, which could be interpreted as
𝑑 = 1+ growth-rate, and 𝑡 indicates time.
Table 1
Time series used to perform simulations.
asset name (from) asset name (from) asset name (from)
3M (2/1/73) General Electric (2/1/73) Pfizer (2/1/73)
Accenture (19/7/01) General Motors (18/11/10) Philip Morris (17/3/08)
Adidas (17/11/95) Goodyear (2/1/73) Philips (1/1/73)
Adobe Systems (24/11/86) Heineken (1/1/73) Samsung (2/7/84)
Alphabet (19/8/04) Henkel (2/7/96) Royal Dutch Shell (1/1/73)
American Express (2/1/73) Hewlett-Packard (2/1/73) Siemens (1/1/73)
Apple (12/12/80) Intel (2/1/73) Sony (1/1/73)
AT&T (21/11/83) Intesa San-Paolo (1/1/73) Telefonica (2/3/87)
Barclays (30/12/64) Johnson&Johnson (2/1/73) Tesla (29/6/10)
BMW (1/1/73) JPMorgan (2/1/73) Texas Instruments (2/1/73)
Cisco (16/2/90) EssilorLuxottica (28/10/75) Thomson Reuters (12/6/02)
Colgate/Palmolive (2/1/73) Microsoft (13/3/86) Netflix (23/5/02)
Daimler (26/10/98) Deere&Company (2/1/73) Total (1/1/73)
Danone (1/1/73) Morgan/Stanley (23/2/93) Volkswagen (1/1/73)
Deutsche Telekom (15/11/96) Nestlé (1/1/73) Walt Disney (2/1/73)
Exxon (2/1/73) Oracle (12/3/86) Amazon (15/5/97)
Ford Motor (2/1/73) Starbucks (26/6/92)
3. Simulations
The model has been engineered as a sort of back-testing framework in which a fictitious reality
is simulated. In Table 1 time series used for simulations are listed, each reporting the initial
date of the time series. The simulation considers all possible couples of assets and defines a
financial market where traders try to get the highest gain in terms of portfolio value. For each
couple, the length of the simulation is set to the length of the shortest time-series, in such a
way that at every simulation step, traders will always have newly disclosed prices for both
assets. In such a configuration, the simulated market will operate as if investors were living
in the past, thus making the measurement of performance possible, while a sort of financial
race is run among traders, in order to discover which strategy accumulates the highest wealth.
Each trader adopts a strategy and cannot change it. At the beginning, all traders are given the
same amount of money, 𝑚𝑖 = 𝑚 ¯ = 250. By means of their trading decision they will trade
assets, thus computing their wealth, 𝑤𝑖 , possibly greater or smaller than the initial endowment.
Further, traders are assumed to be marginal with respect to the market, which means that they
will always find the possibility to negotiate assets as they want. In other words, they will not
be constrained to buy and sell selected quantities. If a trader goes bankruptcy, he will not be
replaced and this will correspond to the worst outcome
(i.e., Δ𝑤𝑖 = −100%).
Unlike fundamentalists, all other types of traders considered observe past values of assets to
take decisions. In particular, most of these traders are momentum traders and we assume that
they must have at least 30 data available for each asset. Instead, econometrician forecasters
operate by observing a wider time window of at least 180 data.
Table 2
Ranking of strategies with daily data
strategies 1st 2nd 3rd failures
Stochastica 330 225 141 77
Crossover 203 214 164 67
Fundamentalists 202 160 149 60
rsi 175 89 168 56
rnd 94 97 92 160
macd-divergence 79 80 99 129
Chartists 69 72 96 126
macd-basic 33 86 112 118
roc 16 31 64 208
macd-plus 10 32 95 106
Linear 10 25 28 398
Compound 4 14 17 557
Figure 1: Occurrences for various strategies in the first position in the ranking or failures with daily
data.
3.1. Results
Results reported in Table 2 show the number of times that each strategy scored the first, the
second and the third in the ranking and the amount of times they fail. Fig.1 compares how
many times the strategies have placed first and fail while Fig.2 shows how many times they
arrived in the first three positions of the 1225 rankings analysed.
More in detail, stochastica strategy have been place in the top three position of the ranking
696 times, followed by the crossover strategy with 581 placements, fundamentalists with 511
and the rsi with 532. Then we find the rnd with 283 placements and macd-divergence with
Figure 2: Number of times in which strategies have been placed in the top 3 positions with daily data.
258, continuing with the chartists that have been in the top three positions 237 times and
the macd-basis strategy with 231 placements. The roc with 111 times follows the macd-plus
strategy with 133 placements. At the end there are the two econometric forecasting approaches,
linear (59) and compound (37).
Data show that, overall, the stochastica strategy performed the best and that the worst are,
instead, the econometric forecasting approaches.
For each couple of assets, simulations give twelve vectors containing portfolio values obtained
by each strategy. The volatility of the best performing strategy has then been computed as
the standard deviation of the distribution of portfolio values associated to that strategy for all
occurrences in which it has ranked first. Fig.3 compares the volatility of all winning strategies,
thus showing that even best performing ones manifest wide variability across the distribution
of results.
We carried out the same analysis considering also the intraday data, more specifically the
hourly data and data with a frequency of five minutes and one minute. All data were downloaded
using Refinitiv’s Eikon ©, and the intraday series were considered with their maximum available
length, corresponding to the last year for hourly data and the last three months for five minutes
and one minute data. For data with a frequency of five minutes and one minute, the given
threshold for the roc strategy was reduced (𝑐 = 0.01).
For hourly data we found the following results,reported in Table 3, Fig. 4 and Fig. 5.
Observing these results, we note that chartists reached the first position more times than the
others, but by observing the number of times in which strategies have reached the top three
and last positions, it is noted that the strategy that has performed better overall is the crossover,
which it finished in the top three 468 times and fail 397 times. The worst are confirmed to be
macd-plus and the econometrician forecasters, with compound strategy that failed 1118 times
out of 1225.
For data with a frequency of 5 minutes we found the following results, reported in Table 4,
Figure 3: Volatility of portfolio values for different strategies with daily data.
Table 3
Ranking of strategies with hourly data
strategies 1st 2nd 3rd failures
Stochastica 97 120 102 469
Crossover 157 186 125 397
Fundamentalists 127 82 119 125
rsi 170 138 89 489
rnd 77 166 127 392
macd-divergence 106 160 122 319
Chartists 207 66 79 448
macd-basic 90 129 166 256
roc 129 39 62 634
macd-plus 11 21 84 523
Linear 48 74 86 651
Compound 5 10 11 1118
Fig. 6 and Fig. 7.
In this case fundamentalists reach top three positions several times (482 times) and failed
only 237 times. The crossover strategy didn’t get many first places but overall it finished in the
top three 345 times. Excellent results were achieved by macd-basic which ranks 490 times in
the top three strategies and failed only 342 times.
For data with a 1-minute frequency we found the following results, reported in Table 5, Fig.
8 and Fig. 9.
Figure 4: Occurrences for various strategies in the first position in the ranking or failures with hourly
data.
Figure 5: Number of times in which strategies have been placed in the top 3 positions with hourly data.
The best performances are those of fundamentalists (in the top three positions 387 times and,
again, with the least number of failures 211) and once again the macd-basic strategy which
reaches the top three positions 480 times . Chartists have reached the first position several
times (206) but have failed many times (631). The worst is the compound strategy, that failed
1210 times.
Table 4
Ranking of strategies (5 minutes)
strategies 1st 2nd 3rd failures
Stochastica 96 118 116 620
Crossover 74 159 112 603
Fundamentalists 214 115 153 237
rsi 121 119 84 626
rnd 100 172 120 549
macd-divergence 174 166 75 455
Chartists 150 44 58 696
macd-basic 163 130 197 342
roc 78 31 48 831
macd-plus 7 32 84 664
Linear 47 70 57 841
Compound 1 4 2 1196
Figure 6: Occurrences for various strategies in the first position in the ranking or failures with (5
minutes).
4. Concluding remarks
In this paper we presented a model testing different strategies, based on technical analysis, of
expectations formation and show how they affect performances of investors.
The proposed approach lies on back-testing simulations over true data. Data is used with
reference to each day, as agents experience each time step ignoring the future. Thus, they
choose on the basis of their expectations only, thus making it possible to measure performance
of their portfolio investments, as in a financial race. Portfolios are obtained by considering all
Figure 7: Number of times in which strategies have been placed in the top 3 positions (5 minutes).
Table 5
Ranking of strategies (1 minute)
strategies 1st 2nd 3rd failures
Stochastic 131 156 99 584
Crossover 116 124 126 572
Fundamentalists 130 109 148 211
rsi 158 127 81 627
rnd 72 175 152 540
macd-divergence 115 161 112 484
Chartists 206 31 77 631
macd-basic 156 170 154 346
roc 92 31 48 829
macd-plus 4 31 65 598
Linear 44 48 52 840
Compound 0 1 2 1210
possible couples of the 50 assets.
Simulations have been devoted to investigate two sets of aspects. First of all, the performance
of different strategies has been analysed. For each couple of assets, a ranking of strategies was
identified on the basis of portfolio values. Overall, results show that there are no concordant
rankings of various strategies at different time lengths resolution. Thus, for instance, a winning
strategy in simulations with daily data reveals to loose if used with infra-day data. This provides
evidence that optimal strategies are more a desire of investors than an actual results. The reason
why financial success can be reached in speculative investments must depend on occasional
reasons and not on the chosen strategy. In other words, the complexity of the system prevents
Figure 8: Occurrences for various strategies in the first position in the ranking or failures with (1
minute).
Figure 9: Number of times in which strategies have been placed in the top 3 positions (1 minute).
any forecast and past trends, elaborated as much as algorithm and experienced traders want,
need not be replicated.
Secondly, we analysed the volatility of the best performing strategy and the instability of
the market. Consequently to our first finding, we found that even best performing strategies
manifest wide variability. One can conclude that the variability of results is not simply linked
to the goodness of the adopted strategy. Something lying between the lines makes all strategies
uncertain and potentially harmful.
The methodological innovation to the literature proposed in this paper is that possible
strategies of actual trading have been compared by agent-based simulations. Although here the
model is limited to portfolio composed by two assets only, further research will be dedicated to
this topic, by considering interactions and contagion among traders and a ticker multi-asset
settings to determine the weight of big traders, such as hedge funds and institutional investors,
on the overall market dynamics.
References
[1] H. Markowitz, Portfolio selection, Journal of Finance, 7 (1952) 77–91.
[2] V. Chopra, W. Ziemba, The effect of errors in means, variances, and covariances on optimal
portfolio choice, The Journal of Portfolio Management,19 2 (1993) 6–11.
[3] W. Sharpe, Capital asset prices: a theory of market equilibrium under condition of risk,
Journal of Finance,19 (1964).
[4] J. Lintner, The valuation of risk assets and the selection of risky investments in stock
portfolios and capital budgets, Review of Economics and Statistics, 47 (1965) 13–37.
[5] J. Mossin, Equilibrium in a capital asset market, Econometrica 34 (1966) 768–783.
[6] J. Tobin, Liquidity preference as behavior towards risk, The review of economic studies
25 (1958) 65–86.
[7] F. Black, R. Litterman, Global portfolio optimization, Journal of Fixed Income (1991).
[8] F. Black, R. Litterman, Global portfolio optimization, Financial Analysts Journal (1992).
[9] J. Walters, The black-litterman model in detail (2011).
[10] Satchell, Scowcroft, A demystification of the black-litterman model: Managing quantitative
and traditional portfolio construction, The Journal of Asset Management (2000).
[11] A. Meucci, Beyond black-litterman in practice: A five-step recipe to input views on non-
normal markets, Working paper (2006).
[12] T. Idzorek, A step-by-step guide to the black-litterman model, incorporating user-specified
confidence levels, Working paper (2005).
[13] W. F. Sharpe, Mutual fund performance, The Journal of business 39 (1966) 119–138.
[14] W. F. Sharpe, The sharpe ratio, Journal of portfolio management 21 (1994) 49–58.
[15] A. D. Roy, Safety first and the holding of assets, Econometrica: Journal of the econometric
society (1952) 431–449.
[16] J. L. Treynor, How to rate management of investment funds, Harvard Business Review 43
(1965) 63–75.
[17] L. Sortino, F.A. anf Price, Performance measurement in a downside risk framework, Journal
of Investing 3 (1994) 59–64.
[18] T. Bodnar, T. Zabolotskyy, Maximization of the sharpe ratio of an asset portfolio in the
context of risk minimization, Economic Annals-XXI (2013).
[19] M. C. Jensen, The performance of mutual funds in the period 1945-1964, The Journal of
finance 23 (1968) 389–416.
[20] B. Cornell, Asymmetric information and portfolio performance measurement, Journal of
Financial Economics 7 (1979) 381–390.
[21] T. E. Copeland, D. Mayers, The value line enigma (1965–1978): A case study of performance
evaluation issues, Journal of Financial Economics 10 (1982) 289–321.
[22] M. Grinblatt, S. Titman, R. Wermers, Momentum investment strategies, portfolio perfor-
mance, and herding: A study of mutual fund behavior, The American economic review
(1995) 1088–1105.
[23] L. Zheng, Is money smart? a study of mutual fund investors’ fund selection ability, the
Journal of Finance 54 (1999) 901–933.
[24] R. N. Mantegna, H. E. Stanley, Introduction to econophysics: correlations and complexity
in finance, Cambridge university press, 1999.
[25] M. Gallegati, M. G. Richiardi, Agent based models in economics and complexity., 2009.
[26] A. M. Sbordone, A. Tambalotti, K. Rao, K. J. Walsh, Policy analysis using dsge models: an
introduction, Economic policy review 16 (2010).
[27] J. F. Muth, Rational expectations and the theory of price movements, Econometrica (29)
(1961).
[28] T. J. Sargent, N. Wallace, Some unpleasant monetarist arithmetic, Federal Reserve Bank of
Minneapolis Quarterly Review (1981).
[29] J. Lucas, Robert E., Expectations and the neutrality of money, Journal of Economic Theory
(4) (1972).
[30] H. A. Simon, A behavioral model of rational choice, The quarterly journal of economics
69 (1955) 99–118.
[31] H. A. Simon, Models of man; social and rational. (1957).
[32] A. Leijonhufvud, Information and coordination: essays in macroeconomic theory, Oxford
University Press, USA, 1981.
[33] A. Leijonhufvud, Agent-based macro, Handbook of computational economics 2 (2006)
1625–1637.
[34] L. Tesfatsion, Agent-based computational economics: a constructive approach to economic
theory, In: Tesfatsion, L., Judd, K. (Eds.), Handbook of Computational Economics (II) (2006)
831–880.
[35] A. Beja, M. B. Goldman, On the dynamic behavior of prices in disequilibrium, The Journal
of Finance 35 (1980) 235–248.
[36] W. A. Brock, C. H. Hommes, A rational route to randomness, Econometrica: Journal of
the Econometric Society (1997) 1059–1095.
[37] W. A. Brock, C. H. Hommes, Heterogeneous beliefs and routes to chaos in a simple asset
pricing model, Journal of Economic dynamics and Control 22 (1998) 1235–1274.
[38] C. Chiarella, The dynamics of speculative behaviour, Annals of operations research 37
(1992) 101–123.
[39] C. Chiarella, X. He, et al., Asset price and wealth dynamics under heterogeneous expecta-
tions, Quantitative Finance 1 (2001) 509–526.
[40] R. H. Day, W. Huang, Bulls, bears and market sheep, Journal of Economic Behavior &
Organization 14 (1990) 299–329.
[41] R. Franke, R. Sethi, Cautious trend-seeking and complex asset price dynamics, Research
in Economics 52 (1998) 61–79.
[42] C. H. Hommes, Financial markets as nonlinear adaptive evolutionary systems (2001).
[43] T. Lux, Herd behaviour, bubbles and crashes, The economic journal 105 (1995) 881–896.
[44] T. Lux, The socio-economic dynamics of speculative markets: interacting agents, chaos,
and the fat tails of return distributions, Journal of Economic Behavior & Organization 33
(1998) 143–165.
[45] E. Zeeman, On the unstable behavior of stock exchanges, Journal of Mathematical
Economics 1 (1974) 39–49.
[46] B. LeBaron, Agent-based computational finance, Handbook of computational economics
2 (2006) 1187–1233.
[47] Y. Orito, Y. Kambayashi, Y. Tsujimura, H. Yamamoto, An agent-based model for portfolio
optimization using search space splitting, in: Multi-Agent Applications with Evolutionary
Computation and Biologically Inspired Technologies: Intelligent Techniques for Ubiquity
and Optimization, IGI Global, 2011, pp. 19–34.
[48] B. I. Carlin, S. Kogan, R. Lowery, Trading complex assets, The Journal of finance 68 (2013)
1937–1960.
[49] S. Alfarano, T. Lux, F. Wagner, Estimation of agent-based models: the case of an asymmetric
herding model, Computational Economics 26 (2005) 19–49.
[50] V. Alfi, A. De Martino, L. Pietronero, A. Tedeschi, Detecting the traders’ strategies in
minority–majority games and real stock-prices, Physica A: Statistical Mechanics and its
Applications 382 (2007) 1–8.
[51] P. Flaschel, F. Hartmann, C. Malikane, C. R. Proaño, A behavioral macroeconomic model of
exchange rate fluctuations with complex market expectations formation, Computational
Economics 45 (2015) 669–691.
[52] T. Lux, M. Marchesi, Scaling and criticality in a stochastic multi-agent model of a financial
market, Nature 397 (1999) 498–500.
[53] T. Lux, M. Marchesi, Volatility clustering in financial markets: a microsimulation of
interacting agents, Int. J. Theor Appl Finance (4) (2000) 675–702.
[54] F. H. Westerhoff, Multiasset market dynamics, Macroeconomic Dynamics 8 (2004) 596–616.
[55] C. Chiarella, R. Dieci, X.-Z. He, Heterogeneous expectations and speculative behavior in a
dynamic multi-asset framework, Journal of Economic Behavior & Organization 62 (2007)
408–427.
[56] F. H. Westerhoff, S. Reitz, Nonlinearities and cyclical behavior: the role of chartists and
fundamentalists, Studies in Nonlinear Dynamics & Econometrics 7 (2003).
[57] J. Murphy, Technical Analysis of the Financial Markets: A Comprehensive Guide to Trading
Methods and Applications, New York Institute of Finance, 1999.
[58] G. Appel, Technical analysis: power tools for active investors, Financial Times Prentice
Hall, 1999.
[59] T. T.-L. Chong, W.-K. Ng, Technical analysis and the london stock exchange: testing the
macd and rsi rules using the ft30, Applied Economics Letters 15 (2008) 1111–1114.
[60] T. T.-L. Chong, S. H.-S. Cheng, E. N.-Y. Wong, A comparison of stock market efficiency of
the bric countries, Technology and Investment 1 (2010) 235–238.
[61] N. Ülkü, E. Prodan, Drivers of technical trend-following rules’ profitability in world stock
markets, International Review of Financial Analysis 30 (2013) 214–229.
[62] J. W. Wilder, New Concepts in Technical Trading Systems, Trend Research, 1978.
[63] R. A. Levy, Relative strength as a criterion for investment selection, The Journal of Finance
22 (1967) 595–610.
[64] D. Eric, G. Andjelic, S. Redzepagic, Application of macd and rsi indicators as functions of
investment strategy optimization on the financial market, Zbornik radova Ekonomskog
fakulteta u Rijeci: časopis za ekonomsku teoriju i praksu 27 (2009) 171–196.
[65] R. Rosillo, D. De la Fuente, J. A. L. Brugos, Technical analysis and the spanish stock
exchange: testing the rsi, macd, momentum and stochastic rules using spanish market
companies, Applied Economics 45 (2013) 1541–1550.
[66] A. E. Biondo, A. Pluchino, A. Rapisarda, The beneficial role of random strategies in social
and financial systems, Journal of Statistical Physics 151 (2013) 607–622.
[67] A. E. Biondo, A. Pluchino, A. Rapisarda, D. Helbing, Are random trading strategies more
successful than technical ones?, PloS one 8 (2013) e68344. URL: https://doi.org/10.1371/
journal.pone.0068344.
[68] A. E. Biondo, A. Pluchino, A. Rapisarda, D. Helbing, Reducing financial avalanches by
random investments, Phys. Rev. E 88 (2013) 062814. URL: https://link.aps.org/doi/10.1103/
PhysRevE.88.062814. doi:10.1103/PhysRevE.88.062814.
[69] A. E. Biondo, A. Pluchino, A. Rapisarda, Micro and macro benefits of random investments
in financial markets, Contemporary Physics 55 (2014) 318–334.
[70] N. H. Hung, Various moving average convergence divergence trading strategies: a com-
parison, Investment management and financial innovations (2016) 363–369.
[71] E. Pätäri, M. Vilska, Performance of moving average trading strategies over varying stock
market conditions: the finnish evidence, Applied Economics 46 (2014) 2851–2872.
[72] Y.-C. Chiang, M.-C. Ke, T. L. Liao, C.-D. Wang, Are technical trading strategies still
profitable? evidence from the taiwan stock index futures market, Applied Financial
Economics 22 (2012) 955–965.
[73] D. Vezeris, T. Kyrgos, C. Schinas, Take profit and stop loss trading strategies comparison
in combination with an macd trading system, Journal of Risk and Financial Management
11 (2018) 56.
[74] W. Brock, J. Lakonishok, B. LeBaron, Simple technical trading rules and the stochastic
properties of stock returns, The Journal of finance 47 (1992) 1731–1764.
[75] C. A. Ellis, S. A. Parbery, Is smarter better? a comparison of adaptive, and simple moving
average trading strategies, Research in International Business and Finance 19 (2005)
399–411.
[76] D. Li, W.-L. Ng, Optimal dynamic portfolio selection: Multiperiod mean-variance formula-
tion, Mathematical finance 10 (2000) 387–406.
[77] R. Jeffrey, Subjective probability: The real thing, Cambridge University Press, 2004.
[78] P. Whittle, Uncertainty, intuition and expectation, in: Probability via Expectation, Springer,
1992, pp. 1–12.
[79] R. C. Allen, How to Build a Fortune in Commodities, Windsor Books, Brightwaters, NY,
1972.
[80] R. C. Allen, How to Use the 4-Day, 9-Day and 18-Day Moving Averages to Earn Larger
Profits from Commodities, Best Books, 1974.