Skip to main content

A meta-grammatical evolutionary process for portfolio selection and trading


This study presents the implementation of an automated trading system that uses three critical analyses to determine time-decisions and portfolios for investment. The approach is based on a meta-grammatical evolution methodology that combines technical, fundamental and macroeconomic analysis on a hybrid top-down paradigm. First, the method provides a low-risk portfolio by analyzing countries and industries. Next, aiming to focus on the most robust companies, the system filters the portfolio by analyzing their economic variables. Finally, the system analyzes prices and volumes to optimize investment decisions during a given period. System validation involves a series of experiments in the European financial markets, which are reflected with a data set of over nine hundred companies. The final solutions have been compared with static strategies and other evolutionary implementations and the results show the effectiveness of the proposal.

This is a preview of subscription content, access via your institution.

Fig. 1
Fig. 2
Fig. 3
Fig. 4


  1. An algorithm that exists to manipulate some other algorithm.

  2. NET_INC: Total profits.

    MARK_CAP: Total market value of all outstanding shares of a company.

    EBIT: Earnings before interest and taxes.

    EBITDA: Earnings before interest, taxes, depreciation and amortization.

    COM_EQY: Total value of shares issued.

    LT_DEBT: Long-term debt (greater than 1 year).

    TOT_AS: The sum of current and long-term assets.

    SALES: Total volume of sales.

  3. B&H consists of buying at the beginning of the period and selling at the end, and it is widely used as comparison metric.


  1. G.P. Dwyer, R.W. Hafer, The Stock Market: Bubbles, Volatility, and Chaos (Springer, Berlin, 2010)

    Google Scholar 

  2. J.R. Koza, Genetic Programming: On the Programming of Computers by Means of Natural Selection, vol. 1 (MIT Press, Cambridge, 1992)

    MATH  Google Scholar 

  3. M. O’Neill, C. Ryan, Grammatical Evolution: Evolutionary Automatic Programming in an Arbitrary Language (Kluwer Academic Publishers, Dordrecht, 2003)

    Book  MATH  Google Scholar 

  4. I. Dempsey, M. O’Neill, A. Brabazon, Live trading with grammatical evolution, in GECCO 2004 Workshop Proceedings, (Seattle, Washington, 2004), pp. 311–327

  5. A. Brabazon, M. O’Neill, Evolving technical trading rules for spot foreign-exchange markets using grammatical evolution. Comput. Manag. Sci. 1(3), 311–327 (2004)

    Article  MATH  Google Scholar 

  6. I. Dempsey, M. O’Neill, A. Brabazon, Adaptive trading with grammatical evolution, in Proceedings of the 2006 IEEE Congress on Evolutionary Computation (IEEE Press, Vancouver, 2006), pp. 9137–9142

  7. I. Dempsey, M. O’Neill, A. Brabazon, Foundations in Grammatical Evolution for Dynamic Environments (Springer, Berlin, 2009)

    Book  Google Scholar 

  8. A. Brabazon, M. O’Neill, Biologically Inspired Algorithms for Financial Modelling (Natural Computing Series) (Springer, New York, 2006)

    MATH  Google Scholar 

  9. M. O’Neill, C. Ryan, Grammatical Evolution by Grammatical Evolution: The Evolution of Grammar and Genetic Code (Springer, Berlin, 2004)

    Google Scholar 

  10. K. Adamu, S. Phelps, Modelling financial time series using grammatical evolution, in Proceedings of the Workshop on Advances in Machine Learning for Computational Finance, London, (2009)

  11. K. Adamu, S. Phelps, Coevolution of technical trading rules for high frequency trading, in Proceedings of the World Congress on Engineering 2010, WCE’10, London vol I, June 30–July 2, 2010, Lecture Notes in Engineering and Computer Science, eds. by S.I. Ao, L. Gelman, D.W.L. Hukins, A. Hunter, A.M. Korsunsky (International Association of Engineers, Newswood Limited 2010), pp. 96–101

  12. I. Contreras, Y. Jiang, J.I. Hidalgo, L. Núñez, Using a GPU–CPU architecture to speed up a GA-based real-time system for trading the stock market. Soft Comput. 16(2), 203–215 (2012)

    Article  Google Scholar 

  13. I. Contreras, JI. Hidalgo, L. Núñez, Time series of stock prices and randomness: Undercover patterns. In Proceedings of The 2015 Northeast Decision Sciences Institute (NEDSI) conference , March 20 - 22, 2015, Boston, MA, USA, (2015)

  14. I. Arnaldo, I. Contreras, D. Millán-Ruiz, J.I. Hidalgo, N. Krasnogor, Matching island topologies to problem structure in parallel evolutionary algorithms. Soft Computing 17(7), 1209–1225 (2013)

    Article  Google Scholar 

  15. A.W. Lo, Reconciling efficient markets with behavioral finance: the adaptive markets hypothesis. J. Invest. Consult. 7(2), 21–44 (2005)

    Google Scholar 

  16. S. Hao, Q. Jin, G. Zhang, Relative firm profitability and stock return sensitivity to industry-level news. Account. Rev. 86(4), 1321–1347 (2011)

    Article  Google Scholar 

  17. J.L. Bettman, S.J. Sault, E.L. Schultz, Fundamental and technical analysis: substitutes or complements? Account. Finance 49(1), 21–36 (2009)

    Article  Google Scholar 

  18. P.M. Menaje Jr., Impact of selected accounting and economic variables on share price of publicly listed banks in the Philippines from 2002–2008. DLSU Bus. Econ. Rev. 22(1), 35–62 (2012)

    Google Scholar 

  19. A. Hull, Active Investing: How to Manage Your Portfolio Like a Professional in Less than One Hour a Week, Revised Edition (Wiley, Wrightbooks, 2013), p. 232

  20. A.W. Lo, J. Hasanhodzic, CMT Level I 2016: An Introduction to Technical Analysis (Wiley, Hoboken, 2015)

    Google Scholar 

  21. G. Appel, Technical Analysis: Power Tools for Active Investors (Financial Times - Prentice Hall, Upper Saddle River, 2005)

    Google Scholar 

  22. I. Contreras, J.I. Hidalgo, L. Núñez-Letamendia, Combining technical analysis and grammatical evolution in a trading system, in Applications of Evolutionary Computation—16th European Conference, EvoApplications 2013, Vienna, April 3–5, 2013. Proceedings, (2013), pp. 244–253

  23. W.F. Sharpe, Mutual fund performance. J. Bus. 39(1), 119–138 (1966)

    Article  Google Scholar 

  24. C. Israelsen, A refinement to the sharpe ratio and information ratio. J. Asset Manag. 5(6), 423–427 (2005)

    Article  Google Scholar 

Download references


This work was partially supported by the Spanish Government Minister of Science and Innovation under Grant TIN2014-54806-R and the People program (Marie Curie Actions) of the European Union Seventh Framework Programme (FP7/2007–2013) with the Agreement No. 600388 of the REA and the Agencia per a la Competitivitat de L’Empresa (ACCIÓ). J. I. Hidalgo also acknowledges the support of the Spanish Ministry of Education mobility Grant PRX16/00216.

Author information

Authors and Affiliations


Corresponding author

Correspondence to J. Ignacio Hidalgo.

Rights and permissions

Reprints and Permissions

About this article

Verify currency and authenticity via CrossMark

Cite this article

Contreras, I., Hidalgo, J.I., Nuñez-Letamendía, L. et al. A meta-grammatical evolutionary process for portfolio selection and trading. Genet Program Evolvable Mach 18, 411–431 (2017).

Download citation

  • Received:

  • Revised:

  • Published:

  • Issue Date:

  • DOI:


  • Grammatical evolution
  • Automated trading systems
  • Meta-GE
  • Technical analysis
  • Fundamental analysis
  • Macroeconomic analysis