Download as pdf or txt
Download as pdf or txt
You are on page 1of 20

INDEX TRADING USING GRAMMATICAL EVOLUTION

Munagala Venkatesh 200701237 Supervisor Prof. Samaresh Chatterji


1

INDEX
Problem definition Introduction Technical indicators Genetic algorithm Mapping process Fitness function Results Analysis Acknowledgement References

PROBLEM DEFINITION
Implementing

the index trading model developed by Dr. Anthony Brabazon. the performance of the system by changing the genetic parameters.

Improving

INTRODUCTION

Index trading is an example of program trading where a fixed amount of money is invested in the market index (or fixed amount of investment is sold out) based on the trading signal buy (or sell) generated by the trading system. The trading system uses technical indicators for generating the trading signal. Enumeratively trying all possible combinations is very difficult.

TECHNICAL INDICATORS
Moving average:
They compare current price with the moving average of the price. Current price > moving average increasing trend Ma(int, day)

Momentum:

price(t) / price(t-x) market over brought


5

Reduction in upward momentum

Reduction in downward momentum market over sold

GENETIC ALGORITHM

Initially N candidate solutions encoded in the binary strings are selected for first generation. Fitness is calculated for each of them using fitness function defined for that specific problem. Select a pair of binary strings from the current population, the probability of selection being an increase function of fitness. With probability pc crossover the pair to form two offsprings and with probability pm mutate offsprings at each position and finally add them to the new population.

GENETIC ALGORITHM (CONTINUED)

Repeat the previous two steps until the size of new population becomes N. Now replace the current population with new population for the next generation of algorithm. After several generations best solution is evolved.

GENETIC ALGORITHM (CONTINUED)


Selection:

1.) Roulette wheel 2.) Tournament selection


Replacement

1.) General 2.) Steady state

MAPPING PROCESS
<prog> ::= <expr> <expr> ::= <relbi> (<expr>,<expr>) | <fopbi> (<expr>,<expr>) | <expr><matbi><expr> | <var> <relbi> ::= f_and | f_or <fopbi> ::= greater | lesser <matbi> ::= + | - | * <var> ::= <int> | ma( <int> , day ) | momentum ( <int> , day) | trb ( <int> , day)
9

<int> ::= 1 | 2 | 3 | 4 | 5 | 10

MAPPING PROCESS (CONTINUED)

11100010111000011101001010010100101010.. Codons are generated for the binary string taking 8 bits at a time and converting to an integer. 226 225 213 83 .

<fopbi> ::= greater | lesser

Two possibilities, so we use the formula rule = c mod r; c=codon value, r= no. of possibilities. In our example rule = c mod 2 if rule = 0, we choose greater if rule = 1, we choose lesser

10

MAPPING PROCESS (CONTINUED)


Consider the following codon string 225 84 150 34 167 45

Start with the start symbol <prog> <prog> ::= <expr>, only one possibility 225 mod1=0 <expr>::= <relbi> (<expr>,<expr>) | <fopbi> (<expr>,<expr>) | <expr><matbi><expr> | <var>

11

MAPPING PROCESS (CONTINUED)

There are 4 possibilities. Take the nest codon 85 85 mod4 = 1, so choose second possibility <fopbi> (<expr>,<expr>) With the next codon 150, use production rule for the non-terminal from left-side. In this way the codon string can be mapped to a solution like f_and ( lesser ( trb ( 4 , day ) , trb ( 3 , day ) ) , lesser ( momentum ( 1 , day ) , momentum ( 3 , day ) ) )

12

FITNESS FUNCTION

The fitness is calculated over the FTSE data set of 440 days. Using the solution formed from the grammar trading signal (buy or sell ) is generated. According to it $1000 is invested in the market or shares for $1000 are sold out. The total profit gained over 440 days is assigned as fitness to the solution.
13

RESULTS
Replacement: Steady state Selection:Roulette wheel wheel period Training Profit
(days) (US$) Train (75 to 440) Test 1 (440 to 805) Test 2 (805 to 1170) Test 3 (1170 to 1535) Test 4 (1535 to 1900) 4834 5968 -2466 2805 866

Replacement: General Selection: Roulette wheel


Training period (days) Train (75 to 440) Test 1 (440 to 805) Test 2 (805 to 1170) Test 3 (1170 to 1535) Test 4 (1535 to 1900) Profit (US$) 2838 4988 279 2325 812
14

RESULTS (CONTINUED)
Replacement: Steady state Selection: Tournament
Training period (days) Train (75 to 440) Test 1 (440 to 805) Test 2 (805 to 1170) Test 3 (1170 to 1535) Test 4 (1535 to 1900) Profit (US$) 4921 5182 1666 2238 1356

Replacement: General Selection: Tournament


Training period (days) Train (75 to 440) Test 1 (440 to 805) Test 2 (805 to 1170) Test 3 (1170 to 1535) Test 4 (1535 to 1900) Profit (US$) 4584 5780 -2225 2746 971
15

ANALYSIS
Results for the model developed by Anthony Brabazon.
Training period (days) Train (75 to 440) Test 1 (440 to 805) Test 2 (805 to 1170) Test 3 (1170 to 1535) Test 4 (1535 to 1900) Profit (US$) 3071 5244 -1376 1979 1568

Selection: Steady state Replacement: Tournament


Training period (days) Train (75 to 440) Test 1 (440 to 805) Test 2 (805 to 1170) Test 3 (1170 to 1535) Test 4 (1535 to 1900) Profit (US$) 4921 5182 1666 2238 1356
16

CONCLUSION

More profit ($15363) is obtained in case 3 in which selection method and replacement strategy is tournament and steady state respectively. Best individuals of past generations are retained in future generations as we used steady state replacement and at the same time using tournament selection there is a possibility of generating better children with worst parents. Thus the results justified the efficiency of genetic algorithm parameters. The time taken for each run of the genetic algorithm is less than a minute and sometimes it is very fast also, so we can many solve many np-hard problems which requires exponential time using the evolutionary programming approach.

17

ACKNOWLEDGMENT I would like to thank Prof.Samaresh Chatterji for his proper guidance and who was always there to help me whenever I faced the problem.

18

REFERENCES

NYSE(2005). Market Information-Quick reference sheet, http://www.nyse.com Anthony Brabazon, Michael ONeill (2006) Biologically inspired algorithms for financial modeling. pp. 183-192 ISBN 3-540-26252-0 Melanie Mitchell (1996), An Introduction to Genetic algorithms, pp.115, ISBN-81-203-1358-5. Murphy, John J. (1999). Technical Analysis of the Financial markets, New York: New York institute of finance. Brock, W., Lakonishok, J. and LeBaron B. (1992). Simple technical trading rules and the stochastic properties of stock returns, Journal of finance, 47(5):1731-1764. Glassman, R. (1973). Persistence and loose coupling in living systems, Behavioral science18:83-98.
19

THANK YOU

20

You might also like