an empirical methodology for developing stockmartket trading systems using neural networks

Upload: bo-ferris

Post on 08-Aug-2018

212 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/22/2019 An Empirical Methodology for developing stockmartket trading systems using neural networks

    1/18

    Bond University

    ePublications@bond

    Information Technology papers Faculty of Business

    1-1-2009

    An empirical methodology for developingstockmarket trading systems using articial neural

    networksBruce J. VanstoneBond University, [email protected]

    Gavin FinnieBond University, [email protected]

    Follow this and additional works at: hp://epublications.bond.edu.au/infotech_pubs

    Part of the Business Commons

    is Journal Article is brought to you by the Faculty of Business atePublications@bond. It has been accepted for inclusion in Information Technology

    papers by an authorized administrator of ePublications@bond. For more information, please contactBond University's Repository Coordinator.

    Recommended CitationBruce J. Vanstone and Gavin Finnie. (2009) "An empirical methodology for developing stockmarkettrading systems using articial neural networks",, .

    hp://epublications.bond.edu.au/infotech_pubs/21

    http://epublications.bond.edu.au/?utm_source=epublications.bond.edu.au%2Finfotech_pubs%2F21&utm_medium=PDF&utm_campaign=PDFCoverPageshttp://epublications.bond.edu.au/infotech_pubs?utm_source=epublications.bond.edu.au%2Finfotech_pubs%2F21&utm_medium=PDF&utm_campaign=PDFCoverPageshttp://epublications.bond.edu.au/business?utm_source=epublications.bond.edu.au%2Finfotech_pubs%2F21&utm_medium=PDF&utm_campaign=PDFCoverPageshttp://epublications.bond.edu.au/infotech_pubs?utm_source=epublications.bond.edu.au%2Finfotech_pubs%2F21&utm_medium=PDF&utm_campaign=PDFCoverPageshttp://network.bepress.com/hgg/discipline/622?utm_source=epublications.bond.edu.au%2Finfotech_pubs%2F21&utm_medium=PDF&utm_campaign=PDFCoverPageshttp://epublications.bond.edu.au/mailto:[email protected]:[email protected]://epublications.bond.edu.au/http://network.bepress.com/hgg/discipline/622?utm_source=epublications.bond.edu.au%2Finfotech_pubs%2F21&utm_medium=PDF&utm_campaign=PDFCoverPageshttp://epublications.bond.edu.au/infotech_pubs?utm_source=epublications.bond.edu.au%2Finfotech_pubs%2F21&utm_medium=PDF&utm_campaign=PDFCoverPageshttp://epublications.bond.edu.au/business?utm_source=epublications.bond.edu.au%2Finfotech_pubs%2F21&utm_medium=PDF&utm_campaign=PDFCoverPageshttp://epublications.bond.edu.au/infotech_pubs?utm_source=epublications.bond.edu.au%2Finfotech_pubs%2F21&utm_medium=PDF&utm_campaign=PDFCoverPageshttp://epublications.bond.edu.au/?utm_source=epublications.bond.edu.au%2Finfotech_pubs%2F21&utm_medium=PDF&utm_campaign=PDFCoverPages
  • 8/22/2019 An Empirical Methodology for developing stockmartket trading systems using neural networks

    2/18

    An Emperical Methodology for Developing Stockmarket

    Trading Systems using Artificial Neural Networks

    Bruce VanstoneBond University

    Gold Coast, Queensland,Australia

    [email protected]

    Gavin FinnieBond University

    Gold Coast, Queensland,Australia

    [email protected]

    ABSTRACT

    A great deal of work has been published over the past

    decade on the application of neural networks tostockmarket trading. Individual researchers have

    developed their own techniques for designing and testingthese neural networks, and this presents a difficultywhen trying to learn lessons and compare results. Thispaper aims to present a methodology for designing

    robust mechanical trading systems using soft computingtechnologies, such as artificial neural networks. This

    methodology describes the key steps involved in creatinga neural network for use in stockmarket trading, andplaces particular emphasis on designing these steps tosuit the real-world constraints the neural network will

    eventually operate in. Such a common methodologybrings with it a transparency and clarity that should

    ensure that previously published results are both reliableand reusable.

    1. INTRODUCTIONArtificial Neural Networks (ANNs) have earnedthemselves an excellent reputation as non-linearapproximators. According to Tan [1], of all the AItechniques available, ANNs are the technique whichdeals best with uncertainty. Like other forms of soft-computing, ANNs exhibit a high tolerance toimprecision and perform well in noisy dataenvironments.

    These characteristics of ANNs make them particularlysuited to financial problem domains, particularly thearena of financial trading. The stockmarket represents a

    datasource with an abundance of uncertainty and noise.Indeed, it is these characteristics which make financialtrading both particularly challenging and particularlyrewarding.

    There have been repeated attempts by a number ofresearchers to apply ANNs to the problem of developingmechanical trading systems. In this context, amechanical trading system is one which operatesaccording to a fixed set of rules, and contains nodiscretionary components. Unfortunately, there are anumber of concerns with the manner in which this fieldappears to have progressed.

    Principal amongst these concerns is a lack of a formalmethodology describing the procedure to follow tocreate mechanical trading systems using soft computing,indeed, a lack of a formal methodology describing how

    to create any mechanical trading systems. The reasonsfor this are crystal clear. Successful systems traders

    jealously guard their intellectual capital regarding theirdevelopment methodologies. This inhibits manyresearchers from developing systems which wouldactually work when real-world constraints were applied.

    Apart from the lack of understanding of the methods ofcreating such trading systems, there is a further lack of

    understanding about the correct way to benchmark andtest such systems. Again, this is understandable.Unfortunately, this appears to have led to a situationwhere published results may be the end combination of avast number of prior experiments, leading to poorlydeveloped systems. In practice, such systems usuallyfail rapidly.

    Further complications in the development process comefrom a lack of understanding of the constraints of real-world trading, such as accounting for transaction costs,and the implementation of money managementalgorithms.

    Developing economically feasible trading systems usingANNs is possible, although it is clearly a complex task.In many ways, ANNs themselves compound thedifficulty. As noted by White [2], neural methods of

    back-propogation are designed to reduce networktraining error. Perhaps a better objective would be tooptimize profit subject to risk, an opportunity notdirectly afforded by using neural networks.

    The objective in using ANNs to design trading systemsis to attempt to resolve the mismatch between traders

    behavioural expectations, and ANN training methods,through careful selection of the ANNs inputs andoutputs.

    Conducting the development process within a welldefined methodology, subject to real-world tradingconstraints and effective benchmarking is the key todesigning successful mechanical trading systems.

    This paper will aim to lay down a methodology fordeveloping a mechanical trading system using ANNs.From an ANN viewpoint, it will cover the selection ofinputs, the ANN architecture, and the ANN outputs.From a trading system viewpoint, it will focus on real-world constraints, and the technique of benchmarking.

    The starting point for the creation of a trading ANN isthe selection of variables likely to influence the desiredoutcome. There are a number of methods used by

    practitioners to find such variables, and they broadly fall

  • 8/22/2019 An Empirical Methodology for developing stockmartket trading systems using neural networks

    3/18

    within the remit of either Fundamental Analysis, orTechnical Analysis. It is essential to have anunderstanding of these two complementary forms ofanalysis, so that an intelligent choice of inputs can bemade, and these can be matched to likely outputs interms of their possible effect and duration.

    This paper will review research in the areas of

    fundamental and technical analysis, to arm the readerwith the required knowledge to confidently select neuralinputs and likely outputs. The mechanics of tradingsystem structure and design are also reviewed. The paperwill then continue with a study of ANNs themselves,

    paying particular regard to architecture. At that point,the paper will progress to a study of real-world tradingconstraints, such as slippage, accounting for costs, andmoney management. Finally, the paper will describeappropriate techniques to benchmark a mechanicalstockmarket trading system.

    The methodology presented here is distilled from acombination of trading systems research and experience.This paper does not attempt to claim that following thismethodology will lead to guaranteed success, nor thatthere is no other way to develop a successful ANNtrading system.

    It simply attempts to add an element of process to aresearch area whose results are often as chaotic as theunderlying processes studied.

    2. LITERATURE REVIEWBoth the fields of Fundamental Analysis and TechnicalAnalysis have long histories of using their variables as

    predictors of future returns. This Literature Reviewhighlights some of the key papers which support thisapproach, and, in the case of Technical Analysis,addresses some concerns of academic credibility.

    When searching the domain of possible fundamental ortechnical variables to include in an ANN, it is generallyadvised that all variables selected be supported by

    published research.

    2.1. FUNDAMENTAL ANALYSISThere is a long established tradition of attempting to use

    the financial ratios produced from fundamental analysisas predictors of a companys future share price (orreturn, or price direction).

    The process of using fundamental variables to makestock trading decisions begins with Benjamin Graham,as early as 1928. Publication of Grahams work dates

    back to his first book, Security Analysis, in 1934. Thisbook is still in print and is now in its 5th edition.Graham produced a number of books distillinginvestment wisdom, including the Intelligent Investor,initially published in 1949. This book, last published in1973, made detailed comments on the building of

    portfolios and selecting stocks. Graham urged investorsto pay attention to three fundamental variables, namelysize of firm, capitalization, and price-earnings ratio. The

    book provided detailed information of how to selectcompanies using these variables. Research by

    Oppenheimer and Schlarbaum [3], tested Grahamsapproach to determine its effectiveness. They extractedthe rules provided to investors in each of the foureditions of The Intelligent Investor, and using publicallyavailable information, found that positive risk-adjustedrates of return were delivered to investors that followedthe approach between 1956 and 1975. Rates of returnwere 3% to 3.5% higher than a nave buy-and-hold

    stategy (in a frictionless market). When the variousmarket frictions (costs) were taken into account, rates ofreturn were 2% to 2.5% higher than the buy-and-holdstrategy. Oppenheimer and Schlarbaum state that itis reasonable to conclude that our evidence contradictsthe semi-strong form of the efficient market hypothesis.

    According to Lowe [4], Graham also published a list often attributes of an undervalued stock, which could beused by investors seeking excess return. These tenattributes were:

    Earnings-to-price yield >= double the AAA bondyield,

    P/E = two-thirds the AAA bond yield, Price

  • 8/22/2019 An Empirical Methodology for developing stockmartket trading systems using neural networks

    4/18

    price yield is the inverse of the P/E ratio, and ensuring itis greater than the AAA bond yield effectively cappedthe P/E ratio. In this manner, it steered investors awayfrom high P/E stocks. The second guideline requiredP/E be four-tenths highest average P/E in most recent 5years, again, effectively steering the investor away fromhigh P/E stocks.

    Banz [7] focused on the size effect. Essentially, thesize effect concerns the relationship between the marketcapitalization of a firm, and its return. Banz reports thatduring the study period (1936 1975), common stock ofsmall firms had higher returns than the common stock oflarge firms, even after adjusting for risk. Banz alsoraises the issue that the size effect may just be a proxyfor one or more other factors, which are correlated withsize, an interpretation he also applies to Basus findingsconcerning the P/E effect.

    Also in 1981, Reinganum [8] described amisspecification of the simple one-period CAPM model,namely, that data on firm size can be used to create

    portfolios that earn abnormal returns. From studyingsmall firms listed on the New York and American StockExchanges, during the period from 1963 to 1977,Reinganum discovered average rates of return for smallfirms to be nearly 20% per year greater than those oflarge firms.

    Rosenberg et al. [9] presented two strategies aimed atexploiting fundamental information to increase returns.The first, the book/price strategy buys stocks with ahigh ratio of book value to market price, and sells stockswith the reverse. The second strategy, specific returnreversal computes specific returns per stock, and relies

    on the observation that specific returns tend to reverse inthe subsequent month. Thus, this strategy buys stockswith negative specific returns in the preceding month,exploiting this reversal. The study sourced data fromCompustat, on 1400 of the largest companies, from 1980to 1984, and stocks were priced mainly from the NYSE.The study demonstrated statistically significant results ofabnormal performance for both strategies, and suggeststhat prices on the NYSE are inefficient. Here, the firststrategy provides support for Grahams fourth guideline,namely that price be two-thirds tangible book value pershare, effectively steering the investor toward stockswith a higher book value than price.

    DeBondt and Thayler [10] present evidence thatinvestors tend to overreact when considering recent data.This overreaction led to a reversal effect, with stocksthat had been prior losers likely to become futurewinners. The researchers also investigate seasonality

    patterns in returns data. They demonstrate that thewinner-loser effect is not primarily a size effect, and theearnings of winner firms and loser firms showreversal patterns consistent with overreaction. In termsof seasonal influence, DeBondt and Thayler report thatexcess returns for losers are negatively related to bothlong-term and short-term formation performance,

    particularly in January. For winners, they find thatJanuary excess returns are negatively related to theexcess returns for the prior December.

    Detailed research from Fama and French [11] surveysthe above style of anomaly detection, and conclude thatif asset-pricing is rational, then size and the ratio of bookvalue of a stock to its market value must be proxies forrisk, as opposed to reflecting market inefficiency.

    Lakonishok et al [12] find that a wide range of valuestrategies (based on sales growth, Book-to-market, Cash

    flow, earnings, etc) have produced higher returns, andrefute Fama and Frenchs claims that these valuestrategies are fundamentally riskier. Using data fromend-April 1963 to end-April 1990, for the NYSE andAMEX, Lakonishok et al find evidence that the marketappears to have consistently overestimated future growthrates for glamour stocks relative to value stocks, and thatthe reward for fundamental risk does not explain the10% - 11% higher average returns on value stocks. Thisstudy lends further support to the fourth guideline, againeffectively steering the investor toward stocks with ahigher book value than price.

    Fama and French [13] respond to Lakonishok et al byfocusing on size and book-to-value, and form portfoliosof stocks partitioned by these variables from the NYSE,AMEX and NASDAQ, from 1963 to 1992. Their resultsdemonstrate that both size and BE/ME (book-to-marketequity) are related to profitability, but find no evidencethat returns respond to the book-to-market factor inearnings. They conclude that size and BE/ME are

    proxies for sensitivity to risk factors in returns. Theirresults also suggest that there is a size factor infundamentals that might lead to a size-related factor inreturns.

    Later, Fama and French [14] study returns on market,

    value and growth portfolios for the US and twelve majorEAFE countries (Europe, Australia, and the Far East).They recognize that value stocks tend to have higherreturns than growth stocks, finding a difference betweenlow B/M (Book-to-market) stocks and high B/M stocksof 7.68% per year on average. They find similar value

    premiums when investigating earnings/price, cashflow/price and dividend/price. They find that valuestocks outperform growth stocks in twelve of thirteenmajor markets during 1975 1995. They also find avalue premium in emerging markets. Fama and Frenchconclude that these results are explained by a one-state-variable ICAPM (or a two-factor APT) that explains

    returns with the global market return and a risk factor forrelative distress.

    Frankel and Lee [15] estimate firms fundamental values(V) using I/B/E/S concensus forecasts and a residualincome model. They find that V is highly correlatedwith stock price, and that the V/P ratio is a good

    predictor of long-term returns. They state that this effectis not explained by a firms market beta, B/P ratio, ortotal market capitalization (size). They also findevidence that errors in consensus analysts forecasts are

    predictable, and these prediction errors can be exploitedby incorporating the error with V/P. They conclude that

    the evidence suggests that firms value estimates maywell provide a better forecast ability than simply usingratios, and that prices converge to value estimatesgradually over greater than 12 month horizons. They

  • 8/22/2019 An Empirical Methodology for developing stockmartket trading systems using neural networks

    5/18

    also state that the predictability of long-term forecasterrors in consensus forecasts is consistent with a long-term mispricing hypothesis. Finally, the authors alsoacknowledge that the results may demonstrate yetanother proxy for cross-sectional risk differences, butstate that this is an unlikely conclusion.

    Piotroski [16] investigates whether fundamental analysis

    can be used to provide abnormal returns, and right shiftthe returns spectrum earned by a value investor. Inanomaly terms, Piotroski focused on high book-to-market securities, and shows that the mean return earned

    by a high book-to-market investor can be shifted to theright by at least 7.5% annually, and a simple investmentstrategy based on high book-to-market securitiesgenerates a 23% annual return between 1976 and 1996.The research is stimulated by the observation that

    portfolios of high book-to-market firms normally containseveral strong performing firms (achieving strongreturns), and many deteriorating ones (achieving poorreturns). Piotroski defines three different classes of

    financial performance signals, namely:

    Profitability, Leverage, Liquidity and source of funds, and, Operating Efficiency.From these three classes of signals, nine simple signalsare defined, and an aggregate score of the nine signals isused to rank the constituents. The nine signals involveseven fundamental variables, namely:

    net income before extraordinary items, cash flow from operations, (both scaled by the

    beginning of year total assets), leverage, liquidity, whether external financing has been raised recently, current gross margin scaled by total sales, and current year asset turnover ratio.Within the portfolios constructed from the higheraggregates, Piotroski notes that the returns areconcentrated in small and medium sized companies,companies with low share turnover, and firms with lowanalyst following. It is also noted that superior

    performance is not dependant on initial low share prices.Again, support is found for Grahams fourth guideline inthis study. Of further interest is the determination thatone-sixth of the annual return difference between the ex-ante strong and weak firms is earned over the four three-day periods surrounding earning announcements. Thisinformation is of obvious interest to those advocatingmarket timing approaches.

    Kanas [17] finds a non-linear relation between stockreturns and the fundamental variables of dividends andtrading volume.

    Aby et al. [18] focus on combining fundamental

    variables to screen stocks for value. This is a reasonablycommon approach, with some authors reportingoutstanding results. Aby et al. developed portfolios

    based on four fundamental conditions, namely: Single

    Valued P/E (P/E 12%), and dividends paid out less than 25% ofearnings. They conclude that when the four criteria areused to screen stocks, quality investments seem to result,again providing support for Grahams fourth guideline.The authors state that higher yields do not seem to

    provide good long term returns, possibly due to the use

    of retained earnings to enhance equity per share.Overall, the main contribution of their work is toestablish a relationship between ROE (> 12), and share

    price performance. The research alludes to the fact thatBuffett believes 12 is an appropriate value for ROE indomestic (US) markets. The authors find that the valueof 12 for ROE provides a clear line of demarcation

    between performance and non-performance is shareprice terms. The authors tested the filter criteria againstthe Value Line database between August 31, 1989 toAugust 31, 1999. The filter conditions described cut thedatabase down from 6000 possible stocks to just 14.These 14 yielded an average return of 30.55% per year

    for the ten years. It is interesting to note that in earlierwork Aby et al. [19], the same authors had focused onshares with simply a low P/E and a market price below

    book value, and had concluded that this filter method didnot produce satisfactory returns.

    2.2. TECHNICAL ANALYSISModern Technical Analysis dates from the work ofCharles Dow, who in 1884 drew up an average of thedaily closing prices of 11 important stocks. Between1900 and 1902, Dow wrote a series of articles in theWall Street Journal documenting stock price patterns and

    movements he observed in the average. These articleswere the first to describe systematic phenomena in thestock markets.

    Although Dows work represents the beginning ofmodern technical analysis, it is worthy of note thatmarkets and analysis techniques existed centuries beforethis, notably in Japan since 1730, where the first futurescontracts (in rice) were traded. For a fascinatingdescription of the operation of these markets, refer to

    Nison [20]. Tvede [21] reports that interest in the futureprices of these rice futures ran high, with the Japanesegovernment suspending the forward market in 1869 due

    to excessive volatility.

    Today, a manual of technical analysis is likely to becomposed of techniques which fall into one of three

    primary classifications, namely:

    Charting (typically pattern matching), Indicators (and oscillators), Esoteric approachesThis paper will focus on the technical indicators andoscillators, as these are easily reproduced according totheir mathematical definitions. In contrast, Charting and

    pattern matching is usually highly subjective and withoutrigorous mathematical definition. Esoteric approachesare excluded from this study, as they have no scientific

  • 8/22/2019 An Empirical Methodology for developing stockmartket trading systems using neural networks

    6/18

    justification. Warnecke [22] provides examples of thecriticisms often leveled at these techniques.

    Technical Analysis is enjoying a recent resurgence inacademia after having been out of favour for severaldecades. The main reason for this lack of favourconcerns the Efficient Market Hypothesis (EMH), whichsupports the random-walk theory. In essence, since the

    early work of Fama [23], the random-walk theory hasheld sway. This theory states that successive pricechanges in stock prices are independent, identicallydistributed random variables. The important implicationof this hypothesis is that it implies that a series of pricechanges has no memory, which further implies that thestudy of past prices cannot provide a useful contributionto predicting future prices. As the majority of technicalanalysis techniques focus on probability based on past

    price behavior, the natural conclusion is that TechnicalAnalysis cannot work.

    Regardless of the random walk theory, a large number ofmarket participants use technical analysis as their mainmethod of stock selection. Indeed, Taylor and Allen[24] conducted a UK survey of forex dealers on behalfof the Bank of England, and found that at least 90% ofthe respondents placed some weight on TechnicalAnalysis for decision making. It has been suggested thatdue to its high usage, technical analysis may, in fact, be

    becoming a self-fulfilling methodology. In other words,if enough people follow the principles, then those

    principles can be expected to become manifest in thecharacter of price time series.

    To complete the discussion regarding technical analysis,it is occasionally stated that as technical rules become

    more widely known, the abnormal returns they attemptto identify will be reduced, and the usefulness of thetechnical rules themselves will be destroyed. Silber [25]finds against this conclusion, instead concluding thatthe continued success of simple technical trading rulesis possible as long as there are price smoothing

    participants in the market. In this context, Silbersexample of price smoothing participants refers to thecentral banks.

    Rather than focus on Technical Analysis as a discipline,the remainder of this literature review will focus on theresearch support for the use of Technical Analysis

    variables, such as Moving Averages, Indicators andOscillators.

    The majority of the academic literature concerningtechnical analysis concerns the testing of simpletechnical rules, such as moving averages. Trulyeffective technical rules are not published in academic

    journals, and are usually kept secret.

    According to Pring [26], there are three basic principlesof Technical Analysis, namely:

    Prices move in trends, Volume goes with the trend, A trend, once established tends to persistThe moving average and its derivatives are designed toexpose when a security has begun trending, and as such,

    deal with the first and third principles listed above. Theidea of observing (and profiting from) trends has a longhistory, and is one of the early systematic phenomenadescribed by Dow.

    Academic research in the area of moving averages datesfrom the work of Neftci and Policano [27], who studiedmoving averages, and the slope of price movements on

    the chart (named trendlines by technical analysts). Theystudied closing prices of gold and T-bills, and createdbuy-and-sell rules based on trendlines and movingaverages. Although they described their results from thestudy of trendlines as inconclusive, they reported asignificant relationship between moving average signalsand prices. Of particular interest was the fact that a setof significant parameters for one commodity were ofteninsignificant for another commodity. This difference insignificant parameters is often termed a marketspersonality.

    Murphy [28] demonstrated that different sectors of themarket move in relationships with other sectors, a fieldof study now known as Intermarket Analysis.

    Neftci [29] examined the relationship of the 150 daymoving average rule to the Dow-Jones Index. Thisresearch concluded that the moving average rulegenerated Markov times (no dependence on futureinformation) and has predictive value.

    Two popular technical trading rules were tested byBrock et al. [30], namely, moving averages and tradingrange breaks (known by technical analysts as Supportand Resistance trading). Using data from the start of theDJIA in 1897 to the last trading day of 1986, the authors

    test a variety of combinations of moving averages, usinga 1% band around predictions to eliminate whipsaws.They find support for the use of moving averages, andreport that the differences in utility are not readilyexplained by risk. They conclude their results areconsistent with the technical rules having predictive

    power.

    Inspired by Brock et al [30] above, Mills [31] tests thesame two trading rules in the London Stock Exchange,using FT30 data from 1935 1994. Mills results areremarkably similar to Brocks, with Mills concluding thatthe trading rules could predict stock prices, and are thus

    profitable in periods when the market is inefficient.

    Levich and Thomas [32] test currency futures contractsin five currencies over the period 1976 to 1990. Theyreport persistent trading profits over the 15 year periodusing a variety of commonly researched moving averagerules. Levich and Thomas concluded the profitability oftrend following rules strongly suggest some form ofserial dependency in the data, but the nature of thedependency remains unclear.

    LeBaron [33] provided more support for the movingaverage, by using moving average rules as specificationtests for foreign exchange rates. He concluded that

    exchange rates do not follow the random walk, and thatthe deviations are detected by simple moving averagerules.

  • 8/22/2019 An Empirical Methodology for developing stockmartket trading systems using neural networks

    7/18

    Lehmann [34] considers evidence supporting variationin equity returns, attempting to decide whether theevidence is indicative of predictable changes in expectedreturn, or market inefficiency. Lehmann finds thatwinners and losers one week often experiencereversals of fortune in the following week. The costless

    portfolio constructed by Lehmann (difference betweenwinner and loser portfolios) showed profit in 90% of

    weeks. Lehmann concludes that the reversals of fortuneare probably reflections of the imbalances in the marketfor short-term liquidity, and states that it is difficult toaccount for these results within the efficient marketsframework. Lehmanns work is often quoted by

    practitioners as supporting Technical Analysis, as itsupports the idea that price trends occur frequentlyenough to create profit opportunities for technicaltraders. Lehmann does not specifically make thisstatement.

    Jegadeesh [35] examines the predictability of monthlyreturns on individual securities. Ten portfolios were

    formed based on the predicted returns using estimates ofthe regression parameters. The difference betweenabnormal returns on the extreme decile portfolios was2.49 percent per month over the period 1934 to 1987.Slightly different values are provided when comparingextreme decile portfolios excluding January results(2.20% per month), and when January was consideredseparately (4.37% per month). Jegadeesh rejects therandom walk hypothesis, and concludes that returns

    predictability is due to either market inefficiency, orsystematic changes in expected stock returns. This

    paper is often used to support the principles of technicalanalysts, as it shows evidence that increases (and

    decreases) in prices during one month are often reversedout the following month. Patterns of that nature wouldsuggest that investors could profit from technical tradingstrategies, and would also be a breach of marketefficiency.

    Very little academic research exists supporting the use ofspecific technical indicators and oscillators. The mainacademic work above relates to Moving Average rulesand Momentum based rules. To allow the neuralnetwork to have access to the same types of indicatorsand oscillators being used by practitioners, a survey ofthe main practitioners journal, The Technical Analysis

    of Stocks and Commodities was conducted. For thesake of brevity, detailed reviews are not provided for thearticles studied, rather, a list of the most popular (i.e.most frequently referenced) technical variables is

    provided below. The assumption is that these variablesare most in use due to the fact that they are useful.

    Technical Variables most frequently cited in The

    Technical Analysis of Stocks and Commodities

    Moving Averages (including a variety of derivativesbuilt from basic moving averages)

    Volatility based variables, such as ATR (Average

    True Range)

    Volume based variables, such as Volume directly, orOBV (On Balance Volume)

    ADX (Average Directional Index See Wilder [36])

    Stochastics (based on the work of George Lane)

    Momentum (both price and volume)

    RSI (Relative Strength Index See Wilder [36])

    Variety of miscellaneous indicators and oscillators (eg

    MACD, Intermarket indicators, Money Flow, TRIN(Traders Index), etc)

    To sum up the position regarding technical analysis, it isreasonable to state that after a long absence fromacademia, technical analysis is beginning to enjoy areturn to mainstream investment finance. It is becomingmore common to see universities promote subjects withtitles such as Computational Finance, and even Siegel[37] cautiously supports the use of Moving Averages.

    It should be noted that Computational Finance courses

    are not specifically devoted to Technical Analysis, butalso cover other topics, such as Behavioural Finance andIntelligent Finance.

    Intelligent Finance seeks to develop a comprehensiveundetstanding of financial markets by the combination offundamental, technical and strategic analysis. To pursuethis field further, the reader is referred to Pan [38].

    2.3. TRADING SYSTEMSAccording to Chande [39], a trading system consists ofthree major functions, namely:

    Rules to enter and exit trades, Risk Control, and, Money Management

    2.3.1. RULES TO ENTER AND EXIT TRADESIn the approach used in this paper, the ANN will be thesignal generator, and its output will be used to eitherinitiate or exit trades. Rules to enter and exit trades are

    based on the strength of the ANN output signal. Thisapproach is discussed in detail in Section 3 Neural

    Network Creation.

    2.3.2. RISKCONTROLIn the context of stock market trading, a trader istypically concerned with downside risk, which describeshow much money is at risk on an individual trade-by-trade basis. This method of approaching risk leads totraders placing orders to sell/buy securities to cover openlong/short positions when losses cross pre-determinedthresholds. These are known as stop-loss orders.

    As investors are typically preoccupied with return, it isalso appropriate to consider risk to be appropriately

    controlled by trade risk within the confines of a tradingsystem. After all, this is the entire purpose of a tradingsystem. This method of considering risk is growing in

  • 8/22/2019 An Empirical Methodology for developing stockmartket trading systems using neural networks

    8/18

    popularity, see for example Kaufman [40], Longo [41],and Pocini [42].

    A general framework for considering the issue of riskcontrol is the TOPS COLA approach described byChande [39]. TOPS COLA is an acronym for "take our

    profits slowly, cut off losses at once". In effect, itdescribes the traders approach to risk.

    Trend following systems will typically have more losingtrades than winning trades. In financial terms, this stillleads to a viable system, as long as the value of losingtrades is quite low, and/or the value of winning trades ishigh. Typically, according to Chande, about 5% of thetrades made by a trend following system are the 'bigones'. In light of this information, it is easy to see howthe TOPS COLA approach can work.

    Risk control may therefore be defined as the process formanaging open trades using predefined exit orders.Traders enter an initial stop-loss when they first enter a

    trade. If the price of the security falls, then a stop-lossis triggered and a loss is taken. Clearly, the closer thestop is to the actual price of the security, the less moneywill be lost if the price falls, but the more likely it is thata smaller price fluctuation or random noise will triggerthe stop. If the stop price is further away from thecurrent price, then there is potentially more money atrisk, however, the chance is lower that the stop will betriggered by noise. Chande provides evidence to suggestthat the use of tight stops may well be degrading longterm portfolio performance.

    If the price of a security rises, the trader may well adjust

    the stop loss to a break even stop, or a trailing stop. Abreak-even stop will cancel out the trade if the pricefalls, at an amount equal to the trade cost. A trailingstop will increase in value as the security price increase,either proportionately or otherwise. The trailing stopwill never move down, it is only ever moved up underthe security price, so once the price of the security falls,the stop will be hit.

    A variety of methods are available, such as Volatilitystops (refer to Overholser [43]), Fixed Dollar / FixedPercent stops, Support and Resistance stops, Time delaystops, and Dev-Stops (refer to Kase [44, 45]).

    There are a number of variants of the stops describedabove, and stops may also be set relative to volatility, or

    period of time elapsed, or combinations of the above.Also, the use of profit targets is not uncommon. Theseeffectively exit a trade once a predefined amount of

    profit has been achieved. There are variants of profitexits also, but, in general, they run contra to Chandes

    principle of "take our profits slowly".

    When trading using longer term classical bar charting inthe market, it is not uncommon for traders to use verysimple stops, typically setting a basic money

    management stop on the initial purchase, and leavingthat stop in for the duration of the trade. The trade entryis determined by the detection of a trend, and the tradeexit is controlled by the evidence that a trend has

    reversed, or ended. This is entirely consistent with thedefinition provided by Pring [26], and the use of stops isreserved for exiting out of trades where a trend appearedto begin, but very quickly ended.

    It should be noted that there are a variety of othertechniques in common usage, a brief summary of theseis provided by Tharp [46]. Also, the use of stops within

    a given strategy, particularly if it is a long-term strategy,may not always be appropriate. Kaufman [40]demonstrates how the performance of a longer-termtrending strategy without stops is most consistent, andconcludes that the use of fixed value stops may evenconflict with the strategys objectives.

    As can be seen, risk control for a trader concernsprotecting open trades where money is at risk throughthe use of stops. In essence, although there are manystyles of stop described above, the use of stops in this

    paper is simply to be able to site the neural networksdeveloped within a realistic trading environment. For

    this purpose, an initial stop-loss will suffice.

    The stop-loss threshold is selected by the study of the in-sample MAE as described by Sweeney [47], and later byTharp [46]. The MAE studies the Maximum AdverseExcursion (MAE) of a set of trades, in an effort todetermine the extent to which favorable (profitable)trades range into unprofitable territory before closing out

    profitably. This method of risk management allowstraders to study the MAE characteristics of a set oftrades, to identify preferred stop-loss points.

    As the choice of stop strategy is closely related to the

    method used to signal entries, a discussion on which stopthresholds to implement is delayed until Section 3

    Neural Network Creation.

    2.3.3. MONEY MANAGEMENTMoney management, aka position sizing, refers to theactual size of the trade to be initiated, taking intoconsideration the account equity and potential trade risk.

    Like risk control, the style of money management isclosely related to the trading system, as it is influenced

    by many variables which are constrained by the specific

    system. As every trade carries a potential for loss, thereis a need to determine the maximum amount of capital toexpose at each trade, given a finite capital base. Anumber of specific approaches exist, and the reader isencouraged to pursue the following references:

    Kelly system: well described by Balsara [48] Optimalf: refer to Vince [49] Percent of equity: refer to Elder [50], and Pring

    [26]

    To simplify the complexities of Money Management,this paper suggests using a fixed percentage of equity per

    trade (as suggested by Elder) for testing andbenchmarking. Not only is this simple to implement, butit also avoids having to determine how much of any

    profit effect observed is attributable to the neural

  • 8/22/2019 An Empirical Methodology for developing stockmartket trading systems using neural networks

    9/18

    network developed, and how much is attributable strictlyto money management. Given the goal of this paper,this choice seems appropriate.

    3. NEURAL NETWORKCREATIONThis section of the paper describes the methodology to

    produce a neural network which behaves well in in-

    sample testing. When such a network is identified, theparameters which support this network are effectivelyfrozen for out-of-sample testing. It is at that point thatthe extent to which the ANN has been curve-fit will berevealed.

    3.1.1. SELECTING INPUTSSpecific choices need to be made regarding the inputs to

    be selected. At this point, it is important to have someexpectation of the timeframe that the system will be usedto trade. Developing a long-term system may call for agreater reliance on fundamental variables, due to the

    timeframe of their production, and therefore, their likelyinfluence. Developing a short-term system may call fora greater reliance on technical variables.

    It is at this stage that the user must decide on theirexpected trading timeframe. Typically, a distinction ismade between investors and traders, with investorsassociated with longer-term holding periods, and tradersassociated with shorter-term holding periods. Thechoice between trader and investor will influence thedecision on which variables, fundamental or technical,will likely be the main neural network inputs.

    Choices can be made by studying the published researchreviewed above, by experience, or by experimentation.Ideally, variables should be selected in line with

    published research, however, due to the lack of detailedresearch regarding technical variables, it is suggestedthat function profiles be used. Function profileseffectively iterate a function through every possiblerealistic value, and measure the corresponding change ina different variable for every value of the function.Typically, they display their results graphically for easyinterpretation.

    When selecting technical variables it is important not to

    let the ANNs have visibility of actual prices or volume,only ratios and indicators built from the prices andvolume. This will prevent the ANNs focusing onwhether a stock has a high price (or volume) or a low

    price (or volume), and allow more for generalizationabout the ratios and indicators, and their relativerelationships. As the goal with neural networks is toencourage generalization, supplying ratios to the neuralnetwork is an ideal way to accomplish this. This is

    because the same ratio can be built from any number ofnumerators and denominators, and it is unlikely(although not inconceivable) that the exact values of thenumerator and denominator are relevant. Technical

    analysis generally focuses on ideas concerning price andvolume behaviour, not the exact price and volumethemselves.

    Note that when using fundamental variables as inputs, itis advisable to delay their input to the network by somefixed time period. Typically, fundamental data isdelayed by about 6 months before being used as an inputto a neural network. This ensures that the variables

    being acted on are available to the market at the timethey are made available to the neural network. Whilstsome fundamental data is realized much more quickly

    than 6 months, the long lag is generally used to ensurethat the neural network does not have access to datawhich would not have been available in the real-world.This is an essential element of backtesting.

    3.1.2. SELECTING OUTPUTSAgain the selection of output variables is dependant onthe expectation and timeframe of the system beingdeveloped. From the research presented in the literaturereview, there are clearly a great many choices for outputvariables.

    While it may seem appropriate to attempt to predictprice, a great deal of research shows that this is aparticularly difficult task, possibly due to the fact thatprice changes do not tend to be smooth. Predicting pricedirection appears easier, and more likely to besuccessful, but then the trader has no real way ofgauging the strength of the move in that direction. Forexample, a high degree of directional accuracy may nottranslate to high returns after costs if the movement inthe direction forecast is small, as noted by Azoff [51]and Thawornwong and Enke [52]. Ruggiero [53] makesa number of suggestions, such as predicting a smoothedoutput function, such as a forward shifted technical

    indicator which is constructed from underlying pricedata. However, there are a number of inherentadvantages and disadvantages in all technical indicators,and whilst they may be smoother than price action, theyare typically only suitable for trading whilst marketaction is favorable to that actual indicator. For example,as Bauer [54], Pring [26] and a host of other technicalanalysts explain, trend based indicators perform wellwhilst the market is trending, but perform poorly at othertimes. Oscillators perform well when the market is nottrending, but perform poorly otherwise. The temptationto create two technical neural networks, one for eachmain type of market activity is easily avoided, as then afurther methodology would be required to tell whichnetwork to use at which point in time. In any event, anumber of academics believe that the market actuallygoes through three phases, trending, non-trending, andchaotic, making the selection of which network to trustat which point in time much more complex. For furtherinformation on training neural networks with chaoticconstraints, see Slim and Trabelsi [55]. Finally,according to Ruggiero [56], the decision on which targetto predict should be based on three factors, namely, thedesired trade frequency, risk / reward criteria, andexpertise available.

    In consideration of all of the above, it is proposed thatthe most useful ANN output is an indication of therelevant strength of any movement expected over theforecast period. This should give rise to a highly

  • 8/22/2019 An Empirical Methodology for developing stockmartket trading systems using neural networks

    10/18

    tradeable indicator, which can be expected to performduring both trending and non-trending (and any other!)

    phases of the market.

    The method suggested here is to build an output variablewhich effectively captures the strength of expectedreturn movement. Such a variable is easily built bymeasuring the maximum price change over some

    timeframe after the variable is sampled. This leads to aneural network which can give a strength forecast basedon the inputs provided. This is particularly useful whenchoosing between a number of possible positions, and insetting thresholds for entry and exit rules.

    A simple 200 day strength variable may be computed as:

    ( )100

    ),...,max(Target 1200

    = ++

    i

    iii

    close

    closecloseclose

    For long-term trading systems, 1 year is a typical look-ahead period, see for example, Longo [41] andReinganum [57].

    Specific timeframe lengths could be determined bysearching for cycles, but as already stated earlier, it isgenerally accepted that the market dynamics arechanging over time. Thus, there appears little benefit indetermining the optimal timeframe at any point in time,as it could not be relied on to hold, thus reducing theexpected lifetime of a trading strategy, and addingadditional risk (see for example, Balsara et al [58]).Published work exists which describes cycles alreadyfound in the Australian stockmarket, such as a 6-daycycle discovered by Pan et al. [59], however, this was

    discovered in the AORD index, and there is no reason toexpect it would hold for individual stocks, each with itsown individual characteristics. For example, it could beexpected that certain stocks had radically different cyclelengths, such as bank stocks following the economiccycle, resource stocks following the strength of theindustrial cycle in other countries, etc. Other publishedworks use PCA (Principal Component Analysis) (e.g.Raposo et al. [60]), or Self Organizing Maps (e.g. Chi etal. [61]).

    Essentially, the practical solution, and indeed, theobjective, is to select timeframes which are consistent

    with the traders trading expectations. This idea isconsistently presented in literature describing thetechniques involved in building trading systems, forexample, Ruggiero [56].

    Finally, Azoff [51] suggests the network have only oneoutput, to avoid the effect of conflicting outputs pullingthe weights in opposing directions during training. Inthis way the network is effectively focused on one taskonly.

    3.1.3. PARTITIONING AVAILABLE DATAAny study involving optimization, or neural networksmust logically (or better still, physically) separate data

    which will be used for training, from data that will beused for testing.

    There is acceptance within the academic community thatthe relationship between security prices (and returns),and the variables that constitute that price (return),changes over time as described by Refenes et al. [62]and also by Thawornwong and Enke [52]. In other

    words, the structural mechanics of the market arechanging over time, and their effects on prices are alsochanging. For this reason, it is necessary to partitiondata vertically rather than horizontally. A vertical

    partition of a dataset will divide each securities datasetinto two partitions, one for training, and one for testing.Typically, the training dataset is larger, and covers asignificant date range of the overall data, whilst thetesting dataset is smaller, and used to provide out-of-sample confidence. These two partitions are typicallyknown as in-sample (training), and out-of-sample(testing) partitions. Using this approach, every securitiesdata will be partitioned into training and testing subsets.

    The horizontal approach to partitioning splits the entirerange of data into either a training or a testing block. Forexample, horizontally partitioning 10 datasets, with 60%in training, and 40% as testing would yield 6 entiredatasets used for training, and 4 entire datasets used fortesting. This approach is invalid when it is recognizedthat the structural mechanics change over time, due tothe fact that a neural network may well learn correlationsthat could not have been known in chronological time,and later, exploit these during the testing phase. Thismay well lead to higher quality predictions, but is clearlyunrealistic.

    In summary, it is advised to split all available securitydata vertically, with the final date of all training subsetsaligned. The actual ratio for the split is generally chosendependant on how much data is available, and is oftenarbitrarily chosen. However, some general guidelinescan be distilled. For example, Ruggiero [56] suggeststhat the data sets used for training should cover a periodat least 5 times longer than the desired life of the modelto be produced, and suggests using 80% of the data fortraining, and 20% for testing. Azoff [51] takes a typicalapproach, which suggests that the training period should

    be long enough to cover typical market behaviour,

    including bull, bear, and sideways moving markets.Kaufman [40] suggests a 70:30 split between trainingand testing, Kim and Lee [63] suggest an 80:20 split,Gately [64] suggests saving only 10% of the availabledata for testing, thus a 90:10 split. From an optimization

    point of view, Pardo [65] suggests choosing a periodlong enough to cover a variety of market activity, andadvises choosing a size large enough to generate at least30 trades for statistical validity. Pardo also notes thatthe size of the models test window will affect tradingshelf life, specifying that the life of the model will be

    between one-eight and one-quarter of the test window.Pardo further suggests a rule-of-thumb that the walk-

    forward window (in optimization) should beapproximately 10% - 20% of the optimization window.

  • 8/22/2019 An Empirical Methodology for developing stockmartket trading systems using neural networks

    11/18

    There are a wide variety of other competing andcomplementary guidelines available. In essence, themain principle is to capture as much diverse marketactivity as possible (with a long training window), whilstkeeping as long a testing window as possible (to increaseshelf life and model confidence). This studyrecommends sourcing at least 10 years data for eachsecurity, and then performing an 80:20 split. In this way,

    80% of the data will be used for training, and 20% willbe reserved for testing. This split provides a reasonablecompromise, and takes the above guidelines intoconsideration.

    Neural networks must be trained on data which includesdelisted securities, to enable the neural network access todata which describes the real world environment. Notincluding data for securities which have delistedintroduces survivorship bias. From a trading point ofview, the trader cannot benefit from survivorship bias, soincluding the data for delisted securities will representthe worst case results, and these will be directly

    applicable to the trader.

    3.1.4. IN-SAMPLE BENCHMARKSAs neural networks are developed in this methodology to

    be signal generators, and in-sample testing is initiallyoutside of the context of a trading system, the test metriccomparing different neural network architectures must

    be on the basis of their in-sample training. These in-sample metrics are used to assess the quality of theneural network architectures tests (see section 3.1.5Determining Architecture). It is not appropriate to test

    each neural network architecture on the out of sampleresults and select the best performer.

    For this reason, it is necessary to define metrics whichcan be used to test different neural network architectures,and the metrics presented below are focused onidentifying how well the neural network has learnt itsobjective. Different metrics are provided for cases whenthe neural network is focused on long-term timeframes,or short term timeframes.

    In the case of a long-term timeframe, a useful in-samplemetric is the networks selectivity. This is because long-

    term trading networks usually serve as stock screeningstrategies. That is, they are designed to filter the entiremarket of stocks, and identify those which have thegreatest chance of the highest appreciation within theexpected trading time period. The signal generated bythese neural networks is effectively a prediction of thelikely strength of price increase over the next 1 year

    period.

    To determine how to evaluate a screening strategy, it isnecessary to review the purpose of such a strategy.Specifically, a screening strategy is used to reduce(refine) the number of securities that are competing for

    capital. A traders requirement is to increase thelikelihood of selecting stocks that will significantlyincrease in value. Thus, a suitable measure of success isto determine the percentage of stocks selected that

    achieve a pre-specified increase in value. By measuringthese values for the entire market, then for the ANN

    predictions, it can easily be determined whether theneural network is effective. Finally, care must be takento ensure that a reasonable number of predictions areoutput by the ANN for this process. Clearly, it wouldnot make sense to select a network with a 100% successrating if there was only 1 trade predicted.

    The metric used for this style of longer-term screeningstrategy measurement, termed Filter Selectivity, isdefined as:

    ( )sTotalTrade

    esClosedTradctivityFilterSele

    100*=

    where

    ClosedTrades is the number of trades closed due tomeeting the predefined increase in valueTotalTrades is the total number of trades selected by the

    screening strategy

    For shorter term timeframes, such as those relying solelyon technical variables, an objective measure of aaccuracy is the measure of expectancy. The idea ofexpectancy in trading was first raised by Tharp [46],who proposed it as a useful method to compare tradingsystems. Expectancy is a measure of the expected profit

    per dollar risked on a fixed position size basis. It is usedwithout money management settings enabled, which isappropriate for the in-sample testing. There are anumber of variant formulas for calculating expectancy,

    this version presented is more conservative than Tharps;it uses the average loss as the standard of risk (ratherthan the minimum loss as used by Tharp).

    ( ) ( )( )AL

    PLALPWAWEXPECTANCY

    +=

    whereAW = Average amount won on profitable tradePW = Probability of winningAL = Average amount lost on losing trade (-ve)PL = Probability of losing

    Secondly, to assess the quality of the ANN architecturechosen, it is also appropriate to consider the AverageProfit/Loss %, which is a standard trading systemmetric.

    3.1.5. DETERMINING ARCHITECTUREThere are no standard rules available for determining theappropriate number of hidden layers and hidden neurons

    per layer, although for greater generalization, the smallerthe number of hidden nodes and hidden layers the better.General rules of thumb have been proposed by a number

    of researchers. For example, Shih [66] suggestsconstructing nets to have a pyramidical topology, whichcan be used to infer approximate numbers of hiddenlayers and hidden neurons. Azoff [51] quotes a theorem

  • 8/22/2019 An Empirical Methodology for developing stockmartket trading systems using neural networks

    12/18

    due to Komolgorov that suggests a network with onehidden layer and 2N + 1 hidden neurons is sufficient for

    N inputs. Azoff concludes that the optimum number ofhidden neurons and hidden layers is highly problemdependant, and is a matter for experimentation. Gately[64] suggests setting the number of hidden nodes to beequal to the total of the number of inputs and outputs.As another alternative, some researchers, for example

    Kim at al. [67] use a brute force approach, and train agreat number of ANNs with different configurations, andthen select that configuration that performed best. Yetanother approach, such as that used by Jaruszewicz andMandziuk [68] is to train networks for a fixed number ofepochs, or fixing the number of hidden nodes to somearbitrary value, as in Kim and Lee [63]. Zirilli [69]

    proposes a formula based on prior knowledge of thenumber of unique patterns the net is expected to learn,

    but concedes that if you know your feature space wellenough, you can usually determine this number ofhidden nodes better yourself. Finally, another reasonably

    popular method is used by some researchers such as Kim

    & Lee [63] and Versace et al [70], whereby geneticalgorithms are used to select between the combinatorialexplosion of possible networks given choices such asnetwork type, architecture, activation functions, inputselection and preprocessing.

    An alternative approach described by Tan [1], is to startwith a small number of hidden neurons and increase thenumber of hidden neurons gradually. Tans procedure

    begins with 1 hidden layer, containing the square root ofN hidden nodes, where N is the number of inputs.Training the network takes place until a pre-determinednumber of epochs have taken place without achieving a

    new low in the error function. For example, ANNs canbe trained until no new low had been achieved for atleast 2000 epochs. At this point the network would betested against the in-sample set, and benchmarked usingthe appropriate metrics described above. A new neuralnetwork is now created with the number of hidden nodesincreased by 1, and the training and in-sample testing isrepeated. After each test, the metric being used for

    benchmarking is assessed, to see if the new networkconfiguration is superior. This process continues whilethe networks being produced are superior, that is, itterminates at the first network produced which showsinferior in-sample results.

    This approach to training is an implementation of theearly stopping method, which aims to preserve thegeneralization capabilities of neural networks. It is

    based on the observation that validation error normallydecreases at the beginning of the training process, and

    begins to increase when the network starts to over-fit.Lack of generalization is caused by over-fitting. In anover-fit (over-trained, over-learned) situation, thenetwork begins to memorize training examples, andloses the ability to generalize to new situations.

    3.1.6.

    SETTING SIGNAL THRESHOLDS

    Each neural network developed has fit itself to thecharacteristics of the market which the training datarepresents, within the constraints of its architecture. A

    simple way to observe this fit is with the use of afunction profile. From inspection of the function

    profiles for each neural network, the threshold at whichthe neural network output signal begins to signal

    profitable trades can be easily established.

    Therefore, for the in-sample testing, the buy signalshould take account of the individual neural networks

    threshold, and also take account of whether the signal isincreasing in strength, or decreasing in strength from its

    previous forecast. Naturally, the sell signal should alsotake account of the threshold, and also take account ofwhether the signal is increasing in strength, ordecreasing in strength from its previous forecast. It isalso considered a desirable property of a trading systemif the rules for exiting a trade are the contra to the rulesfor entering it.

    Therefore, a general buy and a general sell rule can beexplicitly stated, and then applied to each tradingsystem. Wherex is the signal strength threshold chosen

    from the function profile, then the entry and exit rulesbecome:

    Buy: Buy tomorrow when neural signal output(today) >x, and neural signal output(today) > neural signaloutput(yesterday)

    Sell: Sell tomorrow when neural signal output(today)

  • 8/22/2019 An Empirical Methodology for developing stockmartket trading systems using neural networks

    13/18

    determined from the in-sample data will be then used asthe stop value in the out-of-sample testing data.

    Typically, the exact value chosen is selected byeyeballing; what is required is to locate the point atwhich the number of winning trades falls away verysharply, whilst typically the number of losing tradesdoes not. According to Chandes principles, if in doubt,

    we should err towards selecting a larger value of stoploss than a smaller one. This gives a trade plenty ofroom to develop a profitable outcome. The main reasonwe should err towards wide stops, is that if a stoploss ishit, it will always force us to incur a loss. There is nevera profitable outcome for a stoploss being triggered.This implies that if the decision to take the trade iscorrect, then we should attempt to stay in the trade for aslong as possible, and avoid being shaken out by noise, orshort-term adverse behaviour.

    The graph below represents the MAE/MFE observationsfor a trading system which doesnt use stops. These

    MAE/MFE observations are taken from the in-sampletest of the trading system. By eyeballing the graph, itis clear that the majority of successful trades dont strayfurther than 5% into the red before rebounding toconclude profitably. In this case, the threshold would beset at 5%.

    4. REAL-WORLD CONSTRAINTSThere are a great variety of tradable securities and

    trading mechanisms available. The trading systemsconsidered in this paper are all 'long' end-of-daysystems. That is, the systems implemented only tradelong positions, and do not attempt to sell stocks short.

    One of the main issues with short-selling is that it cannotjust be assumed that stocks can be sold short. Thereason for this is that in some markets only certainsecurities can be sold short, and these can only be soldshort at certain times. For example, the method the ASX(Australian Stock Exchange) uses to determine whichshares can be sold short can make short-side sellingreasonably complex. In effect, the ASX determine the

    list of Approved Securities (for short selling), and allownot more than 1/10th of the total quantity in issue ofeligible securities to be short sold. The shortsell list isupdated every trading day, based on the shortsell list forthe previous trading day, as described by the Australian

    Stock Exchange, in the Short Sales document [71]. Foran individual trader, it is very difficult to knowhistorically whether a short-sell transaction couldactually have been executed.

    All trades initiated from end-of-day data must be day+1long market orders. This means that after a signal isgiven, then the trade takes place on the next day the

    market is open, at market open price. For example, afterthe market has closed on day t, the trading system would

    be run, and any buy (sell) signals generated are queuedfor opening positions (closing positions) for the start ofthe next days trading, day t+1. In this way, there is no

    possibility of acting on information which is not publiclyavailable to all traders. In essence, this is similar to theissue of displacing fundamental data by at least 6months, again, to ensure that the trading system is not

    being tested on data which was not available in themarket.

    All trading simulations must account for transaction

    costs, and it is advised that these be over-estimated forhistorical testing. Traditionally, the cost of brokeragefor individuals has been falling, therefore, using todaystransaction costs to simulate historical trading results asof 10 years ago is very misleading, particularly if thestrategy being tested generates a large number of trades.

    Another realistic simulation constraint is slippage.Although a trade may be initiated at market open, thisdoes not mean the trade will be opened (closed) atmarket open price. There will inevitably be slippage dueto the fact that at market open there may be a great many

    trades scheduled. Naturally, the price can move aroundquite considerably in the early part of trading, andslippage is the method to account for this cost. Slippagesettings of 5% would be reasonable.

    It is also important when developing and benchmarkingsystems of this type that simulations respect volumeconstraints. It is not realistic to assume that there is anunlimited amount of stock available for purchase.Historical technical data includes the volume data item.When training and testing, it is realistic to assume thatthe positions sizes acquired be some smallish factor ofthe overall trade volume available. A suitable factor

    might be 5%, or perhaps even less dependant on themarket volatility.

    Finally, it is unwise in historical simulations to referdirectly to cut-off values for variables such as price. Forexample, it would be unrealistic to include a conditionthat price must be less than $5 to initiate a trade.Historic price data is adjusted for splits etc, therefore,historically a price may be shown as $5, but at the actualdate that stock was traded in the market, it could wellhave been a different price.

    5. BENCHMARKINGOnce the appropriate in-sample architecture has beendecided, the architecture and training must be frozen,and the network can proceed to out-of-sample

    benchmarking. At the same time, all the parameters of

  • 8/22/2019 An Empirical Methodology for developing stockmartket trading systems using neural networks

    14/18

    signal strength threshold, stop-loss threshold and moneymanagement threshold used in the in-sample testingmust also be frozen.

    A primary objective of a trading system is to produce(and capture) profit. However, in itself, the amount of

    profit obtained is an unsuitable benchmark for a varietyof reasons. The desire to produce a profit must be

    tempered with such considerations as trading risk, equitycurve management, amount of capital required,drawdown, and consistency. These factors determinehow tradeable a system would be in practice.

    Trading systems are typically assessed according to avariety of metrics. The metrics presented in Table 1 aresourced from Babcock Jr [72], Chande [39], Ruggiero[56], Pardo [65], Kaufman [40], Tharp [46], and Refenes[73]. Each metric is briefly discussed, and whereappropriate, guidelines for desirable values are given.

    It should be remembered that the factors which

    determine whether a system is acceptable or not areultimately the choice of the trader. No system should bechosen if it displays undesirable characteristics;however, individual traders would differ on their choiceof system, dependant on such issues as their tolerance torisk, their amount of starting capital, and their tradinghorizon.

    Metric Brief Description

    Net Profit Ending Capital StartingCapital

    Annualized Gain (%) Annualized Net Profit (Loss).

    aka Annual Percentage Return(APR)

    Number of Trades Total Trades initiated bystrategy

    Exposure (%) Area of portfolio equity exposedto market, as calculated on aday-by-day basis.

    Winning Trades (%) Percentage of trades that werewinners.

    Average Profit (%) Average profit per winningtrade, expressed as a percentage.Includes effect of trading costs,and does not take open positionsinto account.

    Losing Trades (%) Percentage of trades that werelosers.

    Average Loss (%) Average loss per losing trade,expressed as a percentage.Includes effect of trading costs,and does not take open positionsinto account.

    Max. Drawdown (%) Largest peak to valley decline inthe equity curve, on a closing

    price basis, expressed as apercentage of open equity.

    Profit Factor Gross Profit divided by GrossLoss. (Desirable systems shoulddisplay over 2 for this ratio).

    Recovery Factor Absolute value of Net Profitdivided by Max Drawdown.(Desirable system must displayover 1 for this ratio).

    Payoff Ratio Absolute value of average profitper trade divided by averageloss per trade. (Desirable systemmust display over 2 for this

    ratio).Sharpe ratio Sharpe Ratio measures risk

    adjusted return. Specifically,the ratio indicates the historicaverage differential return perunit of historic variability of thedifferential return. Sharpe [74]

    provides a detailed discussion ofthe limitations and uses of theSharpe Ratio. It is calculated byobtaining the average

    percentage return of the tradesgenerated, as well as the

    standard deviation of returns.The average return and averagestandard deviation areannualized by using the averagenumber of days held per trade asa baseline. The annualizedaverage return is then divided bythe annualized standarddeviation of returns.

    Ulcer Index Ulcer Index measures overallvolatility of a portfolio. It is thesquare root of the sum of thesquared drawdowns.

    Luck Coefficient Shows how the largest (byprofit) trade compares to theaverage trade.

    Pessimistic Rate ofReturn

    A statistical adjustment of thewins to losses ratio for the

    purpose of estimating the worstexpected return based on

    previous results. PessimisticRate of Return is calculated bydecreasing the number ofwinning trades by the squareroot of the total winners, andincreasing the number of losingtrades by the square root of thenumber of losers. The result isthen computed by multiplyingthe new number of winners bythe average amount won, anddividing this by the new numberof losers multiplied by theaverage amount lost.

    Equity Drop Ratio Potential for loss expressed as aprobability by computing thestandard deviation of all dropsin the equity curve measured

    from each equity low to theprevious equity high anddividing the result into theannualized return. Only equitydrops greater than 2% are

  • 8/22/2019 An Empirical Methodology for developing stockmartket trading systems using neural networks

    15/18

    considered. The equity dropratio favors higher profits,favors short term fluctuations inthe equity curve, and does not

    penalize a system for large gains(as only equity drops are used tomeasure risk).

    Table 1 Trading System Metrics

    Further, when benchmarking a trading system, it isappropriate to perform a students t-test to determine thelikelihood that the observed profitability is due tochance. This is the method recommended by Katz [75],Katz and McCormick [76], Chande [39], Stakelum [77],and Kaufman [40].

    The means of the strategies developed are tested againstthe mean of the distribution curve that a random tradingstrategy would produce, which is assumed to be zerounder the null hypothesis of no excess returns.

    The hypotheses for the t-tests would be:H0: profit = 0,H1: profit > 0

    The use of the t-test relies on assumptions of normalityand independence. Essentially, these assumptions areconstraints upon the usefulness of the t-test in evaluatingtrading systems.

    Typically, the assumption of normality is dealt with byreference to the Central Limit Theorem, which indicatesthat as the number of cases in the sample increases, the

    distribution of the sample mean approaches normal.Consequently, as long as the sample size is adequate(generally stated as at least 30 samples), the statistic can

    be applied with reasonable assurance.

    The constraint of independence presents a more difficultissue when testing trading systems. Essentially, theviolation is potentially one of serial dependence, whichoccurs when cases constituting a sample are notstatistically independent of one another. One method ofdealing with this issue is to perform a runs test, asdescribed by Vince [49]. The runs test shows whetherthe sequence of wins and losses in the sample trades

    contains more or less streaks than would ordinarily beexpected in a truly random sequence, which has nodependence between trials. Although a runs test doesnot prove or disprove dependency, it can be used todetermine an acceptable confidence limit in order toaccept or reject a hypothesis of dependency. Vincedemonstrates the runs test is essentially a matter ofobtaining the Z scores for the win and loss streaks ofsystems trades, as follows:

    Z Score =

    )1(

    ))(*(

    ))5.0(*(

    N

    NXX

    XRN

    where

    N = total number of trades,

    Equation 1 Computing the Z-Score for a Runs test

    It should be noted that serial dependency is notnecessarily an issue for system tradeability, and for moreadvanced forms of money management, it may well be

    desirable.

    Once out-of-sample benchmarking has been completed,the trader has a realistic model of the trading system,which can then be realistically assessed. From thismodel, the trader can make accurate judgements aboutwhether this particular trading system meets the tradersspecific individual trading requirements.

    Consistency is one of the most important areas for atrader to focus on, and the level of system consistencycan be determined by comparing the figures for the in-sample model to the figures for the out-of-sample model.Clearly, the smaller the amount of variation between the

    two models, the greater the likelihood that the neuralnetwork has captured the generalities of the profit-generating phenomena.

    An accurate model also serves another purpose; it givesthe trader guidelines within which to operate. Shouldthe trader decide to trade using this model, then it will beclear going forward whether the model is operatingwithin the expected guidelines, and, more importantly, itwill give early warning if the model unexpectedlydeviates from expectations. This could happen if someunderlying characteristic of the market changed, and it isimportant for the trader to realize this as soon as

    possible.

    6. CONCLUSIONThis paper has presented a methodology for designingand testing stockmarket trading systems using softcomputing technologies, specifically artificial neuralnetworks.

    A number of models have been developed using themethodology presented in this paper. For examples ofthis methodology in practice, the reader may wish to

    pursue other papers written by the authors in this area,

    for example Vanstone et al. [78, 79]. These papers stepthrough the process of selecting input variables,designing artificial neural networks for trading, and

    benchmarking of the trading results.

    This methodology presented clearly separates the in-sample process of training neural networks and selecting

    parameters from the out-of-sample benchmarkingprocess. It also aims to ensure that if the neural modelsdeveloped during the in-sample training process arecurve-fit, then that is clearly exposed during the out-of-sample benchmarking. This process of breaking up thedevelopment into a number of discrete, testable steps

    provides another advantage it allows the developer tofocus on correcting a specific part of the process if andwhen things go wrong.

  • 8/22/2019 An Empirical Methodology for developing stockmartket trading systems using neural networks

    16/18

    The objective of developing viable mechanicalstockmarket trading systems based on technologies suchas neural networks is achievable. The key is to conductthe development process within a well-definedmethodology, and as close to real-world constraints as

    possible.

    REFERENCES

    1. Tan, C.N.W.,Artificial Neural Networks:Applications in Financial Distress Predictionand Foreign Exchange Trading(Gold Coast,QLD: Wilberto Press, 2001).

    2. White, H., Economic Prediction using NeuralNetworks: The case of IBM Daily StockReturns. Second Annual IEEE Conference onNeural Networks 1988, 451-458.

    3. Oppenheimer, H.R. and G.G. Schlarbaum,Investing with Ben Graham: An Ex Ante Testof the Efficient Markets Hypothesis,Journal ofFinancial and Quantitative Analysis, XVI(3),

    1981, 341-360.4. Lowe, J.,Benjamin Graham on Value Investing

    (New York: Penguin Books, 1994).5. Bierig, R.F., The evolution of the idea of

    "Value Investing": From Benjamin Graham toWarren Buffett,Duke Journal of Economics,12, 2000.

    6. Basu, S., Investment Performance of CommonStocks in Relation to their Price-EarningsRatios: A Test of the Efficient MarketHypothesis,Journal of Finance, 32(3), 1977,663-682.

    7. Banz, R.W., The Relationship between Return

    and Market Value of Common Stocks,Journalof Financial Economics, (9), 1981, 3-18.

    8. Reinganum, M., Abnormal Returns in smallfirm portfolios,Financial Analysts Journal, 37,1981, 52-56.

    9. Rosenberg, B., K. Reid, and R. Lanstein,Persuasive evidence of market inefficiency,Journal of Portfolio Management, 11, 1984, 9-17.

    10. DeBondt, W. and R. Thayler, Further Evidenceof Investor Overreaction and Stock MarketSeasonality,Journal of Finance, XLII(3), 1987,557-581.

    11. Fama, E. and K. French, The cross-section ofexpected stock returns,Journal of Finance,47(2), 1992, 427-465.

    12. Lakonishok, J., A. Shleifer, and R. Vishny,Contrarian Investment, extrapolation and Risk,Journal of Finance, 49(5), 1994, 1541-78.

    13. Fama, E.F. and K.R. French, Size and Book-to-Market Factors in Earnings and Returns,Journal of Finance, 1995, 131-155.

    14. Fama, E.F. and K.R. French, Value versusGrowth: The International Evidence,Journal ofFinance, 1998, 1975-1999.

    15. Frankel, R. and C. Lee, Accounting Valuation,

    Market Expectation and Cross-Sectional StockReturns,Journal of Accounting and Economics,June, 1998, 283-319.

    16. Piotroski, J.D., Value Investing: The use ofHistorical Financial Information to SeperateWinners from Losers, The Journal ofAccounting Research, 38 (Supplement), 2000,1-41.

    17. Kanas, A., Neural Network Linear Forecasts forStock Returns,International Journal ofFinance and Economics, 6, 2001, 245-254.

    18. Aby, C.D., et al., Value Stocks: A Look atBenchmark Fundamentals and CompanyPriorities,Journal of Deferred Compensation,7(1), 2001, 20-31.

    19. Aby, C.D., et al., Selection of UndervaluedStock Investments for Pension Plans andDeferred Compensation Programs,Journal ofDeferred Compensation, 6(3), 2001.

    20. Nison, S.,Japanese Candlestick ChartingTechniques: A Contemporary Guide to theAncient Investment Techniques Of The Far East(New York2001).

    21. Tvede, L., The Psychology of Finance

    (Chichester: Wiley, 1999).22. Warnecke, S.J., Hear this, Bob Prechter! A

    Critic attacks the Elliot Wave Theory,Barron's,January 26, 1987, 1987, 13.

    23. Fama, E., The Behaviour of Stock MarketPrices,Journal of Business, 1965, 34-105.

    24. Taylor, M.P. and H. Allen, The Use ofTechnical Analysis in the Foreign ExchangeMarket,Journal of International Money andFinance, 11, 1992, 304-314.

    25. Silber, W.L., Technical Trading: when it worksand when it doesn't. Working Paper Series:Saloman Brothers Centre for the Study of

    Financial Institutions, Leonard N. Stern Schoolof Business, New York University, 1993).

    26. Pring, M.J.,Martin Pring's Introduction toTechnical Analysis (Singapore: McGraw-Hill,1999).

    27. Neftci, S.N. and A.J. Policano, Can Chartistsoutperform the Market? Market Efficiency testsfor 'Technical Analysis',Journal of FuturesMarkets, 4(4), 1984, 465-478.

    28. Murphy, J.J., Intermarket Analysis,Intermarket, 1988, 20-21.

    29. Neftci, S.N., Naive Trading Rules in FinancialMarkets and Wiener-Kolmogorov Prediction

    Theory: A Study of 'Technical Analysis',Journal of Business, 1991, 549-571.

    30. Brock, W., J. Lakonishok, and B. LeBaron,Simple Technical Trading Rules and theStochastic Properties of Stock Returns,Journalof Finance, 47(5), 1992, 1731-1764.

    31. Mills, T.C., Technical Analysis and the LondonStock Exchange: Testing trading rules using theFT30,International Journal of Finance andEconomics, 2, 1997, 319-331.

    32. Levich, R. and L. Thomas, The significance ofTechnical Trading Rule Profits in the ForeignExchange Markets: A Bootstrap Approach,

    Journal of International Money and Finance,12, 1993, 451-474.

    33. LeBaron, B., Technical Trading Rules andRegime shifts in Foreign Exchange, in

  • 8/22/2019 An Empirical Methodology for developing stockmartket trading systems using neural networks

    17/18

    Advanced Trading Rules, E. Acar and S.Satchell, Editors. 1997, ButterworthHeinemann.

    34. Lehmann, B.N., Fads, Martingales and MarketEfficiency, The Quarterly Journal ofEconomics, CV(1), 1990, 1-28.

    35. Jegadeesh, N., Evidence of PredictableBehaviour of Security Returns,Journal of

    Finance, XLV(3), 1990, 881-898.36. Wilder, J.W.,New Concepts in Technical

    Trading(Greensboro, NC: Trend Research,1978).

    37. Siegel, J.J., Stocks for the Long Run. 3rd ed:McGraw-Hill, 2002).

    38. Pan, H., D. Sornette, and K. Kortanek,Intelligent Finance - An Emerging Direction,Quantitative Finance, 6(4), 2006, 273-277.

    39. Chande, T.S.,Beyond Technical Analysis: howto develop and implement a winning tradingsystem (New York: Wiley, 1997).

    40. Kaufman, P.J., Trading Systems and Methods.

    Wiley Trading Advantage (New York: Wiley,1998).

    41. Longo, J.M., Selecting Superior Securities:Using Discriminant Analysis and NeuralNetworks to differentiate between 'Winner' and

    'Loser' stocks, in UMI Dissertation ServicesNumber 9601890. 1996, Rutgers University.Graduate School - Newark.

    42. Pocini, M., Momentum Strategies applied toSector Indices,Journal for the Colleagues ofthe International Federation of Technical

    Analysts, 2004 Edition, 2004, 3-10.43. Overholser, R., Designing a Money

    Management Strategy: Using Volatility-BasedStops and the Kelly Criterion, TechnicalAnalysis of Stocks and Commodities, 18(5),2000, 38-.

    44. Kase, C.A., Trading with the odds: using thepower of probability to profit in the futures

    market(Chicago: Irwin ProfessionalPublishing, 1996).

    45. Kase, C.A., The Kase Dev-Stop(sm) -Accounting for Volatility, Variance and Skew in

    Managing Trade Risk.46. Tharp, V.K., Trade your way to Financial

    Freedom (NY: McGraw-Hill, 1998).

    47. Sweeney, J.,Maximum Adverse Excursion:analyzing price fluctuations for tradingmanagement(New York: J. Wiley, 1996).

    48. Balsara, N.J.,Money management strategies forfutures traders. Wiley finance editions (NewYork: Wiley, 1992).

    49. Vince, R.,Portfolio Management Formulas:mathematical trading methods for the futures,options and stock markets (NY: John Wiley &Sons, 1990).

    50. Elder, A., Trading for a Living: John Wiley &Sons, 1993).

    51. Azoff, M.E.,Neural Network Time Series

    Forecasting of Financial Markets (Chichester:Wiley, 1994).

    52. Thawornwong, S. and D. Enke, The adaptiveselection of financial and economic variables

    for use with artificial neural networks,Neurocomputing, 56, 2004, 205-232.

    53. Ruggiero, M., Build a real neural net,Futures,June 1996, 1996.

    54. Bauer, R.J. and J.R. Dahlquist, TechnicalMarket Indicators: Analysis & Performance(New York: Wiley, 1998).

    55. Slim, C. and A. Trabelsi, Neural Network for

    Modelling Financial Time Series: A NewApproach, Computational Science and itsApplications, 3, 2003, 236-245.

    56. Ruggiero, M., Cybernetic Trading Strategies:developing a profitable trading system withstate-of-the-art technologies (New York:Wiley, 1997).

    57. Reinganum, M., Selecting Superior Securities(Charlottesville, Va: The Research Foundationof the Institute of Chartered Financial Analysts,1988).

    58. Balsara, N.J., K. Carlson, and N.V. Rao,Unsystematic Futures Profits with Technical

    Trading Rules: A Case for Flexibility,Journalof Financial and Strategic Decisions, 9(1),1996, 57-66.

    59. Pan, H., C. Tilakaratne, and J. Yearwood,Predicting Australian Stock Market IndexUsing Neural Networks Exploiting DynamicalSwings and Intermarket Influences,Journal ofResearch and Practice in InformationTechnology, 37(1), 2005, 43-55.

    60. Raposo, R.d.C.T., A.J.d.O. Cruz, and S.Mendes, Using Frames and Multi-Agents forStock Market Prediction Based onFundamentalist Analysis with Fuzzy Neural

    Networks, WSEAS Transactions on Systems,3(9), 2004, 2892-2897.

    61. Chi, S.-C., et al., The Study of the Relationshipamong Technical Indicators and theDevelopment of Stock Index PredictionSystem.NAFIPS 2003: 22nd InternationalConference of the North American FuzzyInformation Processing Society 2003, 291-296.

    62. Refenes, A.-P.N., M. Azema-Barac, and A.D.Zapranis, Stock Ranking: Neural Networks VsMultiple Linear Regression,IEEE, 1993.

    63. Kim, K.-J. and W.B. Lee, Stock marketprediction using artificial neural networks with

    optimal feature transformation,NeuralComputing and Applications, 13(3), 2004, 255-260.

    64. Gately, E.,Neural Networks for FinancialForecasting(New York: Wiley, 1996).

    65. Pardo, R.,Design, testing, and optimization oftrading systems. Wiley Traders AdvantageSeries (New York: Wiley, 1992).

    66. Shih, Y.,Neuralyst Users Guide: CheshireEngineering Corporation, 1994).

    67. Kim, J.-H., et al., Stock Price Prediction usingBackpropagation Neural Network in KOSPI.International Conference on Artificial

    Intelligence IC-AI'03 2003, 200-203.68. Jaruszewicz, M. and J. Mandziuk, One Day

    Prediction of NIKKEI Index ConsideringInformation from Other Stock Markets.

  • 8/22/2019 An Empirical Methodology for developing stockmartket trading systems using neural networks

    18/18

    International Conference on Artificial

    Intellig