A Framework of Adaptative Multi-strategy Agents Applied to Stock Trading

  • Upload
    smysona

  • View
    214

  • Download
    0

Embed Size (px)

Citation preview

  • 8/8/2019 A Framework of Adaptative Multi-strategy Agents Applied to Stock Trading

    1/16

    Genetically Optimized Artificial Agents using various Strategies applied to Stocks

    Trading

    Forecasting Financial Markets 2003

    Alexandre VIGIER

    BNP PARIBAS Asset Management

    [email protected]

    [email protected]

    Abstract

    This paper aims at presenting a portfolio construction process based on artificial agents whichuse a limited number of, but radically different, investment strategies. Designed to replicate

    simple investment rules well-known by fund managers or traders, the simulated agents adapt

    themselves to the stock they have been assigned to. Viewed as stocks analyst, these agents

    produce ratings or recommendations which are aggregated in order to construct a portfolio.

    The kind of strategies come from two, somewhat opposite foundations : trend following

    (channel breakout) and trend reversal. The first one consists in detecting a trend as soon as the

    underlying price broke a channel defined by a moving average plus (or minus) a multiple of

    standard deviation. The second one is exactly the contrary, as the signal triggered will assume

    a mean reverting behaviour of the underlying time serie. Those two kind of strategies have

    been studied in the past quite extensively, and many authors describe sometimes statisticallysignificant abnormal returns. As it can be assumed, the profitability of those strategies may be

    closely related to various market conditions which use to be hard to detect properly.

    In this study, we implement a methodology based on artificial technical agents which have the

    ability to switch from one strategy to another, considering a utility function relying on their

    relative short term profits. Considering this ability to consider various investment strategies,

    we simulate nothing more than simple human behaviour (without irrational exuberance, such

    as greed or fear) within a disciplined framework.

    As the number of parameters for the two strategies and the switching mechanism is large, wemade use of genetic algorithm for each agent (stock) to derive a set of parameters during an

    in-sample period. The profitability of this particular approach is analysed at the stock level

    and considering a benchmark of the same stocks traded by our artificial agents. During this

    exercise, we will test different assumptions about transactions costs to highlight the strategy

    sensibility to trading frequency. Despite its simplicity, this methodology exhibited interesting

    returns and risk/reward figures for a significant number of equities, during a large enough out

    of sample period.

    Keywords : Stock Selection, Active Portfolio Management, Genetic Algorithms, Multi Agents

    Framework

  • 8/8/2019 A Framework of Adaptative Multi-strategy Agents Applied to Stock Trading

    2/16

    Introduction

    This is an attempt to build a portfolio construction process based on artificial agents which

    use a limited number of, but radically different, investment strategies. Designed to replicate

    simple investment rules well-known by fund managers or traders, the simulated agents adapt

    themselves to the stock they have been assigned to. Viewed as stocks analyst, these agents

    produce ratings or recommendations which are aggregated in order to construct a portfolio.

    The strategies involved are :

    - a trend following (channel breakout) strategy and- a contrarian or trend reversal strategy

    The first one consists in detecting a trend as soon as the underlying price broke a channel

    defined by a moving average plus (or minus) a multiple of standard deviation. The second one

    takes exactly opposite trades, as the signal triggered will assume a mean reverting behaviour

    of the underlying time serie. Both of these strategies have been studied in the past quite

    extensively, and many authors reported statistically significant abnormal returns, although

    over different time horizons of investment.

    I will introduce multi-agents framework and genetic algorithms in section 1. Then I will

    describe the stock selection methodology in section 2 and will comment the results in section

    3.

  • 8/8/2019 A Framework of Adaptative Multi-strategy Agents Applied to Stock Trading

    3/16

    I - Multi-Agents Modelling and Genetic Algorithms

    Multi Agents Framework

    Distributed Artificial Intelligence is one of the various artificial intelligence techniques which,

    as neural networks, fuzzy logic or genetic algorithms, has emerged with the achievement of

    powerful calculations capabilities. For a thorough understanding of this field, one can refer to

    Bond and Gasser (1988). Multi-agents frameworks have been widely used to solve complex

    problems, such as planning, complex simulations in Nature sometimes linked to ethology, and

    others.

    Artificial agents frameworks began to be applied in the finance arena to mimetise investors or

    to replicate observed behaviours, as Farmer Doyne (1999) relates in his paper.

    Parkes David C., Bernardo A. Huberman (1997) describes an interesting methodology for

    stock selection using various families of agents, either communicating or non communicating

    ones, adaptative and non adaptative, leading to the conclusion that an evolved multi agent

    framework can suit to the portfolio construction problem. Jefferies (2001) described an agent

    based model which was able to perform better than random on real financial data.

    Zimmermann et al (2001) showed how to integrate explanatory multi-agent models of

    economic behaviour and an econometric framework into Neural Networks to model

    simultaneously several Foreign Exchange Markets.

    On a pure simulation point of view, we have seen in the past an inclination to model the real

    world with complex differential equation and then, facing the gap between the model and the

    reality, the research community tended to focus on a more microscopic understanding of the

    phenomena.

    I guess that we can obtain much more accurate models or simulation by focusing on this

    microscopic level and by integrating the complex, sometimes irrational, behaviour we use to

    observe in the finance community. By doing do, we well could be able to achieve a better

    understanding of todays financial markets. When we think about financial markets in terms

    of distributed artificial intelligence, we could describe the traders and fund managers using

    cognitive artificial agents, and the markets themselves as blackboards which materialize thoseagents actions.

    Genetic Algorithms

    Defining another field of artificial intelligence techniques, Genetic algorithms (GA) find their

    foundations in the evolution theory inspired by Darwin. First proposed by Holland (1975),

    genetic algorithms belong to the family of population based optimization algorithms and

    proved their ability in solving a number of hard problems, although suffering sometimes from

    convergence speed.

  • 8/8/2019 A Framework of Adaptative Multi-strategy Agents Applied to Stock Trading

    4/16

    Introduced by Cramer (1985) and developed by Koza (1992), Genetic programming represents

    another branch of the genetic algorithms whose goal is to discover solution by incrementally

    evolving the structure of the solution.

    The underlying theory of genetic algorithms relies on mutation and crossover, applied to each

    possible elements of the solution. The interest of this technique is to be able to explore thewhole space of solutions, and to always (when correctly parameterised) having elements

    exploring other areas than optimal or local solutions. As the following figure is suggesting,

    one may easily visualize the above mentioned ideas :

    Figure 1 : Illustration of Genetic Algorithms search capabilities

    During the optimization, genetic algorithm individuals tend to concentrate around the optimal

    points, due to the elitist strategy which consists in conserving the best individuals from one

    generation to another. But the other point is that this kind of algorithms will always to explore

    the remaining solution space as the mutation and crossover mechanism generates new

    individuals at each generation. Mutation is also of great help when an individual (part of the

    genetic solution) is in a hole like the one in the above graph: a descent gradient algorithm

    would be stay in this sub-optimal area, but, due to mutation, genetic algorithms are ensured to

    generate a new individual from the bad one which will have a totally new score with respect to

    the optimum searched.

    In the recent past, various studies have been published which made use of genetic algorithms

    or genetic programming to implement strategies whose goal is to outperform either Exchange

    Rate or Equity Markets. Neely et al (1997) applied a genetic programming approach to derive

    technical trading rules and found an out of sample outperformance over the US Dollar.

    Karjalainen (1999) reported no significant outperformance for SP500 index. Dempster et al

    (2001) found encouraging results as genetic algorithms outperformed other methods on an out

    of sample set for intraday trading on the Foreign Exchange market, transaction costs included.

    More and more, Genetic algorithms and Genetic Programming techniques are considered in

    the financial area.

  • 8/8/2019 A Framework of Adaptative Multi-strategy Agents Applied to Stock Trading

    5/16

    II - Stock Selection Methodology

    In this study, we opted for a modelling in which each agent is affected to one given stock, thus

    in charge to recommend a buy or sell on it. It differs from Vigier (2002) where each agent

    were asked to rate the stock against all the other possible stocks within the investment

    universe. The difference is in the fact that agents are here able to opt for different investment

    strategy : a trend-following strategy or a contrarian, trend reversal strategy.

    A large number of studies have been published about trend following or momentum strategies

    and contrarian, sometimes called Value investment strategies. Quite often, authors reported

    a significant added value or abnormal return investors could expect. The underlying

    assumptions, from a fundamental point of view, suppose that investors may overreact or

    underreact to certain information and that a well informed investor can benefit from these

    extreme behaviours. If one agrees these assumptions, it is perfectly possible to create

    abnormal returns from supposedly antagonist strategies such as value and momentum :momentum driven strategies can outperform significantly over the short term and contrarian

    strategies may do the same over a longer investment horizon. Indeed, these facts are reported

    in Jegadeesh Natasimhan, Sheridan Titman (1993) and DeBondt Werner F. M., Richard

    Thaler (1985, 1987).

    Among these studies, Chan Louis K.C., Natasimhan Jegadeesh, Joseph Lakonishok (1999)

    apply momentum investing for US Equities using both price momentum and earnings revision

    momentum : the results exhibited from 1973 to 1993 and from 1994 to 1998 as an out of

    sample set lead the authors to conclude on significant profits over 6 to 12 months horizon,

    admitting a significant turnover. Dirk Schiereck, Merner De Bondt and Martin Weber (1999)

    study momentum and contrarian strategies applied to the German equity market from 1961 to

    1991 and conclude that both of them appear to beat a passive approach. Clifford S Asness.

    (1997) examines the interaction of value and momentum strategies on US stocks from 1963 to

    1994. The author finds that both strategies are effective, although negatively correlated, and

    related to each other in some aspects. Charles Lee and Bhaskaran Swaminathan (2000) made

    use of trading volume information in order to better characterise momentum strategies and

    their corresponding meaning or power.

    In this study, we implemented the two alternatives, embedded in one investment agent which

    has the ability to switch from one strategy to the other. For sake of simplicity, the switching

    mechanism has been made extremely basic : when we observe a stronger profitability for onesystem we switch to this system, meaning that we only take in consideration the signal

    coming from this system. A third alternative has been envisaged and the agents had the

    possibility to switch to it. This alternative is called the random alternative and consists in

    producing random signal each day. It will be interested to observe how many times agents

    choose this third alternative.

    The trend following strategy we considered consists in buying (selling) if the closing price of

    a stock becomes higher (lower) than :

    MedianLagTF + (-) TFMultiplier * StandardDeviationLagTF

    where

  • 8/8/2019 A Framework of Adaptative Multi-strategy Agents Applied to Stock Trading

    6/16

  • 8/8/2019 A Framework of Adaptative Multi-strategy Agents Applied to Stock Trading

    7/16

    Fig. 3 : Profitability of trend following and contrarian strategies for BNP Paribas equity stock

    As one can see, we can also observe a lack of profitability for the two strategies, as it is the

    case for BNP Paribas equity stock.

    The switching mechanism

    The fact that the two strategies have not the same profitable periods is not so surprising : as

    those two strategies tend to have antagonist behaviours, one will tend to work well as the

    other tend to lose money. This is the critical element : if the two strategies are not correlated,

    even on a short period of time, it has to be positive on an investor point of view, as we will try

    from one strategy to the other.

    In Bourgoin (1998), we opted for a switching mechanism based on a mix of statistical

    measures and technical analysis. In this study, I opted for a most simple mechanism : the

    cumulative performance over a given time horizon in the past. This time lag forms the fifth

    parameter of each agents, and this parameter will also and be jointly estimated using genetic

    algorithms.

    In this study, the optimization function, or fitness function, is the terminal performance at theend of the in sample period, which has been set to December 31st 2001.

    BNP Paribas - Cumulative Profit of trend following and Contrarian Strategies

    -80.00%

    -60.00%

    -40.00%

    -20.00%

    0.00%

    20.00%

    40.00%

    60.00%

    80.00%

    100.00%

    06/01/1

    997

    06/04/1

    997

    06/07/1

    997

    06/10/1

    997

    06/01/1

    998

    06/04/1

    998

    06/07/1

    998

    06/

    10/199

    8

    06/01/1

    999

    06/04/1

    999

    06/07/1

    999

    06/

    10/199

    9

    06/01/2

    000

    06/04/2

    000

    06/07/2

    000

    06/10/2

    000

    06/01/2

    001

    06/04/2

    001

    06/07/2

    001

    06/

    10/200

    1

    06/01/2

    002

    06/04/2

    002

    06/07/2

    002

    06/

    10/200

    2

    Trend Follower Contrar ian

  • 8/8/2019 A Framework of Adaptative Multi-strategy Agents Applied to Stock Trading

    8/16

  • 8/8/2019 A Framework of Adaptative Multi-strategy Agents Applied to Stock Trading

    9/16

    III - Results

    The parameters obtained at the end of the in sample period are worth the comment.

    Whichever the parameter we consider, we can observe in the following figure that those

    parameters may vary a lot from one stock to another, which is not surprising. We can also note

    that we observe some stocks exhibiting close values, either for the lag parameters or the

    multiplier or even the switcher lag.

    Although not reported here, even in I observed a majority of outperfomance during the in

    sample period, a few stocks exhibited an underperformance.

    Fig. 4 : Lag estimated for the switching mechanism

    Fig. 5 : Lag estimated for the switching mechanism

    0 10 20 30 40 50 60 70 80

    Volkswagen

    Telecom Italia

    Ahold

    Aventis

    BBVA

    Carrefour

    Deutsche Bank

    Endesa

    E.ON AG

    France Telecom

    Bayerische Hypound Vereinsbank

    Muenchener Ruekler

    Repsol

    Banco Santander

    Telefonica

    Lag for switching mecanism

    0 20 40 60 80 100 120 140 160 180 200

    Volkswagen

    Telecom Italia

    Ahold

    Aventis

    BBVA

    Carrefour

    Deutsche Bank

    Endesa

    E.ON AG

    France Telecom

    Bayerische Hypound Vereinsbank

    Muenchener Ruekler

    Repsol

    Banco Santander

    Telefonica

    Lag for Trend Following Mode

  • 8/8/2019 A Framework of Adaptative Multi-strategy Agents Applied to Stock Trading

    10/16

  • 8/8/2019 A Framework of Adaptative Multi-strategy Agents Applied to Stock Trading

    11/16

    May be the most interesting illustration is the relative preference for each of the three

    strategies (included the random strategy) over time. In Figure 9 below, one can note that the

    time spent by each agent in the random mode may become significant for some stocks. This

    implies that the trend following and the contrarian strategies may reveals to be unprofitable,

    leading to the conclusion that other type of investment strategies have to be implemented

    instead of the ones considered.

    Analysing Figure 9, we cannot conclude to an overall preference for the trend following

    strategy or the contrarian strategy, excepted for a small number of stocks, like Volkswagen

    equity stock for instance, where its agent spent almost 80 % of time preferring the contrarian

    strategy.

    Figure 9 : Time spent by each agent using the available strategies

    Figures 10 and 11 below represent the cumulative profit over the total period and the out of

    sample period, for both the benchmark (the equally weighted investment universe) and the

    active portfolio.

    0% 10% 20% 30% 40% 50% 60% 70% 80% 90% 100%

    Volkswagen

    Telecom Italia

    Ahold

    Aventis

    BBVA

    Carrefour

    Deutsche Bank

    Endesa

    E.ON AG

    Total Fina Elf

    Societe Generale

    L'Oreal

    Royal Dutch Petroleum

    Sanofi Synthelabo

    Suez

    Average System Preference (all period)

    Trend Following Mode Contrarian Mode Random Mode

  • 8/8/2019 A Framework of Adaptative Multi-strategy Agents Applied to Stock Trading

    12/16

    100

    110

    120

    130

    140

    150

    160

    170

    180

    190

    200

    02/01/1997

    02/03/1997

    02/05/

    1997

    02/07/

    1997

    02/09/

    199

    7

    02/11/1997

    02/01/1998

    02/03/1998

    02/05/

    1998

    02/07/

    1998

    02/09/

    199

    8

    02/11/1998

    02/01/1999

    02/03/1999

    02/05/

    1999

    02/07/

    1999

    02/09/

    199

    9

    02/11/1999

    02/01/20

    00

    02/03/20

    00

    02/05/200

    0

    02/07/200

    0

    02/09

    /200

    0

    02/11/20

    00

    02/01/200

    1

    02/03/20

    01

    02/05/200

    1

    02/07/200

    1

    02/09

    /200

    1

    02/11/20

    01

    02/01/200

    2

    02/03

    /200

    2

    02/05/200

    2

    02/07/200

    2

    02/09

    /200

    2

    02/11/20

    02

    Portfolio Index

    Figure 10 : Cumulative Return over the total period

    0

    20

    40

    60

    80

    100

    120

    31/12/20

    01

    14/01/20

    02

    28/01/20

    02

    11/02/20

    02

    25/02/200

    2

    11/03/200

    2

    25/03/200

    2

    08/04/200

    2

    22/04/20

    02

    06/05

    /200

    2

    20/05/20

    02

    03/06

    /200

    2

    17/06

    /200

    2

    01/07

    /200

    2

    15/07/20

    02

    29/07/20

    02

    12/08/20

    02

    26/08/20

    02

    09/09/20

    02

    23/09/200

    2

    07/10/200

    2

    21/10/200

    2

    04/11/20

    02

    18/11/20

    02

    02/12/20

    02

    Portfolio Index

    Figure 11 : Cumulative Return over the out of sample period

  • 8/8/2019 A Framework of Adaptative Multi-strategy Agents Applied to Stock Trading

    13/16

    We can observe a pretty good ability to minimize the drawdown during year 2002, which is

    the out of sample period we considered, in spite of underperformance periods against the

    index, for instance from the beginning of September to the end of October.

    During the in sample period, the active portfolio appeared to exhibit an annualised excessreturn of 5.7 % given an annualised tracking error of 10.1 %, resulting in an information ratio

    of 0.56.

    For the out of sample period, the same active portfolio exhibited an excess return of 15.1 %

    for an annualised tracking error of 25.1 %, resulting in an information ratio of 0.60. Although

    we were able to keep a positive excess return, we observe an large increase of the tracking

    error, and this should stay under careful monitoring in the future.

    Despite encouraging results, we have to keep in mind that, even accounting for transaction

    costs of 20 basis points, the number of transactions is large, around one transaction every

    week for each stock of the universe. Thus, the sensitivity to transaction costs and slippage is

    critical for the positive achievement of the methodology and must be carefully monitored.

  • 8/8/2019 A Framework of Adaptative Multi-strategy Agents Applied to Stock Trading

    14/16

    Conclusion

    We have implemented a stock selection methodology in which artificial agents are able to

    switch from various investment strategies. The strategies involved implies various parameters

    which were estimated using genetic algorithm. Each agent, affected to one equity stock, was

    able to choose between predefined trend following and contrarian investment strategies, and a

    random strategy generating daily signals. We observed that, during the in sample period,

    during which the genetic algorithms allowed us to estimate the five parameters of each agent,

    the corresponding sets of parameters were very different from one agent to another. Besides,

    the preference for each agent towards the trend following or the contrarian strategy could

    strongly differ from one stock to another and, for some agents, the time spent preferring the

    random strategy may be small but significant.

    The resulting active portfolio exhibited encouraging results in terms of active return andinformation ratio for an investment universe of 50 european stocks, but the transaction costs

    and slippage are of critical importance due a large number of transactions.

  • 8/8/2019 A Framework of Adaptative Multi-strategy Agents Applied to Stock Trading

    15/16

    References

    Franklin Allen and Risto Karjalainen (1999), "Using genetic algorithms to find technical

    trading rules", Journal of Financial Economics, vol. 51, no. 2, published in 1999

    Alan H. Bond, Les Gasser (1988), Readings in Distributed Artificial Intelligence, Morgan

    Kaufmann

    Asness Clifford S. (1997), The Interaction of Value and Momentum Strategies , Financial

    Analysts Journal March/April 1997

    Bandy H.B. (1995), The Adaptative Moving Average , NeuroVest Journal, July/August

    1995

    Bourgoin Frederick, Alexandre Vigier (1998), A combined framework to ForecastUSD/DEM : Hard lessons from a time consistent trading system evaluation , Forecasting

    Financial Markets

    Chan Louis K.C., Natasimhan Jegadeesh, Joseph Lakonishok (1999), The Profitability of

    Momentum Strategies , Financial Analysts Journal

    Copeland Maggie M., Thomas E. Copeland (1999), Market Timing : Style and Size Rotation

    using the VIX , Financial Analysts Journal

    Cramer N. L. (1985), A representation for the adaptative generation of simple sequential

    programs, Proceedings of the first International Conference on Genetic Algorithms and their

    Applications, Erlbaum

    DeBondt Werner F. M., Richard Thaler (1985), Does the stock market overreact ? , Journal

    of Finance 40

    DeBondt Werner F. M., Richard Thaler (1987), Further evidence of investor overreaction

    and stock market seasonnality, Journal of Finance 41

    Dempster M.A.H., Tom W. Payne, Yazann Romahi and G.W.P. Thompson (2001),

    Computational Learning Techniques for Intraday FX Trading Using Popular TechnicalIndicators, IEEE Transactions on Neural Networks, Vol. 12 n 4

    Farmer Doyne (1999), Physicists attempt to scale the ivory towers of finance , Computing

    in Science and Engineering Nov/Dec

    Farmer Doyne (1998), Market Force, Ecology and Evolution, Prediction Company working

    paper

    Farmer Doyne (2000), The Price Dynamics of Common Trading Strategies , Santa Fe

    Institute

  • 8/8/2019 A Framework of Adaptative Multi-strategy Agents Applied to Stock Trading

    16/16

    Holland J.H. (1975), Adaptation in Natural and Artificial Systems, Ann Arbor, University

    of Michigan Press

    P. Jefferies, M. Hart, P.M. Hui, N.F. Jonhson (2001), From Markets games to real-world

    markets, APFA Conference Lige

    Koza J.R. (1992), Genetic Programming : On the programming of Computers by Means of

    Natural Selection, MIT Press

    Lakonishok Joseh, Andrei Sheleifer and Robert W. Vishny (1994), Contrarian Investment,

    Extrapolation and Risk , Journal of Finance (December)

    Lee Charles, Bhaskaran Swaminathan (2000), Price Momentum and Trading Volume ,

    Journal of Finance, October 2000

    Lesmond David A., Michael J. Schill, Chunsheng Zhou (2001), The Illusory Nature of

    Momentum Profits , Tulane University working paper

    Jegadeesh Natasimhan, Sheridan Titman (1993), Returns to buying winners and selling

    losers : Implications for stock market efficiency , Journal of Finance 41

    Neely C.J., P.A. Weller, R. Dittmar (1997), Is technical analysis in the foreign exchange

    market profitable ? A genetic programming approach, Journal of Financial and Quantitative

    Analysis, pp 405-426, December 1997

    Parkes David C., Bernardo A. Huberman (1997), Cooperative Multiagent Search for

    Portfolio Selection , Working Paper

    Schiereck Dirk, Merner De Bondt, Martin Weber (1999), Contrarian and Momentum

    Strategies in Germany , Financial Analysts Journal

    Skouras Spyros (1998), Financial Returns and Efficiency as seen by an Artificial Technical

    Analyst

    Vigier Alexandre (2002), Bottom-up Portfolio Construction based on Momentum Agents

    applied to Pairs of Assets, Forecasting Financial Markets Conference

    Georg Zimmermann, Ralph Grothmann, Cristoph Tietz and Ralph Neuneier (2001), Multi-Agent Modeling of Multiple FX-Markets by Neural Networks