You are on page 1of 8

<This paper has been submitted for possible publication>

%volving 3hart Aattern :ensitive Neural Network >ased 'orex Trading &gents
&ene I. 'her CorticalComputer(gmail.com )ni"ersity of Central *lorida
enormous dail volume, there are no sudden interda price changes, and there are no lags in the market, unlike in the stock market" This paper presents the first of its kind, an introduction, discussion, anal sis, and application?benchmarking (to the author@s knowledge) of a topolog and weight evolving neural network (T$%&NN) algorithm for the evolution of geometr )pattern sensitive, substrate encoded trading agents that use the actual closing price charts as input" *n this paper * will compare the Arice 3hart *nput (A3*) using neural network (NN) based traders using substrate encoding, to the standard, direct encoded NN based trading agents which use Arice 2ist *nput (A2*), in which the time series of closing prices is encoded as a list of said prices" 'inall , all of these NN based trading agents will be evolved using the memetic algorithm based T$%&NN s stem called +eus %x Neural Network (+,NN)/5,-0" It must be noted that it is not the goal of this paper to compare one TWEANN using PCI to another TWEANN using PCI. The use of DXNN system for this e periment and this paper !as due to the ease !ith !hich it !as possible to apply it to the gi"en problem. The only goal of this paper is to demonstrate the utility of this ne! method# the use of candle$stic% style chart as direct input to the geometry sensiti"e NN system e"ol"ed using a TWEANN system. The use of T$%&NNs in the financial market has thus far been ver seldom, and to this author@s knowledge, the three most general of these state of the art neuroevolutionar algorithms (+,NN, N%&T/B0, C perN%&T/.0, %&NT/90, %&NT-/=0) have not et been thoroughl tested, benchmarked, and applied within this field" *n this paper * will not use the evolved NN based agents to predict currenc pair prices, but instead evolve autonomousl trading NN based agents" Neural networks have shown time and time again /D,E,F,5;,55,5-,5B,590 that due to their highl robust nature, and universal function approximation qualities, that the fit well in the application to financial market anal sis" *n published literature though/5=,5D,5E,5F,-;0, the most commonl used neural network learning algorithm is backpropagation" This algorithm, being a local optimi!ation algorithm, can and does at times get stuck in local optima" 'urthermore, it is usuall necessar for the researcher to set up the NN topolog beforehand, and since the knowledge of what t pe of NN topolog works best for which dataset and market is ver difficult, or even impossible to deduce, one usuall has to randoml create NN topologies and then tr them out before settling down on some particular s stem" T$%&NN s stems are relativel new, and the have not et been tested thoroughl in financial markets" >ut it is exactl these t pes of s stems that can evolve not onl s naptic weights, but also the NN topologies, and thus perform a global search, evolving the most optimal NN topolog and s naptic weights at the same time" The use of such a T$%&NN s stem in evolving NN based traders is exactl what will be explored in this paper" 7utline# *n :ection)- * will briefl discuss 'oreign %xchange market, the various market h pothesis, and the approaches that

ABSTRACT
Though machine learning has been applied to the foreign exchange market for algorithmic trading for quiet some time now, and neural networks(NN) have been shown to ield positive results, in most modern approaches the NN s stems are optimi!ed through traditional methods like the backpropagation algorithm for example, and their input signals are price lists, and lists composed of other technical indicator elements" The aim of this paper is twofold# the presentation and testing of the application of topolog and weight evolving artificial neural network (T$%&NN) s stems to automated currenc trading, and to demonstrate the performance when using 'orex chart images as input to geometrical regularit aware indirectl encoded neural network s stems, enabling them to use the patterns ( trends within, when trading" This paper presents the benchmark results of NN based automated currenc trading s stems evolved using T$%&NNs, and compares the performance and generali!ation capabilities of these direct encoded NNs which use the standard sliding)window based price vector inputs, and the indirect (substrate) encoded NNs which use charts as input" The T$%&NN algorithm * will use in this paper to evolve these currenc trading agents is the memetic algorithm based T$%&NN s stem called +eus %x Neural Network (+,NN) platform"

Categories and Subject Descriptors


*"-". /Computing Methodologies 0# &rtificial *ntelligence 1 2earning, 3onnectionism and neural nets .

General Terms
&lgorithms

Keywords

Neural Network, T$%&NN, %volutionar 3omputation, Neuroevolution, 4emetic &lgorithm, &rtificial 2ife, 'inancial &nal sis, 'orex" 5" *NT67+83T*7N

'

oreign exchange (also known as 'orex, or ',) is a global and decentrali!ed financial market for currenc trading" *t is the largest financial market, with a dail turnover of 9 trillion 8: dollars" The spot market, speciali!ing in the immediate exchange of currencies, comprises almost 9;< of all ', transactions, 5"= trillion dollars dail " >ecause the foreign exchange market is open -9 hours a da , closing onl for the weekend, and because of the

<This paper has been submitted for possible publication>


currenc traders use to make their decisions" :ection)B will discuss how to use candlestick charts themselves as inputs to the NN based s stems, and how to use substrate encoding/.0 so that the NNs are sensitive to geometrical patterns present in these charts" *n :ection) 9 * will introduce the memetic T$%&NN s stem called +,NN, and discuss its various features and applicabilit to price prediction and automated trading, and how it will be used to evolve the direct and indirect encoded NN based currenc trading agents" *n :ection) = * will explain the benchmark setup for the testing of the A3* and A2* using NNs, and how * will gage fitness and generali!ation abilities of the evolved agents" *n :ection). * will present and discuss the benchmark results" 'inall , in :ection)D * will conclude this paper with a summar , conclusions drawn, and proposed future work" combined" Nevertheless, in this paper our NN s stems will primaril concentrate onl on the raw closing price data" Though in the future, the use of neuroevolution for news mining is a definite possibilit , and research in this area is alread in the works"

B" 36%&T*NG & G%74%T6*3&2 6%G82&6*TI &$&6% N%86&2 N%T$76H


Neural Networks have seen a lot of use and success in the financial market/5D,5E,5F,-;0" 7ne of the main strengths of NN s stems, which makes them so popular as market predictors, is that the are naturall non linear, and can learn non linear data correlation and mapping" &rtificial neural networks are also data driven, can be on) line)trained, are adaptive and can be easil retrained when the markets shift, and finall , the deal well with data that has some errorsJ neural networks are robust" $hen traders look at the financial data the do not usuall look Kust at raw price lists, when a trader performs a time series anal sis he instead looks at the chart patterns" This is especiall the case when dealing with a trader prescribing to the technical anal sis approach" The technical anal st uses the various technical indicators to look for patterns and emerging trends in these charts" There are man recurrent patterns within the charts, some of which have been given names, like for example the Lhead and shouldersM in which the time series has B hills, resembling head and shoulders" 7ther such patterns are the Lcup and handleM, the Ldouble tops and bottomsM, the LtrianglesM""" %ach of these geometrical patterns has a meaning to a trader, and is used b the trader to make predictions about the market" $hether these patterns reall do have a meaning or not, is under debate" *t is possible that the fact that so man traders do use these techniques, results in a self fulfilling prophec , where a large number of the traders act similarl when encountering similar geometrical chart patterns, thus making that pattern and its consequence a realit , b all acting in a similar manner that is proscribed b the trend predicting rule of that pattern" The standard neural networks used for price prediction, trend prediction, or automated trading, primaril use the sliding window approach, as shown in 'ig)B"5, where the data is fed as a vector, a price list, to the NN" This vector, whether it holds onl the historical price data, or also various other technical indicators, does not show these existing geometrical chart patterns which are used b the traders" *f the NN does not have a direct access to the geometrical patterns used b human traders, it is at a disadvantage because it does not have all the information on which the other traders base their decisions"
1.6 1.5 1.4 1.3 1.2 1.1

-" '76%*GN %,3C&NG% 4&6H%T


The foreign exchange market, or 'orex, is a global, full distributed, currenc trading financial market" 8nlike the stock market where a single bu er or seller with enough capital can dramaticall change the price of the stock, the forex market is much too vast and distributed for an currenc pair to be so easil affected" 'urthermore, the fact that currencies can be traded non stop, -9 hours a da , = da s a week, there are a lot fewer spaces in the data stream where news might be aggregating but no technical data is available" >ecause of these factors, there is a greater chance that the pricing data does indeed represent the incorporated news and fundamental factors, which might thus allow for prediction and trend finding through the use of machine learning approaches" The question of predicting future market prices of a stock, or currenc pairs as is the case in this paper, has been a controversial one, especiall when using machine learning" There are two main market h pothesis which state that such predictions should be impossible" These two market h pothesis are the %fficient 4arket C pothesis (%4C), and the 6andom $alk Theor (6$T)" The %4C states that the prices full reflect all the available information, and that all new information is instantl absorbed into the price, thus it is impossible to make profits in the market since the prices alread reflect the true price of the traded financial instrument" The 6$T on the other hand states that historical data has no affect on pricing, and that the future price of a financial instrument is completel random, independent of the past, and thus it can not be predicted from it" Iet we know that profit is made b the financial institutions and independent traders in the existing markets, and that not ever individual and institution participating in the trading of a financial instrument has all the available information immediatel at his disposal when making those trades" Thus it can not be true that %4C and 6$T full appl in a non ideal s stem representing the real world markets" Therefore, with a smart enough s stem, some level of prediction above a mere coin toss, is possible" There are two general approaches to market speculation, the technical and the fundamental" Technical anal sis is based on the h pothesis that all reactions of the market to all the news, is contained within the price of the financial instrument" Thus past prices can be studied for trends, and used to make predictions of future prices due to the price data containing all the needed information about the market and the news that drives it" The fundamental anal sis group on the other hand concentrates on news and events" The fundamental anal st peruses the news which cause the prices, he anal !es suppl ( demand, and other factors, with the general goal of acting on this information before others do, and before the news is incorporated into the price" *n general of course, almost ever trader uses a combination of both, with the best results being achieved when both of these anal sis approaches are

1.2 1.3 1.35 1.2

1.5 1.4 1.4 1.5 1.4 ...

Sliding Window
NN System

Prediction

'ig)B"5 :liding window (moving price list) based input

>ut how do we allow the NN to have access to this geometrical pattern data, and also be able to actuall use itN $e can not simpl convert these charts to bitmaps and feed them to the NN, because the bitmap encoded chart will still be Kust a long vector, and the NN will not onl have to deal with an input with high dimensionalit

<This paper has been submitted for possible publication>


(dependent on the resolution of the bitmap), but also there would reall be no connection between this input vector and the actual geometrical properties of the chart that could be exploited" & recentl populari!ed indirect NN encoding approach that has been activel used in computer vision, and which has a natural propert of taking geometrical properties of the input data into consideration, is the substrate (also known as h percube) encoded NN s stem populari!ed b the C perN%&T/.0 implementation" *n the substrate encoded NNs, the inputs and outputs are not fed directl to the neural network, but instead are fed into a substrate, in which the embedded neurodes (each possessing a coordinate) processes the signals and produces the outputs, as shown in 'ig)B"-"
Substrate
1 Not all connections are s&own

neurons in the first neurode plane located at O P ;, and 5,5 neurons in the third plane located at OP5 (as shown in 'ig)B"B), then each of the 5;; neurons at O P ; receives 5;;;;;; inputs, so each has 5;;;;;; s naptic weights, and for this feedforward substrate to process a single input signal would require it 5;;Q5;;;;;; R 5Q5;; calculations, where the 5Q5;; calculations are performed b the neuron at O P 5, which is the output neuron of the substrate" This means that there would be roughl 5;;;;;;;; calculations per single input, per single processing price chart"
Su1strate 2ncoding: 6ray 7 +1 8ar9 6ray 7 , /lac9 7 1
, +1 1 Not all connections are s&own

2ncoding: 3ong 415 S&ort 4+15 Close 4,5

Sense' (n%ut
1 " , +1

, +1

)ct' *ut%ut

1 " , +1

N1: [-1,1,-1] N2: [-1,1,0]

+1 # +1 # Syna%tic Weig&t: [W$ Connected Neurode coordinates: [ 1!"1!#1! 2!"2!#2$ , 1

NN

Syna%tic Weig&t: [W$

Connected Neurode coordinates: [ 1!"1!#1! 2!"2!#2$: [-1,1,-1,-1,1,0]

NN

'ig)B"B & la er)to)la er feedforward substrate processing a -d chart input

'ig)B"- The substrate encoded neural network

&s shown in the above figure, a substrate is a h percube of neurodes, and though in the above figure the dimensionalit is B, it can be an thing" %ach neurode in one la er is connected in a feedforward fashion to the neurodes in the next la er, plane, cube, or h percube, depending on the dimensionalit of the entire substrate" &ll dimensions of the substrate have a cartesian coordinate, and the length of each side of the substrate is normali!ed such that the coordinates for each axis are between )5 and 5" The substrate is impregnated with neurodes, with the number of neurodes per dimension is set b the researcher, with each neurode having a coordinate based on its location in its substrate" $ith this setup, the weight that each neurode has for the pres naptic connection with other neurodes is then determined b the neural network to whom the substrate belongs" *t is the neural network that calculates the s naptic weights for the connected neurodes based on the coordinates of those neurodes" The and pre and post)s naptic neurode coordinates are used as input to the NN" >ecause the NNs deal with coordinates, with the actual data input sent to the substrate, the substrate encoded NN s stem is aware of the geometric regularities within the input" &nd it is these geometric regularities that technical anal sis tries to find and exploit" $ith this t pe of indirect encoded neural network we can anal !e the price charts directl , making use of the geometrical patterns, and trends within" >ecause each neurode in the substrate receives a connection from ever neurode or input element in the preceding h per)la er, the chart that is fed to the substrate must first be reconstructed to the resolution that still retains the important geometrical information, and et is computationall viable as input" 'or example, if the sliding chart that is fed to the substrate is 5;;;x5;;;, which represents 5;;; historical points (hori!ontal axis), with the resolution of the price data being (4axAlotArice 1 4inAlotArice)?5;;; (the vertical axis), then each neurode in the first h perplane of the substrate will have 5;;;;;; inputs" *f the substrate has three dimensions, and we set it up such that the input signals are plane encoded and located at O P )5, with a 5;,5;

Thus it is important to determine and test what resolution provides enough geometrical detail to allow for prediction to be made, et not overwhelm the NN itself and the processing power available to the researcher" 7nce the length of the historical prices (hori!ontal axis on the price chart) and the resolution of the prices (vertical axis on the price chart) are agreed upon, the chart can then be generated for the sliding window of currenc pair prices, producing the sliding chart" 'or example, 'ig)B"9& shows a single frame of the chart whose hori!ontal and vertical resolution is 5;; and -; respectivel , for the %86?8:+ closing prices taken at 5= minute time)frame (pricing intervals)" This means that the chart is able to capture 5;; historical prices, from N to N)FF, where N is the current price, and N)FF is the price (FFQ5=)min ago" Thus, if for example this chart@s highest price was SB";; and the lowest price was S-"=;, and we use a vertical resolution of -;, the minimum discernible price difference (the vertical of the pixel) is (B)-"=)?-; P S;";-=" 'or comparison, 'ig)B"9> shows a5;x5; chart resolution"
). -&e recreated closing %rice c&art wit& an 1,,.2, resolution. /. -&e recreated closing %rice c&art wit& a 1,.1, resolution 0or com%arison.

'ig)B"9 &" and >" show a 5;;x-; and 5;x5; resolution based charts respectivel , using the candle)stick charting st le"

:imilar to 'ig)B"B, in 'ig)B"9 the pixels of the background gra are given a value of )5, the dark gra have a value of ;, and the black a value of 5" These candlestick charts, though of low resolution, retain most of the geometrical regularities and high?low pricing info of the original plot, with the fidelit increasing with the recreated chart@s resolution" *t is this input plane that can be fed to the substrate"

<This paper has been submitted for possible publication> 9" +%8: %, N%86&2 N%T$76H A2&T'764
The topolog and the s naptic weights of the neural networks need to be set and optimi!ed for the tasks the NNs are applied to" 7ne of the strongest approaches to the optimi!ation of s naptic weights and their topologies is through the application of evolutionar algorithms" The s stems that evolve both the topolog and the s naptic weights of neural networks are called Topolog and $eight %volving &rtificial Neural Networks (T$%&NN)" +,NN is a memetic algorithm based T$%&NN s stem, and is the algorithm * will use to evolve the NN based currenc trading agents in this paper" *n this section we will briefl discuss +,NN@s various features, and what makes it different from other T$%&NNs" augmented version of stochastic hill)climbing algorithm)" (ntil" The fitness has failed to increased H number of times" B" 3onvert the NN s stem back to its genot pe, with the tuned s naptic weights, and its fitness score" B" &fter all the NNs have been given a fitness score, sort the NN agents in the population based on their fitness score, which is further weighted based on the NN si!e, such that smaller si!ed NNs are given priorit " 9" +elete the bottom =;< of the population" =" 'or each NN, calculate the total number of N offspring that it is alloted to produce, where N is proportional to the NN@s fitness as compared to the average fitness of the population, and average NN si!e, where the smaller and more fit NNs are allowed to create more offspring" ." 3reate the offspring b first cloning the fit parent, and then appl ing to the clone T number of mutation operators, where T is randoml chosen to be between 5 and sqrt(AarentUTotNeurons), with uniform probabilit " 2arger NNs will produce offspring which have a chance to be produced through a larger number of applied mutation operators" D" 3ompose the new population from the fit parents and their offspring" (ntil" Termination condition is reached (4ax number of evaluations, time, or goal fitness)" $hat in the +,NN is referred to as a Ltuning phaseM is the local search phase of the algorithm, which as noted is an augmented stochastic search algorithm" The topological mutation phase, b randoml choosing the number of mutation operators to use when producing offspring b appl ing the said mutation operators to the clones of the fit parents, allows for a high variabilit of topological mutants to be created, improving the diversit of the population" The +,NN s stem uses the following list of mutation operators# 5" &dd new neuron" -" :plice two neurons (choose - connected neurons, disconnect them, and then reconnect them through a newl created neuron" This also increases the depth of the NN)" B" &dd an output connection to a randoml selected neuron, recurrent or feedforward" 9" &dd an input connection to a randoml selected neuron" =" &dd a sensor ." &dd an actuator Thus through mutation operators = and ., the offspring might incorporate into itself new and still unused sensors and actuators, if those are available in the list of sensors and actuators for its specie?population" *ndeed this particular part of the +,NN acts as a natural feature selection, and is especiall useful for complex problems, in robotics, and alife simulations" *n alife in particular, as was shown in /50, the organisms were able to evolve and integrate new sensors over time" This can also be used in robotics, letting evolution decide what sensors and actuators are most useful to the evolving individual" >ut more importantl , this can be used in evolving algorithmic trades, where :ensors can represent the different t pes of technical indicators" 'urthermore, +,NN evolves both, direct and indirect (substrate in this case) encoded NNs" $here its substrate encoded NNs further differ in their abilit to evolve different t pes of coordinate based preprocessors, which is hoped to allow it to deal with a more varied number of geometrical features, and was another reason for choosing it in this experiment" & further elaboration on this is discussed next"

9"5 TC% 4%4%T*3 &AA67&3C T7 :IN&AT*3 $%*GCT 7AT*4*O&T*7N


The standard genetic algorithm performs global and local search in a single phase" & memetic algorithm separates these two searches into separate stages" $hen it comes to neural networks, the global search is the optimi!ation and evolution of the NN topolog , while the local search is the optimi!ation of the s naptic weights" >ased on the benchmarks, and &2ife performance of +,NN/50, the memetic approach has shown to be highl efficient and agile" The primar benefit of separating the two search phases is due to the importance of finding the right s naptic weights for a particular topolog before considering that topolog to be unfit" *n standard T$%&NNs, a s stem might generate an optimal topolog for the problem, but because during that one innovation of the new topolog the s naptic weights make the topolog ineffective, the new NN topolog is discarded" &lso, in most T$%&NNs, the s naptic weight perturbations are applied indiscriminatel to all neurons of the NN, thus if for example a NN is composed of 5 million neurons, and a new neuron is added, the s naptic weight mutations might be applied to an of the now existing 5;;;;;5 neurons""" making the probabilit of optimi!ing the new and the right neuron and its s naptic weights, ver low" The +,NN platform evolves a new NN topolog , and then through the application of an augmented stochastic search with random restarts optimi!es the recentl added s naptic weights for that topolog " Thus when the Ltuning phaseM, as is the local search phase is called in the +,NN platform, has completed, the tuned NN has roughl the best set of s naptic weights for its particular topological architecture, and thus the fitness that is given to the NN is a more accurate representation of that NN@s true potential" 'urthermore, because the s naptic weight optimi!ation through perturbation is not applied to all the neurons indiscriminatel throughout the NN, but instead is concentrated on the newl mutated, augmented, or mutationall affected neurons, the tuning phase optimi!es the new additions to the NN, making those new elements work with the existing, alread evolved and proven architecture" 3ombined together, the +,NN@s approach to neuroevolution tends to produce a more efficient and concise NN s stems" The benchmarks in paper /50 demonstrated it to rapidl evolve neurocontrollers for agents in the &2ife simulation, which gives hope that this neuroevolutionar s stem is also powerful enough to produce positive results in this application, and is the reason +,NN was chosen for this paper"

9"- TC% +,NN N%867%T728T*7N&6I A673%::


The +,NN evolutionar algorithm performs the following steps# 5" 3reate a seed population of topologicall minimalistic NN genot pes" ! Do" 5" 3onvert the genot pes to phenot pes" ! Do #or e$ery %% &Apply parametric tuning'" 5" Test the fitness of the NN s stem" -" 7ptimi!e the s naptic weights through the application of s naptic weight tuning (&n

<This paper has been submitted for possible publication> 9"B +*6%3T &N+ *N+*6%3T %N37+*NG
The +,NN platform evolves both direct and indirect encoded NN s stems" The direct encoded NN s stems were discussed in the above sections, the indirect encoded NNs use substrate encoding" :ince it is the substrate that accepts inputs from the environment and outputs signals to the outside world, and the NN is used to set the s naptic weights between the neurodes in the substrate, the s stem not onl has a set of sensors and actuators as in the standard NN s stem, but also a set of LcoordinateUpreprocessorsM and LcoordinateUpostprocessorsM, that are integrated into the NN during evolution in a similar manner that it integrates new sensors and actuators, onl using the LaddUcoordUpreprocessorM and LaddUcoordUpostprocessorM mutation operators" *n the standard substrate encoded NN s stem, the NN is given an input that is a vector composed of the coordinates of the neurode for which the s naptic weight must be generated, and the coordinates of the pres naptic neurode which connects to it" *n +,NN, there are man different t pes of coordinateUpreprocessors and coordinateUpostprocessors available" The coordinateUpreprocessors calculate values from the coordinates passed before feeding the resulting vector signals to the NN" The coordinateUpostprocessors post process the NN@s output, adding plasticit and other modifications provided b the particular substrateUactuator incorporated into the s stem through evolution" $heres C perN%&T which populari!ed substrate encoding, feeds the 3ANN (a NN that uses tanh, and other t pes of activation functions) simpl the coordinates of the pres naptic and posts naptic neurodes, and in some variants the distance between the neurodes, the +,NN uses the following list of coordinateUpreprocessors" &ll of these are available to the substrate encoded NNs in this paper, and can be integrated and used b the substrate encoded NN as it evolves# 5" 3artesian 3oordinates -" 3artesian +istance B" 3onvert to Aolar (if substrate is a plane) 9" 3onvert to :pherical (if substrate is a cube) =" 3entripetal distance of neurode ." +istance between coordinates D" Gaussian processed distance between coordinates This set of substrate sensors further allow the evolved NN to extract geometrical patterns and information from inputs" &lso, +,NN allows the evolved neurons to use the following list of activation functions# /tanh#gaussian#sin#absolute#sgn#linear#log# s+rt, , whether those neurons are used b standard direct encoded NNs, or NNs used to calculate weights for the substrate encoded s stems" $hich the creator of +,NN hopes will further improve the generalit of the evolve NN s stems, and has indeed shown benefit when evolving standard neurocontrollers for the double) pole balancing benchmark, in which the problems were solved faster b NNs that used sinusoidal activation functions" 'or this benchmark * created a forex market simulator, where each interfacing NN will be given a SB;; starting balance" %ach agent produces an output, with the output being further converted to ) * i# its less than +,!-, , i# between +,!- and ,!-, and * i# greater than ,!-" $hen interacting with the forex simulator, )5 means go short, ; means close position (or do nothing if no position open), and 5 means go long (if currentl shorting, then close the position, and then go long)" The 'orex simulator will simulate the market using 5;;; real %868:+ currenc pair closing prices, stretching from -;;F)55)=)--#5= to -;;F)55)-;)5;#5=, with 5= min time frame (each closing price is 5= minutes from the other)" The simulator uses a price spread of S;";;;5="This 5;;; point dataset is split into the training set, and into a testing?generali!ation set" The training set is the first E;; time steps, ranging from# -;;F)55)=)--#5= to -;;F#55)5E)E#5=, and the testing?generali!ation data set is the immediatel following -;; time steps from -;;F)55)5E)E#5= to -;;F)55)-;)5;#5=" 'inall , when opening a position, it is alwa s done with S5;;, leveraged b x=; to S=;;; (due to the use of a flat spread and bu ?sell slots, the results can be scaled)" & single evaluation of a NN is counted if the NN based agent has went through all the E;; data points, or if its balance dips below S5;;" The fitness of the NN is its networth at the end its evaluation" %ach evolutionar run lasts for -=;;; evaluations, and each experiment is composed of 5; such evolutionar runs" *n each experiment the population si!e was set to 5;" 'inall , in ever experiment the NNs were allowed to use and integrate through evolution the following set of activation functions# -tanh# gaussian# sin# absolute# sgn# linear# log# s+rt,. The remainder of the parameters were set to the values recommended in /50" *n the experiments performed, the NNs used price sliding window vectors (for direct encoded NNs), and price charts (for recurrent substrate encoded NNs) as shown in 'ig)="5" The NNs were also connected to a sensor which fed them the vector signal# /Aosition,%ntr ,Aercentage3hange0, where Aosition takes the value of either )5 (currentl shorting), ; (no position), or 5 (currentl going long), %ntr is the price at which the position was entered (or set to ; if no position is held), and Aercentage3hange is the percentage change in the position since entr " *n this paper * present 5B benchmarks?experiments, each experiment is composed of 5; evolutionar runs from which its average?max?min are calculated" The experiments demonstrate and compare the performance of A3* based NNs and the A2* based NNs" >oth these input t pe experiments were tested with different sensors of comparable dimensionalit " - ./0 e1periments" %xperiments 5)= were performed using with A2* NNs" %ach experiment differed in the resolution of the sliding window input the NNs used" %ach NN started with the sliding window sensor, and the vector# /Aosition, %ntr , Aercentage3hange0" The networks were allowed to evolve recurrent connections" These = experiments are# 5" /:liding$indow=0 -" /:liding$indow5;0 9" /:liding$indow-;0 9" /:liding$indow=;0 =" /:liding$indow5;;0 2 .C0 e1periments" %xperiments .)5B were preformed using the A3* NNs" *n these experiments each A3* based NN used a 9 dimensional substrate" The input h perla er to the substrate was composed of the price chart, the vector# /3urrentAosition, %ntr Arice, Aercentage3hange0, and the substrate@s own output, making the substrate 3ordan Recurrent " The substrate architecture of these 3A* NN based agents is shown in 'ig)="5" The reason for using Vordan 6ecurrent substrates is due to the fact that standard feedforward substrates which do not have recurrent connections, though achieving high fitness during training, did not generali!e almost at all during m preliminar experimentation, with the highest achieved balance during generali!ation testing phases being SB;B (a SB profit), but

=" TC% %,A%6*4%NT&2 :%T8A


The - goals of this paper is to test the applicabilit and effectiveness of T$%&NN s stems in the evolution of automated currenc trading NN based agents, and the testing and comparison of the effectiveness?profitabilit and generali!ation properties of the Arice 2ist *nput (A2*) based NNs, and the Arice 3hart *nput (A3*) used b geometrical pattern aware substrate encoded NNs" The h pothesis is that the A3* NNs will have much more information (&ctual geometrical properties of the chart, including the relative pricing) than the standard A2* based NNs, which do not have access to the geometrical properties of the charts"

<This paper has been submitted for possible publication>


usuall dipping below S-=; (a S=; loss) during most evolutionar runs" Thus for the A3* based NNs, * created a 9 dimensional substrate (the 9th dimension was called H) with an input h perplane composed of the noted B planes and located at H P )5, all of which connected to the =,= hidden plane positioned at H P ;, which then further connected to the 5,5 output plane (a single neurode) located at H P 5, which output the short?hold?long signal and which was also fed back to the substrate@s input h perplane" %ach of the 5; experiments used price chart inputs of differing resolutions# 5" /3hartAlane=,5;0, -" /3hartAlane=,-;0 B" /3hartAlane5;,5;0 9" /3hartAlane5;,-;0 =" /3hartAlane-;,5;0 ." /3hartAlane-;,-;0 D" /3hartAlane=;,5;0 E" /3hartAlane=;,-;0"
Price C&art

trading the currencies onl if the profit gained before the trend changes will be greater than the spread" Table 1. Benchmark/Experiment Results
TrnA$g TrnBst =9; =-B =BD =-= =9E 9.9=9 =5D =;= =9. =9= ==; =9E =BE =-. ==E 9E5 9.. =-D =59 ==F ==D =95 =.D N/A "0# Tst TstA$g TstStd TstBst 5rst --= -9= -B= -.. -E9 *9 : *2, *2, *2; * ::* N/A N/A -FE -FB -FB B;; B;9 -E9 -FD -BE -B; -=9 -D-DF -D; 300 N/A 5B 5. 5= F 59 BBE B-. -F B. -B -; N/A N/A B=. BB5 B=B B=B B.D B9. B== B;; -FB5= B-E B-B B=9 N/A #$% .rice 8ector Sensor Type /:lid$indow=0 /:lid$indow5;0 /:lid$indow-;0 /:lid$indow=;0 /:lid$indow5;;0 /3hartAlane=,5;0 /3hartAlane=,-;0 /3hartAlane5;,5;0 /3hartAlane5;,-;0 /3hartAlane-;,5;0 /3hartAlane-;,-;0 /3hartAlane=;,5;0 /3hartAlane=;,-;0 Buy & H l! &ax ' ssible

) 0our dimensional su1strate


Not all connections are s&own

[Position!2ntry!PercentageC&ange$

"

" " # +1 : # , # 1

=B==E 311 N/A

Connected Neurode coordinates: [ 1!"1!#1!:1! 2!"2!#2!:2$

Syna%tic Weig&t: [W$

NN

'ig)="5 & Vordan 6ecurrent, 9 dimensional substrate encoded NN

To test generali!ation abilities of the evolved NN based agents, ever =;; evaluations the best NN in the population at that time is applied to the -;; data point generali!ation test" Aerforming the generali!ation tests consistentl throughout the evolution of the population not onl tests the generali!ation abilit of the best NN in the population, but also builds a plot of the general generali!ation capabilities of that particular encoding and sensor t pe" This will allow us to get a better idea of whether generali!ation drops off as the A3* and A2* NNs are over)trained, or whether it improves, or sta s the same throughout the training process"

." >%N3C4&6H 6%:82T: ( +*:38::*7N


The general results of the benchmarks are shown in Table)5" The values for this table were computed as follows# Training A$erage 4itness &TrnA$g' P The average fitness score calculated from the 5; evolutionar runs, reached during the last generation of the population" Training Best 4itness &TrnBst' P The highest achieved fitness amongst the 5; evolutionar runs for that experiment" Test 5orst 4itness &Tst5rst' P The worst generali!ation?test fitness achieved amongst the 5; evolutionar runs" Test A$erage &TstA$g' P The average fitness achieved between all the evolutionar runs during the generali!ation?test phase" Test Standard De$iation &TstStd' P The standard deviation calculated from all evolutionar runs during the test phase" Test Best 4itness &TstBst' P The best fitness achieved amongst the 5; evolutionar runs during the generali!ation?test phase" &t the bottom of the table * list the Buy 6 7old strateg , and the Ma1imum .ossible profit results" The >u ( Cold profits are calculated b bu ing trading the currencies at the ver start of the training or testing run respectivel , and then trading back at the end" The best possible profit is calculated b looking ahead and

'irst, we note that the generali!ation results for both, the A3* based NNs and A2* based NNs show profit" The profits are also relativel significant, thus showing that the application of topolog and weight evolving artificial neural network s stems is viable within this field, and warrants significant further exploration in other time series anal sis applications" 'or example the highest profit reached during generali!ation, S.D out of the S5-E possible when the agent started with B;;S, making S5;; with =; leverage based trades, shows that the agent was able to extract =-< of the available profit" This is substantial, but we must keep in mind that though the agents were used on real world data, the were still onl trading in a simulated market" *t is onl after these agents are allowed to trade in real time and using real mone , would it be possible to sa with certaint that these generali!ation abilities carr over, and for how man time)steps before the agents require re)training (*n the experiment the agents are trained on E;; time steps, and tested on the immediatel followed 5;; time steps)" >ut looking at the table, the difference between A2* and A3* based NNs do show some strange anomalous" The A3* based experiment results are particularl surprising" The first thing we notice is that the A3* NN generali!ation phase@s worst performers are significantl worse than those of the A2* based NNs" The A3* based NNs either generali!ed well during an evolutionar run, or lost significantl " The A2* based NNs mostl kept close to B;; during generali!ation test phase when not making profit" &lso, on a"erage the best of A3* are lower than those produced b A2* during generali!ation" The training fitness scores are comparable for both the A3* and A2* NNs" &nother observation we can make is that higher price resolution (,-; Ts" ,5;) correlates with the A3* NNs to achieving higher profit during generali!ation testing" &nd finall , we also see that for both A2* and A3*, generali!ation achieved b = and 5;; based windows price windows is highest" >ased on Table)5, at the face of it, it would seem as if the original h pothesis about the effectiveness of A3* NNs, and their expected superior generali!ation was wrong" >ut this changes if we now plot the best training fitness vs evaluations, and the best generali!ation test fitness vs evaluations, as shown in 'ig)."5"

<This paper has been submitted for possible publication>

'ig)."5 A2* ( A3* based LTraining and Testing 'itness Ts" %valuationsM

'ig)."B A3* based LGenerali!ation Testing 'itness Ts" %valuationsM

Though difficult to see in the above plot, we can make out that though es the A2* NNs did achieve those generali!ation fitness scores, the were simpl blips during the experiment, occurring a few times, and then disappearing, diving back under B;;" 7n the other hand though, the A3* NNs produced lower profits on average when generali!ation was tested, but the produced those profits consistentl , the generali!ed ver well" This is easier to see if we anal !e the graph of A2* Generali!ation 'itness Ts" %valuations, shown in 'ig)."-, and the A3* Generali!ation 'itness Ts" %valuations, shown in 'ig)."B"

2ets now anal !e 'ig)."B, the generali!ation results for Kust the A3* based NN s stems" The stor here is ver different" Not onl there are more consistentl higher than B;; generali!ation fitness scores in this graph, but also the last throughout the entire -=;;; evaluations" This means that there are more agents that consistentl generali!e, reaching the profitabilit in this graph" $hich gives hope that the generali!ation abilit of these A3* NN based s stems will carr over to real world trading" $hen going through raw data, it was usuall the case that for ever A2* NN based experiment, onl about 5)- in 5; evolutionar runs had a few agents which generali!ed for a brief while to scores above B-;" 7n the other hand when going through the A3* NN based experiments, B). out of 5; evolutionar runs had agents generali!ing consistentl , with scores above B-;" The more conservative A3* NNs are much more consistent" Their generali!ation sta s, and if we look at the above figure, we see that those A3* NNs that have generali!ation fitness over B;;, usuall retain it throughout the evaluations" Thus both of the original h pothesis are confirmed" 5" Topolog and $eight %volving &rtificial Neural Networks are indeed useful within this field, and their percentage profits are higher than those reported in the references papers which used backprop algorithms in optimi!ation of static topolog based NNs" &nd -" Geometrical pattern sensitive, price chart input based NNs do work, the NNs learned how to trade currencies based on geometrical patterns within the charts, looking at the trends and patterns, and were able to generali!e much better" Thus this new proposed method of evolving geometrical pattern sensitive currenc trading agents is viable" >ut there were a few issues, and when experimenting with A3* NNs, problems did show up" 'irst, the standard substrate h percube/.0 topologies are la er)to)la er feed forward topologies, and full connected topologies" * did experiment using feedforward substrates, but the could not generali!e in this domain, and their produced fitness scores were bellow -F;" This might be due to their abilit to memori!e, but without an recurrent connections, lacking the abilit to generali!e to previous unseen data, substrate topolog based anomalies will need to be anal !ed in future work" &lso, the full connected substrate topologies did not generali!e with as high a stabilit as the Vordan 6ecurrent (V6) topologies used in this paper" The results of using feedforward substrates where each neurode was recurrentl connected to itself did not produce results better than a V6 substrate either" * also noted that the low resolution substrates produce at times better results, and do so more often, than their high resolution

'ig)."- A2* based LGenerali!ation Testing 'itness Ts" %valuationsM

*f we look at :liding$indow5;;, produced b plotting the best generali!ation scores from the 5; evolutionar runs of that experiment, we see that the score of B.D was achieved briefl , between roughl the evaluation number =;;; and 5;;;;" This means that there was most likel onl a single agent out of all the agents, in the 5; evolutionar runs, that achieved this, and then onl briefl so" 7n the other hand, we also see that maKorit of the points are at B;;, which implies that most of the time, the agents did not generali!e" &nd as expected, during the ver beginning, evaluations ; to about B;;;, there is a lot more activit amongst all sliding window resolutions, which produce profits" The most stable generali!ation and thus profitabilit was shown b :liding$indow= and :liding$indow5;;, and we know this because in those experiments, there were a lot more fitness scores above B;;, consistentl " 'rom this, we can extract the fact that during all the experiments, there are onl a few agents that generali!e well, and do so onl briefl , when it comes to A2* based NNs"

<This paper has been submitted for possible publication>


counterparts""" This is due to the fact that b increasing the number of neurodes in one la er, the neurodes in the posts naptic la er will now have so man inputs that the become saturated, becoming unable to function effectivel " :caling and normali!ing the pres naptic vectors for ever neurode did not seem to improve this problem significantl , leaving this anomal to future work as well" These problems make it clear that further experimentation with various substrate topologies is a must" $hen anal !ing the topolog of the best performing A2* NNs, it was clear that the all had one feature in common, the all had a substantial number of recurrent connections" &nd indeed it was those A2* NNs which used the sliding window vectors of si!e = that seemed to be better at generali!ing, which * believe was due to it being difficult for them to evolve simple memori!ation of signals when using such a small sliding window, which required the evolution of recurrent connections, and which would then help with the abilit to generali!e" >ut this is Kust a h pothesis at the moment"

6%'%6%N3%:
/50 /-0 :her, G", (preprint)# L+,NN Alatform# :hedding the >iological *nefficienciesM, ar,iv#5;55".;--vB /cs"N%0 :her, G", L+,NN# evolving complex organisms in complex environments using a novel tweann s stemM, G%337 @55 Aroceedings of the 5Bth annual conference companion on Genetic and evolutionar computation" :tanle , H"7", 4iikkulainen, 6"# %volving neural networks through augmenting topologies" %volutionar 3omputation 5;(-) (-;;-) FF15-D Hassahun, I", :ommer, G"# %fficient reinforcement learning through evolutionar acquisition of neural topologies" *n# Aroceedings of the 5Bth %uropean : mposium on &rtificial Neural Networks (%:&NN -;;=), >ruges, >elgium (-;;=) -=F1-.. Nils T :iebel and :ommer, G"# %volutionar reinforcement learning of artificial neural networks" *nternational Vournal of C brid *ntelligent : stems 9(B)# 5D5)5EB, 7ctober -;;D" Gauci, V", :tanle , H"7"# Generating large)scale neural networks through discovering geometric regularities" *n# Aroceedings of the Fth annual conference on Genetic and evolutionar computation" pp" FFD15;;9" &34, New Iork, NI (-;;D) Tersace, 4", >hatt, 6", Cinds, 7", :hiffer, 4" LAredicting the exchange traded fund +*& with a combination of genetic algorithms and neural networks"M %xpert : stems with &pplications" -D (B), pp" 95D)9-=" Iao, V" and Aoh, C"2", LArediction the H2:% *ndex 8sing Neural Networks"M *%%% *nternational 3onference on &rtificial neural networks" Himoto, T", &sakawa, H", Ioda, 4" and Takeoka, 4" (5FF;)" :tock market prediction s stem with modular neural networks" *n Aroceedings of *V3NN)F;"

/B0 /90

/=0

/.0

D" 37N328:*7N &N+ '8T86% $76H


*n this paper * presented the performance, profitabilit , and generali!ation of Price .ist Input using NNs# directl encoded, and the Price Candle$'tic% Chart Input using# geometrical pattern sensiti"e NNs" * presented a completel new t pe (to this author@s knowledge) of trading and prediction s stem that uses the actual charts of financial instruments as input, thus letting the evolved NNs take into account the geometrical patterns of the financial data when making predictions and trading" The h pothesis that Topolog and $eight %volving &rtificial Neural Network (T$%&NN) s stems could effectivel evolve currenc trading agents was shown, based on the generali!ation results, to be correct " Iielding higher profits, and with some agents being able to extract as much as =-< of possible profit during generali!ation tests" The h pothesis that geometrical pattern sensitive NN s stems could indeed trade profitabl and generali!e much better and more consistentl than standard A2* NNs proved to be correct " Though at the start it seemed as if the A2* NNs generali!ed better, after anal !ing 'ig)."- we saw that there were onl a few agents, and onl for a brief time, which generali!ed during testing, but the rapidl disappeared" $hile the A3* NNs generali!ed consistentl during testing, holding profitabilit throughout -=;;; evaluations" &t the same time * noted that it took a lot of experimentation with different t pes of substrate topologies, and that though Vordan 6ecurrent topolog allowed for the substrate encoded NNs to generali!e, others did not fair as well" Thus, more exploration of the various different topologies is needed" %xperimentation with free)form substrate topolog (where the substrates evolve, with new neurons being integrated and forming new feedforward and recurrent connections over time""") should be undertaken in future work" 'urthermore, an expanded set of indicators must also be included in the next phase of testing the use of geometrical anal sis based foreign exchange currenc trading agents" *n this future work, we could have the input h perplanes be composed of multiple 3A*s, having different time)frames, and showing different indicators, and even different currenc pairs" * set out in this paper to show that T$%&NN s stems have a place in evolving financial instrument trading agents, and the presented experiments proved this to be a correct h pothesis" * also set out to demonstrate a new t pe of NN based trading agent, one that uses the geometrical patterns within the charts to trade currenc pairs, and the demonstration showed that these t pe of NNs can indeed trade profitabl , and generali!e better than their standard sliding window input based NN counterparts" The fact that this new approach is effective, gives me hope that it can be applied efficientl to time series anal sis in other fields"
/D0

/E0

/F0

/5;0 Cutchinson, Vames 4" &ndrew $"2o and Tomaso Aoggio ,L& Non) Aarametric &pproach to Aricing and Cedging +erivatives :ecurities Tia 2earning Networks"M , The Vournal of 'inance, Tol" ,2*,, No"B, Vul " /550 6efenes , &"N", >ent!, I" >unn, +"$", >urgess, &"N" and Oapranis, &"+" L'inancial Time :eries 4odeling with +iscounted 2east :quares back Aropagation"M, Neuro 3omputing Tol" 59, pp"5-B)5BE" /5-0 Iuhong 2i and $eihua 4a , L&pplications of &rtificial Neural Networks in 'inancial %conomics# & :urve M, Cangshou, OheKiang 3hina" /5B0 6ong)Vun 2i, Ohi)>in ,iong, LArediction stock market with fu!! neural networksM, Aroceedings of the 'ourth *nternational 3onference on 4achine 2earning and 3 bernetics, Guang!hou, 5E)-5 &ugust -;;=" /590 Vacek 4and!iuk and 4arcin Varus!ewic! , LNeuro)evolutionar approach to stock market predictionM , Aroceedings of *nternational Voint 3onference on Neural Networks, 7rlando, 'lorida, 8:&, &ugust 5-)5D, -;;D,*%%%" /5=0 :neha :oni, L&pplications of &NNs in :tock 4arket Arediction# & :urve M *V3%T, 55);-);B" /5.0 &2ife through +,NN# http#??www" outube"com?user?+,NNs stemN blendP5(obP=Wp?a?u?5?C!s+OtE%7D; /5D0 Calbert $hite,M %conomic prediction using neural networks# the case of *>4 dail stock returnsM +epartment of %conomics 8niversit of 3alifornia, :an +iego" /5E0 +ogac :enol,M Arediction of stock price direction b artificial neural network approachM, -;;E" /5F0 Takashi Iamashita, Hotaro Cirasawa, Vinglu Cu , L&pplication of 4ulti) >ranch &rtificial neural networksto :tock 4arket AredictionM, Aroceedings of *nternational Voint 3onference on Neural Networks, 4ontreal, 3anada, -;;= /-;0 Xui) ong Ohao, ,iao u Ohao, 'u +uan , LArediction 4odel of :tock Arices >ased on 3orrelative &nal sis and Neural NetworksM -;;F :econd *nternational 3onference on *nformation and 3omputing :cience , -;;F, pp# 5EF)5F- , *%%%" /-50 >rian G" $oolle and Henneth 7" :tanle , L%volving a :ingle :calable 3ontroller for an 7ctopus &rm with a Tariable Number of :egmentsM *n# Aroceedings of the 55th *nternational 3onference on Aarallel Aroblem :olving 'rom Nature (AA:N -;5;)" New Iork, NI# :pringer

You might also like