Insights

How Genetic Algorithms are Used In Trading

Post by
Suraj Venkat
Insights

How Genetic Algorithms are Used In Trading

By
Suraj Venkat
|
December 1, 2021
|
3 Mins Read
How Genetic Algorithms are Used In Trading

There is an increasing trend in the financial sector to solve problems using mathematical methods particularly in the sub-field of active decision-making for capital markets, foreign exchange, and investment credit. The foreign exchange market (FX) is the world's largest financial market, and exchange rates and market timing are at the heart of it. 

A wide range of financial instruments has been developed based on these two. There are a variety of variables that affect exchange rates. Predicting exchange rates using fundamental analysis, which examines all applicable economic and financial indicators, is extremely difficult. There are several ways this difficulty is tackled, and one of them is through the use of ‘genetic algorithms’


What is a Genetic Algorithm?

Genetic Algorithm is a method of searching for exact or approximate solutions to optimization and search problems. It employs evolutionary biology methods such as inheritance, mutation, selection, and crossover. Genetic algorithms operate by applying genetic operators to a population of artificial structures repeatedly. The only prerequisite for Genetic Algorithms is fitness information rather than gradient information. 

Genetic Algorithms may be used for classification or optimization. They have many advantages over traditional parameter optimization techniques, including suitability for ill-behaved problems, highly nonlinear spaces for global optima, and an adaptive algorithm.


Using Genetic Algorithm

Genetic Algorithm uses binary codes. A series, or structure, is created by combining these binary numbers known as chromosomes. Each chromosome bit is treated as a gene. The GA then generates a population of n randomly generated constructs, each of which encodes a solution to the problem at hand. By sequentially using three operators; selection, crossover, and mutation, the GA processes a fixed number of generations or stops once a criterion is met. The structure with the highest fitness value in the previous population is chosen. 

A selection operator implements replication in the GA. However, using the Genetic Algorithm in trading is a one-of-a-kind method for using nature's ability to solve complex problems. Traders can optimize trading rules by identifying the best parameter to use for a given security by using these methods to predict security prices. As a result, GAs are often used as optimizers, adjusting parameters to minimize or maximize some kind of input metric that can then be used independently.


How it works

Genetic algorithms are developed mathematically using vectors, which are quantities that have direction and magnitude. Each trading rule's parameters are expressed by a one-dimensional vector, which can be compared to a chromosome in genetic terms. Meanwhile, each parameter's values can be thought of as genes that are changed by natural selection. 

A trading rule might include parameters such as moving average convergence divergence (MACD), exponential moving average (EMA), and stochastics, for example. The values for these parameters will then be input by a genetic algorithm to optimize net benefit. Small improvements are made over time, and those that have a positive effect are kept for the next generation.

The three types of genetic operations as is in biology can then be performed; crossover, mutation, and selection using the following measures:

  1. Create a random population with each chromosome being n lengths long, where n is the number of parameters. That is, a random number of parameters with n elements each are generated.
  2. Choose the chromosomes (or parameters) that improve desired outcomes (presumably net profit in the case of trading).
  3. Create an offspring by using mutation or crossover operators on the parents you've chosen.
  4. Using the selection operator, recombine the offspring and the existing population to create a new population.
  5. Reverse measures two through four.

This process would produce more favorable parameters (chromosomes) for use in a trading rule over time. When stopping conditions are met, such as running time, fitness, the number of generations, or other criteria, the process is terminated.


References

T.Hellstrom and K.Holmstrom, “The Relevance of Trends for Predictions of Stock Returns”,

International Journal of Intelligent Systems in Accounting, Finance & Management, Wiley & Sons, 2000, Vol.9, pp.23-34.

A.Lipton-Lifschitz, “Predictability and unpredictability in financial markets”, Physica D, Elsevier, 1999, Vol.133, pp.321-347.

Langdon, W. B. (2012). Genetic programming and data structures: genetic programming+ data structures= automatic programming

D.E. Goldberg, Genetic Algorithms in Search, Optimization, and Machine Learning, Addison-Wesley, Reading, MA, 1989.

Using Genetic Algorithms to Forecast Financial Markets. (2021). Retrieved 19 April 2021,

from https://www.investopedia.com/articles/financial-theory/11/

using-genetic-algorithms-forecast-financial-markets.asp#

:~:text=Genetic%20algorithms%20are%20unique

%20ways,parameter%20for%20a%20given%20security.