Skip to main content
Log in

SABCEMM: A Simulator for Agent-Based Computational Economic Market Models

  • Published:
Computational Economics Aims and scope Submit manuscript

Abstract

We introduce the simulation tool SABCEMM (Simulator for Agent-Based Computational Economic Market Models) for agent-based computational economic market (ABCEM) models. Our simulation tool is implemented in C++ and we can easily run ABCEM models with several million agents. The object-oriented software design enables the isolated implementation of building blocks for ABCEM models, such as agent types and market mechanisms. The user can design and compare ABCEM models in a unified environment by recombining existing building blocks using the XML-based SABCEMM configuration file. We introduce an abstract ABCEM model class which our simulation tool is built upon. Furthermore, we present the software architecture as well as computational aspects of SABCEMM. Here, we focus on the efficiency of SABCEMM with respect to the run time of our simulations. We show the great impact of different random number generators on the run time of ABCEM models. The code and documentation is published on GitHub at https://github.com/SABCEMM/SABCEMM, such that all results can be reproduced by the reader.

This is a preview of subscription content, log in via an institution to check access.

Access this article

Price excludes VAT (USA)
Tax calculation will be finalised during checkout.

Instant access to the full article PDF.

Institutional subscriptions

Fig. 1
Fig. 2
Fig. 3
Fig. 4
Fig. 5
Fig. 6
Fig. 7
Fig. 8

Similar content being viewed by others

Notes

  1. https://sabcemm.github.io/SABCEMM/.

  2. https://github.com/SABCEMM/SABCEMM/wiki/User-Guide.

  3. Cross herding mechanism: https://github.com/SABCEMM/SABCEMM/blob/v0.1-alpha/src/Agent/AgentCross.cpp#L138-L140.

  4. Harras ED: https://github.com/SABCEMM/SABCEMM/blob/v0.1-alpha/src/ExcessDemandCalculator/ExcessDemandCalculatorHarras.cpp#L71-L87.

  5. https://github.com/SABCEMM/SABCEMM/wiki/Create-an-Input-File.

  6. https://github.com/SABCEMM/SABCEMM/blob/master/input/examples/Cross.xml.

  7. Code excerpt: https://github.com/SABCEMM/SABCEMM/blob/v0.1-alpha/src/Agent/AgentCross.cpp#L138-L140.

  8. Code excerpt: https://github.com/SABCEMM/SABCEMM/blob/v0.1-alpha/src/Agent/AgentCross.cpp#L129-L133.

  9. Code excerp: https://github.com/SABCEMM/SABCEMM/blob/v0.1-alpha/src/PriceCalculator/PriceCalculatorGeneral.cpp#L92.

  10. Code excerpt: https://github.com/SABCEMM/SABCEMM/blob/v0.1-alpha/src/PriceCalculator/PriceCalculatorGeneral.cpp#L173-L17.

  11. Code excerpt: https://github.com/SABCEMM/SABCEMM/blob/v0.1-alpha/src/PriceCalculator/PriceCalculatorGeneral.cpp#L190-L193.

  12. https://gcc.gnu.org

  13. min. version 2.8.12; https://cmake.org.

  14. https://opensource.org/licenses/BSD-3-Clause.

  15. https://sabcemm.github.io/SABCEMM/.

  16. https://github.com/SABCEMM/SABCEMM/wiki/User-Guide.

  17. https://www.hdfgroup.org/.

  18. https://portal.hdfgroup.org/display/HDF5/HDF5.

  19. https://www.h5py.org.

  20. https://github.com/HDFGroup/PyHexad.

References

  • Abar, S., Theodoropoulos, G. K., Lemarinier, P., & O’Hare, G. M. (2017). Agent based modelling and simulation tools: A review of the state-of-art software. Computer Science Review, 24, 13–33.

    Google Scholar 

  • Ackerman, F. (2002). Still dead after all these years: Interpreting the failure of general equilibrium theory. Journal of Economic Methodology, 9(2), 119–139.

    Google Scholar 

  • Adam, K., Marcet, A., & Nicolini, J. P. (2016). Stock market volatility and learning. The Journal of Finance, 71(1), 33–82.

    Google Scholar 

  • Alfarano, S., Lux, T., & Wagner, F. (2005). Estimation of agent-based models: The case of an asymmetric herding model. Computational Economics, 26(1), 19–49.

    Google Scholar 

  • Alfarano, S., Lux, T., & Wagner, F. (2008). Time variation of higher moments in a financial market with heterogeneous agents: An analytical approach. Journal of Economic Dynamics and Control, 32(1), 101–136.

    Google Scholar 

  • Allan, R. J. (2010). Survey of agent based modelling and simulation tools. London: Science & Technology Facilities Council.

    Google Scholar 

  • Andersen, J. V., & Sornette, D. (2003). The $-game. The European Physical Journal B-Condensed Matter and Complex Systems, 31(1), 141–145.

    Google Scholar 

  • Beikirch, M., Cramer, S., Frank, M., Otte, P., Pabich, E., & Trimborn, T. (2018). Simulation of stylized facts in agent-based computational economic market models. arXiv preprint arXiv:1812.02726.

  • Beja, A., & Goldman, M. B. (1980). On the dynamic behavior of prices in disequilibrium. The Journal of Finance, 35(2), 235–248.

    Google Scholar 

  • Bernanke, B. (2010). Interview with the international herald tribune, 5.

  • Bouchaud, J.-P. (2002). An introduction to statistical finance. Physica A: Statistical Mechanics and its Applications, 313(1), 238–251.

    Google Scholar 

  • Bouchaud, J.-P. (2008). Economics needs a scientific revolution. Nature, 455(7217), 1181–1181.

    Google Scholar 

  • Bouchaud, J.-P., & Cont, R. (1998). A langevin approach to stock market fluctuations and crashes. The European Physical Journal B-Condensed Matter and Complex Systems, 6(4), 543–550.

    Google Scholar 

  • Brock, W. A., & Hommes, C. H. (1997). A rational route to randomness. Econometrica: Journal of the Econometric Society, 65, 1059–1095.

    Google Scholar 

  • Brock, W. A., & Hommes, C. H. (1998). Heterogeneous beliefs and routes to chaos in a simple asset pricing model. Journal of Economic dynamics and Control, 22(8), 1235–1274.

    Google Scholar 

  • Butcher, J. C. (2016). Numerical methods for ordinary differential equations. New York: Wiley.

    Google Scholar 

  • Campbell, J. Y., Lo, A. W.-C., MacKinlay, A. C., et al. (1997). The econometrics of financial markets (Vol. 2). Princeton, NJ: Princeton University Press.

    Google Scholar 

  • Chakraborti, A., Toke, I. M., Patriarca, M., & Abergel, F. (2011). Econophysics review: Ii. agent-based models. Quantitative Finance, 11(7), 1013–1041.

    Google Scholar 

  • Challet, D., & Marslii, M. (2002). Criticality and finite size effects in a simple realistic model of stock market. Working paper Department of Theoretical Physics, Oxford University, INFM, Trieste-SISSA Unit, Trieste.

  • Challet, D., Marsili, M., & Zhang, Y.-C. (2001). Stylized facts of financial markets and market crashes in minority games. Physica A: Statistical Mechanics and its Applications, 294(3), 514–524.

    Google Scholar 

  • Chen, S.-H., Chang, C.-L., & Du, Y.-R. (2012). Agent-based economic models and econometrics. The Knowledge Engineering Review, 27(02), 187–219.

    Google Scholar 

  • Chiarella, C., Dieci, R., & Gardini, L. (2002). Speculative behaviour and complex asset price dynamics: A global analysis. Journal of Economic Behavior & Organization, 49(2), 173–197.

    Google Scholar 

  • Chiarella, C., Dieci, R., & Gardini, L. (2005). The dynamic interaction of speculation and diversification. Applied Mathematical Finance, 12(1), 17–52.

    Google Scholar 

  • Chiarella, C., Dieci, R., & Gardini, L. (2006). Asset price and wealth dynamics in a financial market with heterogeneous agents. Journal of Economic Dynamics and Control, 30(9), 1755–1786.

    Google Scholar 

  • Chiarella, C., Dieci, R., & He, X.-Z. (2007). Heterogeneous expectations and speculative behavior in a dynamic multi-asset framework. Journal of Economic Behavior & Organization, 62(3), 408–427.

    Google Scholar 

  • Cont, R. (2001). Empirical properties of asset returns: stylized facts and statistical issues.

    Google Scholar 

  • Cont, R., & Bouchaud, J.-P. (2000). Herd behavior and aggregate fluctuations in financial markets. Macroeconomic Dynamics, 4(2), 170–196.

    Google Scholar 

  • Corporation, I. Intel math kernel library.

  • Cowan, R., & Jonard, N. (2002). Heterogenous agents, interactions and economic performance (Vol. 521). Berlin: Springer.

    Google Scholar 

  • Cross, R., Grinfeld, M., & Lamba, H. (2006). A mean-field model of investor behaviour. Journal of Physics Conference Series, 55, 55–62.

    Google Scholar 

  • Cross, R., Grinfeld, M., Lamba, H., & Seaman, T. (2005). A threshold model of investor psychology. Physica A: Statistical Mechanics and its Applications, 354, 463–478.

    Google Scholar 

  • Cross, R., Grinfeld, M., Lamba, H., & Seaman, T. (2007). Stylized facts from a threshold-based heterogeneous agent model. The European Physical Journal B, 57(2), 213–218.

    Google Scholar 

  • Da Silva, M. A., Lima, G. T., et al. (2015). Combining monetary policy and prudential regulation: An agent-based modeling approach. Banco Central Do Brasil working papers (394).

  • Day, R. H., & Huang, W. (1990). Bulls, bears and market sheep. Journal of Economic Behavior & Organization, 14(3), 299–329.

    Google Scholar 

  • De Grauwe, P., & Grimaldi, M. (2005). Heterogeneity of agents, transactions costs and the exchange rate. Journal of Economic Dynamics and Control, 29(4), 691–719.

    Google Scholar 

  • Debreu, G. (1974). Excess demand functions. Journal of Mathematical Economics, 1(1), 15–21.

    Google Scholar 

  • Dieci, R., Foroni, I., Gardini, L., & He, X.-Z. (2006). Market mood, adaptive beliefs and asset price dynamics. Chaos, Solitons & Fractals, 29(3), 520–534.

    Google Scholar 

  • Dijkstra, E. W. (1982). On the role of scientific thought. In Selected writings on computing: A personal perspective (pp. 60–66). Springer.

  • Egenter, E., Lux, T., & Stauffer, D. (1999). Finite-size effects in monte carlo simulations of two stock market models. Physica A: Statistical Mechanics and its Applications, 268(1), 250–256.

    Google Scholar 

  • Ehrentreich, N. (2007). Agent-based modeling: The Santa Fe Institute artificial stock market model revisited (Vol. 602). Berlin: Springer.

    Google Scholar 

  • Evans, L. C. (2012). An introduction to stochastic differential equations (Vol. 82). Providence: American Mathematical Society.

    Google Scholar 

  • Fama, E. F. (1965). The behavior of stock-market prices. The Journal of Business, 38(1), 34–105.

    Google Scholar 

  • Farmer, D. (1997). Seminar presented at université de paris vi.

  • Farmer, J. D., & Foley, D. (2009). The economy needs agent-based modelling. Nature, 460(7256), 685–686.

    Google Scholar 

  • Farmer, J. D., & Joshi, S. (2002). The price dynamics of common trading strategies. Journal of Economic Behavior & Organization, 49(2), 149–171.

    Google Scholar 

  • Farmer, J. D., Patelli, P., & Zovko, I. I. (2005). The predictive power of zero intelligence in financial markets. Proceedings of the National Academy of Sciences of the United States of America, 102(6), 2254–2259.

    Google Scholar 

  • Franke, R., & Westerhoff, F. (2012). Structural stochastic volatility in asset pricing dynamics: Estimation and model contest. Journal of Economic Dynamics and Control, 36(8), 1193–1211.

    Google Scholar 

  • Gode, D. K., & Sunder, S. (1993). Allocative efficiency of markets with zero-intelligence traders: Market as a partial substitute for individual rationality. Journal of Political Economy, 101(1), 119–137.

    Google Scholar 

  • Google test. https://github.com/google/googletest. Accessed 2017-08-24.

  • Granger, C. W. J., & Morgenstern, O. (1970). Predictability of stock market prices. Heath Lexington Books.

  • Harras, G., & Sornette, D. (2011). How to grow a bubble: A model of myopic adapting agents. Journal of Economic Behavior & Organization, 80(1), 137–152.

    Google Scholar 

  • He, C. C. R. D. X.-Z. (2011). The dynamic behaviour of asset prices in disequilibrium: a survey. International Journal of Behavioural Accounting and Finance, 2(2), 101–139.

    Google Scholar 

  • Heertje, A. (2002). Recent criticism of general equilibrium theory. In Equilibrium, markets and dynamics (pp. 51–60). Springer.

  • Hellekalek, P. (1998). Good random number generators are (not so) easy to find. Mathematics and Computers in Simulation, 46(5), 485–505.

    Google Scholar 

  • Hellthaler, T. (1996). The influence of investor number on a microscopic market model. International Journal of Modern Physics C, 6(06), 845–852.

    Google Scholar 

  • Hommes, C. H. (2006). Heterogeneous agent models in economics and finance. Handbook of Computational Economics, 2, 1109–1186.

    Google Scholar 

  • Iori, G., Porter, J., et al. (2012). Agent-based modelling for financial markets. Chapter prepared for the Handbook on Computational Economics and Finance.

  • Kahneman, D. (2003). Maps of bounded rationality: Psychology for behavioral economics. The American Economic Review, 93(5), 1449–1475.

    Google Scholar 

  • Kaizoji, T. (2000). Speculative bubbles and crashes in stock markets: an interacting-agent model of speculative activity. Physica A: Statistical Mechanics and its Applications, 287(3), 493–506.

    Google Scholar 

  • Kaizoji, T., Bornholdt, S., & Fujiwara, Y. (2002). Dynamics of price and trading volume in a spin model of stock markets with heterogeneous agents. Physica A: Statistical Mechanics and its Applications, 316(1), 441–452.

    Google Scholar 

  • Kempf, A., & Korn, O. (1999). Market depth and order size. Journal of Financial Markets, 2(1), 29–48.

    Google Scholar 

  • Kim, G.-R., & Markowitz, H. M. (1989). Investment rules, margin, and market volatility. The Journal of Portfolio Management, 16(1), 45–52.

    Google Scholar 

  • Kirman, A. (1993). Ants, rationality, and recruitment. The Quarterly Journal of Economics, 108(1), 137–156.

    Google Scholar 

  • Kirman, A. P., Teyssiere, G., et al. (2001). Microeconomic models for long-memory in the volatility of financial time series. Technical report, Society for Computational Economics.

  • Knuth, D. E. (1997). The art of computer programming: Seminumerical algortihms (3rd ed., Vol. 2). London: Pearson Education.

    Google Scholar 

  • Kohl, R. (1997). The influence of the number of different stocks on the levy-levy-solomon model. International Journal of Modern Physics C, 8(06), 1309–1316.

    Google Scholar 

  • LeBaron, B. (2000). Agent-based computational finance: Suggested readings and early research. Journal of Economic Dynamics and Control, 24(5), 679–702.

    Google Scholar 

  • LeBaron, B. (2006). Agent-based computational finance. Handbook of Computational Economics, 2, 1187–1233.

    Google Scholar 

  • L’Ecuyer, P., & Simard, R. (2007). Testu01: Ac library for empirical testing of random number generators. ACM Transactions on Mathematical Software (TOMS), 33(4), 22.

    Google Scholar 

  • Levy, M., Levy, H., & Solomon, S. (1994). A microscopic model of the stock market: Cycles, booms, and crashes. Economics Letters, 45(1), 103–111.

    Google Scholar 

  • Levy, M., Levy, H., & Solomon, S. (1995). Microscopic simulation of the stock market: The effect of microscopic diversity. Journal de Physique I, 5(8), 1087–1107.

    Google Scholar 

  • Levy, H., Levy, M., & Solomon, S. (2000). Microscopic simulation of financial markets: From investor behavior to market phenomena. London: Academic Press.

    Google Scholar 

  • Lux, T. (1995). Herd behaviour, bubbles and crashes. The Economic Journal, 105, 881–896.

    Google Scholar 

  • Lux, T. (2008). Stochastic behavioral asset pricing models and the stylized facts. Technical report, Economics working paper/Christian-Albrechts-Universität Kiel, Department of Economics.

  • Lux, T. (1998). The socio-economic dynamics of speculative markets: Interacting agents, chaos, and the fat tails of return distributions. Journal of Economic Behavior & Organization, 33(2), 143–165.

    Google Scholar 

  • Lux, T., & Marchesi, M. (1999). Scaling and criticality in a stochastic multi-agent model of a financial market. Nature, 397(6719), 498–500.

    Google Scholar 

  • Lux, T., & Marchesi, M. (2000). Volatility clustering in financial markets: A microsimulation of interacting agents. International Journal of Theoretical and Applied Finance, 3(04), 675–702.

    Google Scholar 

  • Malkiel, B. G. (2003). The efficient market hypothesis and its critics. The Journal of Economic Perspectives, 17(1), 59–82.

    Google Scholar 

  • Malkiel, B. G., & Fama, E. F. (1970). Efficient capital markets: A review of theory and empirical work. The Journal of Finance, 25(2), 383–417.

    Google Scholar 

  • Mandelbrot, B. B. (1997). The variation of certain speculative prices. Berlin: Springer.

    Google Scholar 

  • Mantel, R. R. (1974). On the characterization of aggregate excess demand. Journal of Economic Theory, 7(3), 348–353.

    Google Scholar 

  • Matsumoto, M., & Nishimura, T. (1998). Mersenne twister: A 623-dimensionally equidistributed uniform pseudo-random number generator. ACM Transactions on Modeling and Computer Simulation (TOMACS), 8(1), 3–30.

    Google Scholar 

  • Mill, J. S. (1994). On the definition of political economy and method of investigation proper to it (1836). Collected Works of John Stuart Mill, 4, 120–164.

    Google Scholar 

  • Myers, G. J., Sandler, C., & Badgett, T. (2011). The art of software testing. New York: Wiley.

    Google Scholar 

  • N. A. G. (NAG). Nag c library.

  • Nikolai, C., & Madey, G. (2009). Tools of the trade: A survey of various agent based modeling platforms. Journal of Artificial Societies and Social Simulation, 12(2), 2.

    Google Scholar 

  • Palmer, R. G., Arthur, W. B., Holland, J. H., LeBaron, B., & Tayler, P. (1994). Artificial economic life: A simple model of a stockmarket. Physica D: Nonlinear Phenomena, 75(1–3), 264–274.

    Google Scholar 

  • Pareto, V. (1897). Cours d’économie politique, professé à l’université de lausanne. tome second.

  • Rumbaugh, J., Blaha, M., Premerlani, W., Eddy, F., Lorensen, W. E., et al. (1991). Object-oriented modeling and design (Vol. 199). Englewood Cliffs, NJ: Prentice-Hall.

    Google Scholar 

  • Samanidou, E., Zschischang, E., Stauffer, D., & Lux, T. (2007). Agent-based models of financial markets. Reports on Progress in Physics, 70(3), 409.

    Google Scholar 

  • Schweitzer, F., Fagiolo, G., Sornette, D., Vega-Redondo, F., Vespignani, A., & White, D. R. (2009). Economic networks: The new challenges. Science, 325(5939), 422–425.

    Google Scholar 

  • Simon, H. A. (1955). A behavioral model of rational choice. The Quarterly Journal Of Economics, 69, 99–118.

    Google Scholar 

  • Simon, H. A. (1957). Models of man; social and rational.

  • Sonnenschein, H. (1972). Market excess demand functions. Econometrica: Journal of the Econometric Society, 40, 549–563.

    Google Scholar 

  • Sornette, D. (2014). Physics and financial economics (1776–2014): Puzzles, ising and agent-based models. Reports on Progress in Physics, 77(6), 062001.

    Google Scholar 

  • Sornette, D., & Zhou, W.-X. (2006). Importance of positive feedbacks and overconfidence in a self-fulfilling ising model of financial markets. Physica A: Statistical Mechanics and its Applications, 370(2), 704–726.

    Google Scholar 

  • Teglio, A., Raberto, M., & Cincotti, S. (2012). The impact of banks’capital adequacy regulation on the economic system: An agent-based approach. Advances in Complex Systems, 15(supp02), 1250040.

    Google Scholar 

  • Tesfatsion, L. (2002). Agent-based computational economics: Growing economies from the bottom up. Artificial Life, 8(1), 55–82.

    Google Scholar 

  • Tesfatsion, L. (2006). Agent-based computational economics: A constructive approach to economic theory. Handbook of Computational Economics, 2, 831–880.

    Google Scholar 

  • Timmermann, A. G. (1993). How learning in financial markets generates excess volatility and predictability in stock prices. The Quarterly Journal of Economics, 108(4), 1135–1145.

    Google Scholar 

  • Tiwana, A., Wang, J., Keil, M., & Ahluwalia, P. (2007). The bounded rationality bias in managerial valuation of real options: Theory and evidence from it projects*. Decision Sciences, 38(1), 157–181.

    Google Scholar 

  • Tobias, R., & Hofmann, C. (2004). Evaluation of free java-libraries for social-scientific agent based simulation. Journal of Artificial Societies and Social Simulation, 7(1), 1–6.

    Google Scholar 

  • Trichet, J.-C. (2010). Reflections on the nature of monetary policy non-standard measures and finance theory, 11 2010. Introductory speech a the ECB Central Banking Conference, Frankfurt. Accessed 2016-05-13.

  • Trimborn, T., Otte, P., Cramer, S., Beikirch, M., Pabich, E., & Frank, M. Data set of sabcemm. https://publications.rwth-aachen.de/record/707265.

  • Walker, D. A. (2006). Walrasian economics. Cambridge: Cambridge University Press.

    Google Scholar 

  • Walras, L. (1896). Éléments d’économie politique pure, ou, Théorie de la richesse sociale. Lausanne: F. Rouge.

    Google Scholar 

  • Zhou, W.-X., & Sornette, D. (2007). Self-organizing ising model of financial markets. The European Physical Journal B, 55(2), 175–181.

    Google Scholar 

  • Zschischang, E., & Lux, T. (2001). Some new results on the levy, levy and solomon microscopic stock market model. Physica A: Statistical Mechanics and its Applications, 291(1), 563–573.

    Google Scholar 

Download references

Acknowledgements

T. Trimborn gratefully acknowledges support by Hans-Böckler Stiftung. T. Trimborn would like to thank the German Research Foundation DFG for the kind support within the Cluster of Excellence Internet of Production(Project-ID: 390621612). T. Trimborn gratefully acknowledges support by the RWTH Aachen University Start-Up grant. The work was partially funded by the Excel-lence Initiative of the German federal and state governments.

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Torsten Trimborn.

Additional information

Publisher's Note

Springer Nature remains neutral with regard to jurisdictional claims in published maps and institutional affiliations.

Appendix

Appendix

1.1 Models

Cross Model We present the Cross model as defined in Cross et al. (2005).

We assume a fixed number of \(N\in {\mathbb {N}}\) agents. Each agent decides in each time step, whether he wants to be long or short in the market. Thus, the investment propensity \(\sigma _i,\ 1\le i\le N\) of each agent switches between \(\sigma _i=\pm 1\). The excess demand of all investors at time \([0,\infty )\) is then defined as:

$$\begin{aligned} ED(t):= \frac{1}{N}\sum \limits _{i=1}^N\sigma _i(t). \end{aligned}$$

Furthermore, the model introduces two pressures, the herding pressure and the inaction pressure, which control the switching mechanism.

The inaction pressure is defined by the interval

$$\begin{aligned} I_i=\left[ \frac{m_i}{1+\alpha _i}, m_i\ (1+\alpha _i)\right] , \end{aligned}$$

where \(m_i\) denotes the stock price of the last switch of agent i and \(\alpha _i>0\) is the so called inaction threshold. The herding pressure is given by:

$$\begin{aligned} {\left\{ \begin{array}{ll} c_i(t+\Delta t)= c_i(t)+ \Delta t |ED(t)|,&{} \text {if}\ \sigma _i(t)\ ED(t)<0\\ c_i(t+\Delta t)=c_i(t),&{} \text {otherwise}. \end{array}\right. } \end{aligned}$$

The implementations of herding pressure and inaction pressure can be found in the Git repository,Footnote 7\(^{,}\)Footnote 8 respectively.

In addition, one defines the herding threshold\(\beta _i\). The thresholds are chosen once randomly from an i.i.d. random variable, which is uniformly distributed.

$$\begin{aligned} \alpha _i\sim {{\,\mathrm{Unif_{c}}\,}}(A_1,A_2), \ A_2>A_1>0,\\ \beta _i\sim {{\,\mathrm{Unif_{c}}\,}}(B_1,B_2), \ B_2>B_1>0. \end{aligned}$$

The constants \(B_1\) and \(B_2\) have to scale with time, since they correspond to the time units an investor can resist the herding pressure.

$$\begin{aligned}&B_1:= b_1\cdot \Delta t,\\&B_2:= b_2\cdot \Delta t. \end{aligned}$$

Switching Mechanism The switching is then induced if

$$\begin{aligned} c_i>\beta _i\ \text {or}\ S(t)\notin I_i. \end{aligned}$$

After a switch the herding pressure is reset to zero and the inaction interval gets updated as well. The stock price is then driven by the excess demand:

$$\begin{aligned}&S(t+\Delta t)=S(t)\ \exp \{ (1+\theta \ |ED(t)| )\ \sqrt{\Delta t}\ \eta (t)+\kappa \ \Delta t\ \frac{\Delta ED(t)}{\Delta t} \},\\&\sqrt{\Delta t}\ \eta \sim {\mathcal {N}}(0,\Delta t)\\&\Delta ED(t):=\frac{1}{N}\sum \limits _{i=1}^N \sigma _i(t)-\frac{1}{N}\sum \limits _{i=1}^N \sigma _i(t-\Delta t), \end{aligned}$$

where \(\kappa \) denotes the market depth and \(\Delta t >0\) the time step.

In SABCEMM, the price evolutionFootnote 9 is implemented as

$$\begin{aligned} S(t+\Delta t) = S(t) + \Delta t*F+sqrt(\Delta t) * G * \eta \end{aligned}$$

with suitable FFootnote 10 and G.Footnote 11

Cross Model Extensions One alternative pricing function is given by:

$$\begin{aligned} S(t+\Delta t)=S(t)\ + \Delta t\ \kappa \ \frac{\Delta ED(t)}{\Delta t} \ S(t)+ \sqrt{\Delta t}\ F_{Cross}(S,ED)\ S(t)\ \eta , \end{aligned}$$

Furthermore, we have added the wealth evolution, for a fixed interest rate \(r>0\) and fixed investment fraction \(\gamma \in (0,1)\):

$$\begin{aligned} w_{i}(t+\Delta t) = w_i(t)+ \Delta t\ \left[ (1-\gamma )\ r + \gamma \frac{S(t)-S(t-\Delta t)}{\Delta t\ S(t)}\right] w_i(t). \end{aligned}$$

LLS Model We have implemented the model as defined in Levy et al. (1994, 1995). In comparison to the original model, we introduce one possible time scaling. In order to obtain the original model one needs to set \(\Delta t=1\).

The model considers \(N\in {\mathbb {N}}\) financial agents who can invest \(\gamma _i\in [0.01, 0.99],\ i=1,\ldots ,N\) of their wealth \(w_i\in {\mathbb {R}}_{>0}\) in a stocks and have to invest \(1-\gamma _i\) of their wealth in a safe bond with interest rate \(r\in (0,1)\). The investment propensities \(\gamma _i\) are determined by a utility maximization and the wealth dynamic of each agent at time \(t\in [0,\infty )\) is given by

$$\begin{aligned}&{w}_i(t)=w_i(t-\Delta t)\\&\quad +\Delta t \left( (1-\gamma _i(t-\Delta t))\ r\ w_i(t-\Delta t)+\gamma _i(t-\Delta t)\ w_i(t-\Delta t)\ \underbrace{\frac{\frac{{S}(t)-S(t-\Delta t)}{\Delta t}+D(t)}{S(t)}}_{=:x(S,t,D)}\right) . \end{aligned}$$

The dynamics is driven by a multiplicative dividend process. Given by:

$$\begin{aligned} D(t):=(1+\Delta t\ {\tilde{z}})\ D(t-\Delta t), \end{aligned}$$

where \({\tilde{z}}\) is a uniformly distributed random variable with support \([z_1,z_2]\). The price is fixed by the so called market clearance condition, where \(n\in {\mathbb {N}}\) is the fixed number of stocks and \(n_i(t)\) the number of stocks of each agent.

$$\begin{aligned} n=\sum \limits _{i=1}^N n_i(t)=\sum \limits _{k=1}^N \frac{\gamma _k(t)\ w_k(t)}{S(t)}. \end{aligned}$$
(9)

The utility maximization is given by

$$\begin{aligned} \max \limits _{\gamma _i \in [0.01,0.99]} E[\log (w(t+\Delta t,\gamma _i,S^h))]. \end{aligned}$$

with

$$\begin{aligned} E[\log (w(t+\Delta t, \gamma _i,S^h))]&=\frac{1}{m_i} \sum \limits _{j=1}^{m_i} U_i\Bigg ((1-\gamma _{i}(t)) w_{i}(t,S^h) \left( 1+r\Delta t\right) \\&\quad +\,\gamma _{i}(t) w_{i}(t, S^h) \Big (1+x\big (S,t-j\Delta t,D\big )\ \Delta t\Big )\Bigg ). \end{aligned}$$

The constant \(m_i\) denotes the number of time steps each agent looks back. Thus, the number of time steps \(m_i\) and the length of the time step \(\Delta t\) defines the time period each agent extrapolates the past values. The superscript h indicates, that the stock price is uncertain and needs to be fixed by the market clearance condition. Finally, the computed optimal investment proportion gets blurred by a noise term.

$$\begin{aligned} \gamma _i (t)=\gamma _i^{*}(t)+\epsilon _i, \end{aligned}$$

where \(\epsilon _i\) is distributed like a truncated normally distributed random variable with standard deviation \(\sigma _{\gamma }\).

Utility Maximization Thanks to the simple utility function and linear dynamics we can compute the optimal investment proportion in the cases where the maximum is reached at the boundaries. The first order necessary condition is given by:

$$\begin{aligned} f(\gamma _i):= & {} \frac{d}{dt} E[\log (w(t+\Delta t, \gamma _i,S^h))]\\= & {} \frac{1}{m_i} \sum \limits _{j=1}^{m_i} \frac{\Delta t\ (x\big (S,t-j\Delta t,D\big )-r)}{\Delta t\ (x\big (S,t-j\Delta t,D\big )-r)\ \gamma _i+ 1+\Delta t\ r}. \end{aligned}$$

Thus, for \(f(0.01)<0\) we can conclude that \(\gamma _i=0.01\) holds. In the same manner, we get \(\gamma _i=0.99\), if \(f(0.01)>0\) and \(f(0.99)>0\) holds. Hence, solutions in the interior of [0.01, 0.99] can be only expected in the case: \(f(0.01)>0\) and \(f(0.99)<0\). This coincides with the observations in Samanidou et al. (2007).

Harras Model We present the Harras model as defined in Harras and Sornette (2011).

We consider N financial agents where each agent is equipped with a personal opinion \(\psi _i(t_k)\), and \(t_k\) denotes a discrete time step. The personal opinion is created through the personal information of each agent \(\epsilon _i(t_k)\), public information \(n(t_k)\) and the expected action of the surrounded neighbor j by the agent i, \(E_i[\sigma _j(t_k)], \sigma _j\in \{-1,0, 1\}\). The opinion of the i-th agent at time \(t_k\) reads:

$$\begin{aligned} \psi _i(t_k) = c_{1,i} \sum \limits _{j=1}^4 k_{ij}(t_{k-1})\ E[\sigma _i(t_k)] + c_{2,i} u(t_{k-1})\ n(t_k) +c_{3,i}\ \epsilon _i(t_k). \end{aligned}$$
(10)

During the evaluation of our simulations we noticed a significant difference in the magnitude of the price’s volatility. Our investigation leads us to the conclusion that the opinion of the i-th agent at time \(t_k\) should instead be:

$$\begin{aligned} \psi _i(t_k) = c_{1,i} \frac{1}{4} \sum \limits _{j=1}^4 k_{ij}(t_{k-1})\ E[\sigma _i(t_k)] + c_{2,i} u(t_{k-1})\ n(t_k) +c_{3,i}\ \epsilon _i(t_k). \end{aligned}$$

The weights \((c_{1,i}, c_{2,i}, c_{3,i})\) are chosen initially for each agent from three uniformly distributed random variables on the domains \([0,C_l],\ l\in \{1, 2, 3 \}\). The private and public information \(\epsilon _i(t_k), n(t_k)\) are modeled as standard normally distributed i.i.d. random variables. The agents are grouped on a virtual square lattice with periodic boundary conditions, such that each agent has four neighbors. We update of the opinion of each agent is performed in each time step in random order. The additional factor \(k_{ij}\) weights the predicted action of the j-th agent based on the past performance. In the same manner the factor u weights the public information stream. The update rule of these weighting factors is given by:

$$\begin{aligned}&u(t_k) = \alpha \ u(t_{k-1}) +(1-\alpha )\ n(t_{k-1}) \frac{ED(t_k)}{\sigma _{ED}(t_k)},\\&k_{i,j} (t_k)= \alpha \ k_{i,j} (t_{k-1})+(1-\alpha )\ E_i[\sigma _j(t_{k-1})] \frac{ED(t_k)}{\sigma _{ED}(t_k)}, \end{aligned}$$

with the constant \(0<\alpha <1\) and the volatility

$$\begin{aligned}&\sigma _{ED}^2(t_k)= \alpha \ \sigma _{ED}^2(t_{k-1})+(1-\alpha )\ (ED(t_{k-1})- \langle ED(t_k)\rangle )^2,\\&\langle ED(t_k)\rangle = \alpha \ \langle ED(t_{k-1}) \rangle +(1-\alpha )\ ED(t_{k-1}), \end{aligned}$$

where the brackets \(\langle \cdot \rangle \) denote the expected excess demand ED. The agent’s action on the market is then determined by a threshold of each agent. The threshold \({\bar{\psi }}_i\) is drawn from a uniform distribution in the interval \([0,\Omega ]\). The trading decision of each agent is characterized by \(\sigma _i=\pm 1\), where \(\sigma _i =1\) represents a buy order and \(\sigma =-1\) a sell order. We have

$$\begin{aligned} \sigma _i(t_k)= {\left\{ \begin{array}{ll} &{} 1,\quad \psi _i(t_k)> {\bar{\psi }}_i,\\ &{}-1,\quad \psi _i(t_k)< -{\bar{\psi }}_i,\\ &{}0,\quad \text {else}. \end{array}\right. } \end{aligned}$$

Furthermore, each agent tracks his number of stocks \(q_i\) and the cash \(w_i\) and thus the trading volume \(v_i(t_k)\) of each agent (in units of stocks) is given by

$$\begin{aligned} v_i(t_k)= {\left\{ \begin{array}{ll} g\ \frac{w_i(t_k)}{S(t_{k})},\quad \sigma _i=1,\\ g\ q_i(t_k),\quad \sigma =-1. \end{array}\right. } \end{aligned}$$

Here, \(S(t_k)\) denotes the stock price and \(g\in (0,1)\) a fixed fraction of wealth each agent wants to invest in stocks. The stock price is then driven by the excess demand \(ED(t_k)\)

$$\begin{aligned} \log (S(t_k)) = \log (S(t_{k-1}))+ ED(t_{k-1}), \end{aligned}$$

where ED is defined as:

$$\begin{aligned} ED(t_k):= \frac{1}{\lambda \ N} \sum \limits _{i=1}^N \sigma _i(t_{k})\ v_i(t_{k}). \end{aligned}$$

The constant \(\lambda >0\) represents the market depth. Finally, we want to state the update mechanism of \(w_i\) and \(q_i\).

$$\begin{aligned}&w_i (t_k)= w_i(t_{k-1}) -\sigma _i(t_{k-1})\ v_i(t_{k-1})\ S(t_k),\\&q_i(t_k) = q_i(t_{k-1})+\sigma _i(t_{k-1})\ v_i(t_{k-1}). \end{aligned}$$

1.2 Technical Details

  • Numerical Discretization With numerical discretization we refer to approximation concepts for time continuous ODEs. The most prominent numerical schemes are the explicit and implicit Euler discretization. We refer to Butcher (2016) for a detailed discussion.

  • Wiener Process A Wiener process is time continuous stochastic process and plays a prominent role in the definition of a stochastic integral. We refer to Evans (2012) for details.

  • Itô SDE The term Itô SDE refers to a SDE defined by the Itô stochastic integrals. In comparison to a differential equation a stochastic process is nowhere differentiable and therefore a SDE is in fact defined as an integral equation. In order to rigorously define an SDE one needs to define a stochastic integral in the first place. For details we refer to Evans (2012).

  • Stratonovich SDE The term Stratonovich SDE refers to a SDE defined by the Stratanovich stochastic integrals. In comparison to a differential equation a stochastic process is nowhere differentiable and therefore a SDE is in fact defined as an integral equation. In order to rigorously define an SDE one needs to define a stochastic integral in the first place. For details we refer to Evans (2012).

1.3 Parameter Sets

Cross Model For simulations using the Cross model, we use the parameters and initial values presented in Table 4.

Table 4 Cross basic setting

LLS Model The initialization of the stock return is performed by creating an artificial history of stock returns. The artificial history is modeled as a Gaussian random variable with mean \(\mu _h\) and standard deviation \(\sigma _h\). Furthermore, we have to point out that the increments of the dividend is deterministic, if \(z_1=z_2\) holds. We used the C++ standard pseudo random number generator for all simulations of the LLS model if not otherwise stated. The parameters and initial values used for simulations using the LLS model are shown in Tables 5 and 6.

Table 5 Basic setting of the LLS model
Table 6 Setting for the LLS model (3 agent groups)

Harras Model The parameters and initial values used for simulations using the Harras Model are shown in Table 7.

Table 7 Harras basic setting

1.4 Software

We aim to explain how we translate our abstract meta-model into software instructions. The centerpiece of our software is the calculation of the excess demand and the price calculator in each time step. Furthermore, one needs to update the action of each agent, which will depend on the stock price and probably on the excess demand.

figure c

Software Classification To facilitate the selection of a proper software tool for other researchers, we classify SABCEMM by the five categories of Nikolai and Madey (2009):

  • Programming language required to create a model or simulation

    • To introduce a new building block programming in C++ is required. From existing building blocks new models/simulations can be configured with XML input files.

  • Operating system required to run the toolkit

    • SABCEMM runs on POSIX (e.g. Linux, macOS) systems with a recent C++ compiler (e.g. g++-7Footnote 12) and CMakeFootnote 13 support.

  • Type of license governing the platform

    • We distribute our software under the 3-clause BSD license.Footnote 14 Accordingly it classifies as free and open-source.

  • Primary domain for which the toolkit is intended

    • Our software is designed for financial market simulations, i.e. it falls in the category Computational economics/Auction mechanisms. SABCEMM enables researchers to do large scale simulations with heterogeneous agent types.

  • Degree of support available to the user of the toolkit

    • A Reference Manual,Footnote 15 a User GuideFootnote 16 and further documentation is provided. Further, bugs and questions can be submitted on GitHub.

HDF5 The Hierarchical Data Format version 5 (HDF5) is a well-known hierarchical file format designed for scientific applications.Footnote 17 The corresponding libraries provides high performance serial and parallel I/O routines. Logically, the data within an HDF5 file is represented as a directory-tree like hierarchy of self-describing datasets, i.e. several datasets can be stored logically separated within a single file and datasets are equipped with a name and information describing data type, encoding, and shape. In addition, HDF5 provides on-the-fly compression of data written.

We decided to use HDF5 as main file format for SABCEMM to facilitate post-processing of the generated data. Data stored in datasets within an HDF5 file can easily be read using either the C and Fortran interfaces,Footnote 18 Python packages, such as h5py,Footnote 19 MATLAB (native support), and Microsoft Excel via the add-in PyHexad.Footnote 20 Finally, the HDF5 format allows us to embed the configuration file used in the generation of the results within the HDF5. This ensures reproducibility of results (besides of differences due to random numbers generated).

Rights and permissions

Reprints and permissions

About this article

Check for updates. Verify currency and authenticity via CrossMark

Cite this article

Trimborn, T., Otte, P., Cramer, S. et al. SABCEMM: A Simulator for Agent-Based Computational Economic Market Models. Comput Econ 55, 707–744 (2020). https://doi.org/10.1007/s10614-019-09910-1

Download citation

  • Accepted:

  • Published:

  • Issue Date:

  • DOI: https://doi.org/10.1007/s10614-019-09910-1

Keywords

Navigation