Performance of Simple Deterministic Stock Trading Strategies Using an Agent-Based Modelling Approach ()
1. Introduction
Regardless of the level of investors’ wealth, all investors have a pre-determined amount of funds to apply in the stock market. Deciding how the money is going to be applied to obtain the highest possible yield is therefore essential. In principle, there are two main types of investors in the market: those that employ fundamental analysis and those that rely on technical analysis. Technical analysis can be defined as methods to forecast price movements by utilising past performance (Nti et al., 2020). This contrasts with fundamental analysis, in which the investor looks at the companies’ fundamental value and trades after that (Nti et al., 2020).
In technical analysis, developing better computers has allowed quantitative strategies to trade stocks continuously. Different methods can be back-tested using historical data to determine their yield in the stock market. By deploying the strategy in a simulated environment using real-life data, the investor can decide which trading strategy to choose before investing any real money.
Park & Irwin (2007) explain that traders and academics have different views of technical analysis. They explain that this dissonance is derived from the acceptance of the efficient market hypothesis (stating that the relation of past market movement to the future is pointless since other factors are also influencing price movement) and empirical findings of the technical analysis’s performance in the stock market.
Agent-based models (ABMs) are computational systems that simulate the actions and interactions of autonomous agents. Each agent can represent an individual or a group of people. The agents can be used to test their effects in a market situation. The ABM can be both deterministic and stochastic, have a variable complexity range in their actions, and interact with or not interact with each other in the market. ABMs have previously been used in various approaches in the financial market, from simulating the market dynamics and trading strategies in the stock market (Chakraborti et al., 2011).
The Oslo Stock Exchange (OSE) features a variety of stocks within sectors such as energy, aquaculture, and finance. ABM can be used to explore how different trading strategies affect returns. The OSE is a relatively small stock exchange, with total assets estimated at approximately 299.55 billion and a traded volume of 4.6 billion. At the OSE, companies related to fossil fuels and aquaculture tend to determine the overall performance of the exchange.
This paper investigates the return of four simple deterministic trading strategies deployed by Agent-Based Modelling to evaluate their performance in trading stocks at the OSE. The various agents were tested with different access to historical data and sensitivity to trading costs. This analysis can be used to determine which, if any, strategy should be deployed as a quantitative trading strategy in the market.
2. Methods
2.1. Data
Data for this paper was collected using the Yahoo Finance API deployed using the R programming language to retrieve historical stock prices. The data consists of daily closing prices for eight stocks on the OSE index: Mowi ASA (MOWI.OL), Equinor ASA (EQNR.OL), Gjensidige Forsikring ASA (GJF.OL), DNB ASA (DNB.OL), SalMar ASA (SALM.OL), Yara International ASA (YAR.OL), Orkla ASA (ORK.OL), Telenor ASA (TEL.OL). The data gathered spans from January 1, 2018, to May 1, 2024. The eight stocks were selected since they have the largest trading volume from OSE (Figure 1):
Figure 1. On the y-axis, the adjusted close prices for the selected stocks at OSE, including MOWI.OL, EQNR.OL, GJF.OL, DNB.OL, SALM.OL, YAR.OL, ORK.OL, and TEL.OL. On the x-axis, the period for the retrieved data is shown.
All the selected stocks were positively correlated, as shown in Figure 2. Salmar ASA and Mowi ASA, both companies within aquaculture, show the highest correlation.
Figure 2. Pearson correlation matrix of the different selected stocks at the OSE, including MOWI.OL, EQNR.OL, GJF.OL, DNB.OL, SALM.OL, YAR.OL, ORK.OL, and TEL.OL. From positive correlation 1 (blue) to negative −1 (red).
2.2. Study Design
Each agent was deployed with a predetermined trading strategy. Each agent began with an initial 10,000 Norwegian kroner (NOK) asset to invest in the stock market. The agents were restricted to 10 trades per trading day and allowed daily trade. Each agent based their strategies on 5 days of historical data. The strategy of each agent was deterministic, meaning that they had to follow their initial strategy during the whole trading time. The agents did not interact with each other when trading in the market. Each agent acted in the market by selling, holding or buying stocks according to their strategy. Each model’s performance was reported daily, covering the period from January 2, 2018, to May 1, 2024. It was assumed that the trading activities of the agents did not affect the stock prices. This is justified by the small trading volumes each agent handled using the simulations.
The effect of trading cost on the reported returns was investigated using a sensitivity analysis of prices ranging from 0.001 to 0.501 and 1.001. In addition, the effect on returns based on the agents’ access to historical data ranging from 10, 25, 50, 100, and 200 days was analyzed.
The first agent used the strategy Buy and Hold. This strategy was passive, meaning that the agent only made one trade during the assessed time. The agent bought all stocks in equal parts and kept all stocks to the end of the simulation.
The second agent used the strategy Trend Following. In this strategy, the agent was buying or selling stocks based on discerning trends in stock price movements to decide whether to buy or sell. The difference between consecutive prices was used to assess the direction of the trend, meaning deciding on buying, selling or holding the different stocks Equation (1).
(1)
where:
is the price difference at time t;
is the stock price at time t;
is the stock price at time
.
Trading signals:
The third agent was trading based on Mean Reversion, which is based on the premise that stock prices will eventually revert to their average. The strategy generated signals to buy when prices were below the historical average and signals to sell when they were above it, as seen in Equation (2).
(2)
where:
St the price at time t;
price at the previous time –1;
α degree of mean reversion, also known as the mean reversion rate or gravity, μs long-term mean of S;
volatility of S;
ε: random drawing from a standardised normal distribution at time t, (t): n~(0, 1).
Trading signals:
The fourth agent was trading based on Momentum, which is the assumption of continuation of current price trends. It involved calculating a moving average and adjusting the portfolio based on whether current prices were above or below this average, which in turn led the agents to decide to sell, buy or hold stocks Equation (3).
(3)
where:
MAt is the moving average at time t;
C is the closing price of a given stock;
Cn is the closing price over time n.
Trading signal:
2.3. Study Design
The performance of the different trading strategies was recorded daily, showing the value of the agents’ portfolio (Figure 3). The yearly accumulative value of the portfolio and Sharpe Ratio were calculated. The Sharpe Ratio measures the performance of an investment relative to its risk, calculated by subtracting the risk-free return rate from the investment’s return and dividing it by the standard deviation of its returns. The risk-free return was set to 3.9%, which is the risk-free rent possible to get in 2024 in Norway. The standard deviation was calculated in addition to the average return. Standard deviation quantifies the variability of the data around the mean. A higher standard deviation (SD) suggests higher risk, as returns vary more from the average compared to a lower SD.
2.4. Software
All the calculations were done using the statistical program R (R Core Team, 2021) within RStudio (RStudio Team, 2020). With the packages “quantmod”, “zoo” and “corrplot” (Ryan et al., 2024; Taiyun Wei et al., 2022; Zeileis et al., 2023).
3. Results and Discussion
There was a high variability in the obtained returns during the tested period. Figure 3 shows the cumulative performance of the trading strategies from 2018 to 2023 based on the accumulative portfolio value. The Mean Revision (green) demonstrates two peaks, the highest increase until late 2022, followed by a sharp decline. The latest increase can be seen as an effect of the political introduction of a basic interest tax on aquaculture in Norway (Finansdepartementet, 2022), declining the market value of the aquaculture stocks at the OSE The first decrease can be seen as a consequence of covid-19 pandemic, and the decrease in the stock market. The Momentum strategy (Blue) and Trend following (red) show less volatility and a more stable performance throughout the period, while constantly reducing the portfolio value. In principle, the mean revision for trading stocks is questionable since the strategy implies a belief that the stock will not gain or increase in value. The buy and hold show a steady increase during the tested period. All trading strategies had a low or negative Sharpe Ratio (Table 1).
![]()
Figure 3. The accumulative value of the portfolio to the different agents of Trend Following, Mean Reversion, Momentum, and Buy and Hold from 2018 to 2023. Each line represents a strategy, Buy and Hold (purple), Trend Following (red), Mean Reversion (green), and Momentum (blue). The y-axis represents the portfolio value, while the x-axis shows time.
Table 1. Daily mean returns, Standard Deviation (SD) and Shape Ratios ratio between the different trading strategies.
Strategy |
Mean return (%) |
SD |
Sharpe Ratio |
Trend Following |
2% |
0.64 |
−0.04 |
Mean Reversion |
35% |
10.4 |
0.03 |
Momentum |
−3% |
1.83 |
−0.04 |
Buy and Hold |
0 % |
0.01 |
−3.77 |
Increasing trading costs impacted the profitability of all strategies, as evidenced in Table 2. With higher costs, all strategies converge towards zero or negative returns and corresponding decreases in their Sharpe Ratios. This shows the influence of transaction costs on trading strategies. If the methods will be deployed in the market, an investigation of free alternatives should be considered.
Table 2. Sensitivity of Mean return, Standard Deviation and Shape ratio between the different trading strategies based on various trading costs.
Trading Cost |
Strategy |
Mean return (%) |
SD |
Shape ratio |
0.001 |
Trend Following |
2% |
0.64 |
−0.04 |
Mean Reversion |
35% |
10.40 |
0.03 |
Momentum |
−3% |
1.83 |
−0.04 |
Buy and Hold |
0% |
0.01 |
−3.77 |
0.501 |
Trend Following |
0% |
0.22 |
−0.16 |
Mean Reversion |
−2% |
0.84 |
−0.07 |
Momentum |
1% |
0.15 |
−0.21 |
Buy and Hold |
0% |
0.01 |
−3.77 |
1.001 |
Trend Following |
0% |
0.10 |
−0.37 |
Mean Reversion |
0% |
0.09 |
−0.40 |
Momentum |
0% |
0.10 |
−0.37 |
Buy and Hold |
0% |
0.01 |
−3.77 |
All the evaluated trading strategies are deterministic, meaning that they do not adapt their behavior during the test period based on their performance. This may have reduced the performance of the deployed models. Further, all the evaluated models are simple; they do not act based on multiple price or volume indicators. In combination, this can explain why the different evaluated strategies are performing poorly. Earlier investigations have shown that more complex models may have advantages in quantitative trading strategies. In recent years, such strategies have been coupled with machine learning and machine learning with reinforcement learning. These do, to some extent, show potential in the literature (Nti et al., 2020; Sorensen et al., 2020). Some authors, like Cliff & Rollins (2020), are more critical of more complex models.
Cliff and Rollins (2020) argued that the literature may be biased towards newer trading methods, as older and simpler methods have not been evaluated based on more sophisticated techniques. Implementing more complex models may overfit the data, thus leading to lower actual performance on unobserved data (testing). The present evaluation shows that simple deterministic trading strategies are also vulnerable to sudden market shifts, like the price drop due to Covid-19 and political with the political decision to enforce a new tax in the aquaculture sector in Norway affecting the stock market.
It could be of interest to combine the strategies of fundamental analysis and technical analysis to evaluate the performance of the new strategies, as suggested by Huang et al. (2021). In addition, having a stop-loss function on deterministic models or switching to stochastic strategies as time goes, with adaptive abilities, can be valuable to handle sudden shifts in price movement.
Sensitivity Variable Trading Cost and Extended Access to Historical Data on the Trading Agents
Increasing trading costs impacted the profitability of all strategies, as evidenced in Table 2. With higher costs, all strategies converge towards zero or negative returns and corresponding decreases in their Sharpe Ratios. This shows the influence of transaction costs on trading strategies. If the methods will be deployed in the market, an investigation of free alternatives should be considered.
The present evaluation overlooks the effect of the agent’s action on the market: as each agent’s trading volume increases, the agents’ actions will affect the market movement. As all the agents are sensitive to trading costs, higher assets should be implemented to improve the accumulative performance. This will lower the relative effect of the trading costs. With the introduction of an extended amount of historical data, the mean return of the trading strategies is generally increased for all the strategies (Table 3). This can be explained by the agents holding the stocks longer without changing the portfolio, therefore lowering the trading costs, and altering the performance. While the mean return after each trading tended to increase, based on the access to more historical data, the Sharpe Ratio remained relatively constant. This shows that even with access to more data, the trading agents deliver high variability (volatility).
Table 3. Effect of daily returns with different access to historical data across the agents.
|
Mean Return |
SD Return |
Sharpe Ratio |
Trend Following 10 days |
5% |
2.64 |
0.003 |
Trend Following 25 days |
4% |
0.73 |
0.005 |
Trend Following 50 days |
8% |
1.66 |
0.02 |
Trend Following 100 days |
−2% |
0.66 |
−0.09 |
Trend Following 200 days |
0% |
1.08 |
−0.04 |
Mean Reversion 10 days |
17% |
8.52 |
0.02 |
Mean Reversion 25 days |
2% |
0.63 |
−0.03 |
Mean Reversion 50 days |
−2% |
0.96 |
−0.06 |
Mean Reversion 100 days |
5% |
1.57 |
0.01 |
Mean Reversion 200 days |
0% |
0.27 |
−0.13 |
Momentum 10 days |
−20% |
7.65 |
−0.03 |
Momentum 25 days |
−1% |
1.32 |
−0.04 |
Momentum 50 days |
157% |
52.13 |
0.03 |
Momentum 100 days |
3% |
0.98 |
−0.01 |
Momentum 200 days |
−1% |
1.37 |
−0.03 |
4. Concluding Remarks
The analysis of simple deterministic trading strategies on the OSE between 2018 and 2023 demonstrates high variability in performance based on market conditions and cost structures.
The performance comparison (Figure 3) shows that every strategy lost money during the test period, except for Mean Revision. Conversely, the only strategy that was profitable was the Mean Revision, due to external events.
The implementation of the deterministic stock trading strategies at the OSE should be further developed to handle unforeseen events before a practical implementation is possible. This may be introduced by stop-loss functions and stochasticity in the models.