Centre for Computational Finance and Economic Agents and Economics Department Presentation CCFEA London Stock Exchange SETS Simulator and Exercises on How to Implement Automated VWAP and Pairs Trading Strategies CCFEA/i4MT Summer School Program 2008 (1-19 September 2008 ) High Frequency Finance (HFF) and Electronic Trader Training (ETT) Professor Sheri Markose Director CCFEA University of Essex Assisted by CCFEA students: Azeem Malik, Simone Giansante, Nivesh Pawar, Shaimma Masry and Pankaj Shah ROAD MAP OF TUTORIAL 1. Introduction HISTORY: Challenges from Electronic Trading New interdisciplinary area referred to as computational market microstructure at forefront with electronic financial markets and automated trading. 2.The CCFEA SETS Multi agent simulator Project 3. Objective pursued here to test bed algo strategies .a VWAP and advances on VWAP Pairs Trading INTRODUCTION: Potted History of E-Fin Markets • Pre www era markets were a given from venerable forms lost in the mystery of time • Continuous double auction trading facilitated primarily by a market maker or specialist system has had a long tradition • Post www era with its electronic financial markets and automated trading : E- markets can be designed • Rapid decentralized and global access to e-trading platforms • Challenges to floor-based centralized exchanges and restrictive practices of established intermediaries • E- online order submission began in the mid 1990s • Early 1990’s, NYSE and LSE hybridize floor-based market maker based continuous double auctions by replacing open outcry by an automated screen based quotation system and execution of best price. LSE SEAQ Recent Developments • • • • 1/3 of all US stock trades in 2006 were driven by automatic programs and by 2010 claimed to reach 50%. In 2006, at the London Stock Exchange over 40% of all orders were entered by so called algo traders and 60% is predicted for 2007. Futures and options markets amenable to e-trading and both foreign exchange and bond markets are moving toward this.[1] Practitioners expending very large budgets on IT based trading systems in order to cope with the optimal limit and market order scheduling in a very fast and complex environment of the electronic limit order system Algo trading in stat-arb and VWAP strategies Competitive co-evolution : Trading algorithms called Guerrillas , Snipers and Sniffers • [1] The electronic derivatives markets include Eurex, Globex, Matif while those for fixed income securities are eSpeed, Euro MTS, BonkLink and BontNet. 1.2 The new trend of computational market microstructure DEBACLE OF NO TRADE RESULTS OF TRADITIONAL FINANCE WITH GROWING TRADING VOLUMES ●Assumption :Fully optimizing traders necessary for efficient markets and the postulation of the possibility of a homogenous rational expectations HRE not tenable. ●The impossibility of a HRE in financial markets where profits arise from being contrarian : Arthur (1991,1994) highly influential vignette of the El Farol/Minority game Self-referential and contrarian decision problems typical of financial markets: DEFY a unique, homogenous and effective procedure for finding solutions and hence deduction in forecast rules to determine the winning strategy, Markose (200 ●Endogenous heterogeneity in expectations and strategies among initially identical agents Red Queen type arms race in technology that is already evident in the IT innovations of trading in E- markets HIA and Multi-Agent Models ●New paradigm of heterogeneous interacting agent models (Reviewed in Markose, Arifovic and Sunder (2007)) ●Zero intelligence traders Gode and Sunder (1993). Fully optimizing traders not necessary for efficient exploitation of gains from trade; the onus on robust trading rules and institutional design. ●Markose et al (2007) and Markose and Sunder (2007 c) “model verite ” in artificial models : represent real time data with no simplifying assumptions. The historical simulator of the actual SETS1 data and the agent abased replica of the same fall into this category of models. 1.3 NEW HIGH FREQUENCY FINANCIAL ECONOMETRICS FOR IRREGULARLY ARRIVING MARKET EVENTS WITH AUTOCORRELATION/CLUSTERING • • New trend with Biasis et. al. (1995) investigate the ELOB system as is. New high frequency financial econometrics have highlighted statistical properties of market events in at least three different ways Engle and Russell (1994) ACD models : the clustering in trade duration (time between trades), with short trade durations implying fast markets. • Dufour and Engle (2000) they find that as time duration between trades decrease, the price impact of trades decrease and spreads decrease. • Extensions to multivariate models with ACI models (see, Hall and Hautsch, 2004). The ACD/ACI models point to a fundamental persistence or the clustering first observed in trade durations can lead to predictability and the design of trading strategies. • ACI models can tackle multivariate analysis; Hall and Hautsch (07) develops 6 dimensional model; Vasco Leemans (2007) analyses 12 dimensional model Second class of models Econometric testing of Market Micro-Structure ( MMS) • Based on explicit theoretical models of order placement (Sandås (2001))or an informally stated hypothesis (see, Ellul et. al. 2007 ) then conduct econometric tests with ELOB data. • Sandås (2001):The model based estimates are found to yield a flat market impact function relative to the data driven estimates for the same. • Hasbrouck (2007) gives the most up to date discussion of the econometric approach for the testing of hypothesis relating to market microstructure. ●The third class of empirical studies of LOBs Dacorogna et. al. (2001) as well as Bouchaud et. al. (2006), Farmer et. al. (2003), Gabaix et. al. (2003) and Eisler et al. (2007) highlight certain fat tailed properties of (limit) order price changes. As yet no consensus of the size of the power exponent on price changes: Farmer et. al. find power law price impact function of 0.25, Gabaix et. al report 0.5. SELF-REFLEXIVITY IN PRICES • • • • • • • • Arthur et. al. (1997) they make a case for heterogeneous multi-agent models where each agent uses genetic algorithms to arrive at future price predictions. Why Artificial Stock Markets With Adaptive Learning Agents? (i) Price determination is reflexive and arises from how stock market prices are based on agents expectations of the price .Self-reflexivity : That is, the price at t+1 is based on strategies of agents, bit (to buy or sell) based on their respective beliefs, on the price at t+1. The implication of this self-reflexive structure: is that there is no there is no unique way in which agents can form expectations of the price. Most ASMs have agents who are heterogeneous in how they form price forecasts. In Arthur et. al. (1997) they make a case for heterogeneous multi-agent models where each agent uses genetic algorithms to arrive at future price predictions. HAMS: TREND FOLLOWERS and Contrarian Fundamentalists • HAMS include popular archetypes : • Trend followers (who accentuate the direction of historical prices) • Fundamentalists (who effectively implement the contrarian strategy by selling when the market price goes above a threshold and buying when it goes below) 1.4 The demise of traditional ‘informed’/’uninformed’ trader models • View of trading : critiqued by Rosu (2006) Over representing the arrival of new information and on the asymmetry of information among traders as the main drivers for trades and their role in explaining features such as price impact and changes in the bid-ask spreads. • Glosten and Milgrom (1985) and Kyle (1985), so called informed and uninformed traders interact and increased spreads arise because market makers or liquidity providers need to protect themselves from informed traders who aim to trade large volumes as directed by their knowledge of the true value. • In a dynamic price setting Easley and O’ Hara (1992) find : Spread is an inverse function of trade durations The absence of trades and the low volume, in this theory, imply high probability of no information (or less asymmetry of information) Hence risk of adverse selection faced by liquidity providers decreases and with it the spread. Easley and O’Hara (1992) result contradicted • By empirical ACD based Dufour and Engle (2001) analysis that spreads fall under brisk trading conditions with short trade durations. Information based theory of trades that a slow market when traders arrive more slowly to the market has smaller spread, has seriously damaged its empirical validity in view of serial correlation in trade durations and the fact that more trades occur when spreads are small. • Laboratory experimental testing by Bloomfield et. al. (2003) of the informed and uninformed trader hypothesis: found negative evidence that informed agents keen to make a speedy transformation of their informational advantage into profits will dominate market orders. Informational advantage did not prevent these agents from making large numbers of limit orders as well. • With institutional investors, large orders naturally arise from liquidity demands and knowledge of this by other price setting parties in the market will enable them to skew prices against the purveyors of large orders. Following, Rosu (2006) it appears to us that fictions such as ‘informed’ and ‘uninformed’ traders are best abandoned as a useful frame of reference to trading in ELOBs. 2.5Models of Trader Behaviour • • • Focus on optimal order placement strategies within a game theory framework (see, Parlour (1998), Goettler et. al. ( 2003)) have important insights into conditions that could drive individual traders. But they abstract from ingredients of the ELOB for purposes of analytical tractability. Optimal order submission strategy models: Simple one of Bertsimas and Lo(2000), to elaborate AI based adaptive learning strategies (see, footnote 7) with Kissel and Glantz (2003) giving a good survey of some the state of the art order placement strategies. • As yet no consensus as to what information is contained in the LOB ! • • • Idea first mooted in Berkowitz et. al. (1988) that the best unbiased estimate of the price a certain quantity can be transacted at in any relevant trading period by a randomly selected trader is given by the Volume Weighted Average Price (VWAP) on the relevant side of the LOB book. Order book VWAP information available ex ante to a trader Basis of trader strategy as well as the market price impact function that is estimated. Part I : Artificial SETS Simulator Market Microstructure of ELOB 2.1 The LSE SETS1 and transparent ELOB Buy limit orders: bids Sell limit orders: offers or asks Best Price and Spread : (lowest ask - highest bid) Market depth on each side of the market is the listed the volumes Price Priority and time priority (P, V) vector Rank determined by uniquely different price -1 : Competitive 0 : Best 1: 2nd best 2: ……..4+ In SETS1 market orders of a volume greater than the volume at the best price on the LOB is allowed to walk the order book. That is, the remaining volume of the market order that remains after execution at best price is converted into a limit order with time priority only if it cannot be fully executed at the 2nd best price and so on further down the order book. Each of the limit prices at which the market order is executed then assume best price status in quick succession. • Limit orders once entered can leave the system only if they are matched in a trade, cancellation, modification or expiry. The maximum time a market, limit or iceberg order can sit on the order book is 90 calendar days. • Iceberg Orders Objectives of CCFEA E-LOB Project ●ASSUMPTIONS AND BUILDING OF BENCHMARK ELOB SIMULATOR ●EXPERIMENTS : ‘SLOW’ AND ‘FAST’ MARKETS WITH EXOGENOUS MARKET EVENTS RESULTS FROM ELOB SIMULATOR AND COMPARISONS WITH REAL WORLD SETS LOB DATA FOR A TYPICAL DAY ACD Signatures and Market Price Impact Functions Why Build Trading Simulators ? Prop Trader’s view: Kerr Hatrick (Deutsche Bank) S eas onality and S imulation • What is a good s imulator? – Alg orithmic trader’s definition: • one which, for a particular ma rket, mimics the market a s clos ely as pos s ible, in order that reg ularities in the market might be taken advanta ge of by ag ents us ing the s imulator • T his means , at s ome s tag e, embedding s eas onality, and an impact model, in s ome form • O ther, s impler cons traints - number of trades , depth of orderbook, typical trade s iz e – s hould be pres erved, to jus tify the cos t es timates of the algorithm des igner, and allow exploratory data analys is • P enn-L ehman exchange s imulator: developed jointly by L ehman B ros prop des k (NY ) and Univers ity of P enns ylvania • Utiliz es Is land order book data • Integrates orders originating from different trading s trategies with Is land data us ing proprietary fill model to as s es s cos t • F ill model – unfortunately - US centric & opaque A Prop Trader’s Wish List for a E-Trading Simulator contd C os ting H F T rading S cenarios • K ey P roblem: D ifficult to es timate cos t s ens itivity of key algorithm parameters • What if I changed the ag gres s ivenes s ? • What confidence intervals can I place on the impact of my activity with s tealth algorithm X to be? • At what time would it be bes t to us e algorithm x? • What algorithm s hould I us e today? • A s imulator cons trained by real-world s eas onality would provide the ideal quantitative framework to analyz e ques tions above… • B ut it has to embed knowledg e of local market micros tructure in a way that is cons itent with real 11 world impact models , for derived cos ts to be relevant Schema of the CCFEA E-Simulator for a SETS type market : Fully Rebuild SETS API (III) Format for Clients of e-Plat to send in their Algo trades. In turn receives Trade Confirmation etc E-Platform (II) Merge Client orders with Real Time Historical Data of Limit Order Book using exact SETS Market Microstructure Rules Provide Real Time Screen Based Information on Traded VWAP; Spreads etc Client Decision Support System (IV) Queries Data Base (I) using SQL Commands ; Obtains Real Time Feeds from historical Market Data in (II). This data can be used to generate trading strategies and evaluate strategies using the ASM AI based agents Data Base (I) Rebuild Limit Order Book SETS Data Rebuilding Order Book SET Data Simulator useful for testbedding Algo Strategies • Check robustness over different stocks and over different market regimes (boom/bust) • We will consider two work horses of algo strategies and put them through their paces: VWAP Pairs Trading Algo VWAP Strategy: Sell (buy) of X units in a given period T so that the executed VWAP(e) is (below) than the market Traded VWAP(m) P j VWAPt k m = V j j =1 V j j =1 where Pj and V j is the price and volume of jth trade respectively, is the total number of trades over the interval t0 and tk when over which the strategy is being evaluated. The algo- trading strategy sell (buy) for this will have the following pseudo code : Sell (Buy) at the bid (ask) whenever the bid (ask) is greater (less) than the market VWAPt j m t j , t j (t 0 , t k ). Note in the figures above for BGY, the market VWAP is below the Bid and Ask till about 4pm, so it is a good time to sell as a market order but not so good to buy. For DMG and GSK, with the Bid and Ask below the VWAP, it gives ample opportunities to buy, but not a good time to sell. Fig Price Impact of large volume Automated : Ask < Market VWAP Impact of 5000 Buy order Size Explanation of large volume price impact impact The figures above shows how the algo VWAP strategy to buy at ask when below market VWAP, responds to a large order size of 5000. The first graph is the market without the algo trade. Note, how the ask jumps up in the second graph, followed by a sharp rise in the bid as well below as the market finds it difficult to absorb the large 5000 size buy order. When failing to find enough volume at best ask, the large buy market order, walks the book, raising the ask immediately and hence the spread. This then makes the algo execution of the 5000 buy order at ask below VWAP no possible and the remainder of the order adds to the buy side by raising the bid. ‘Advanced’ VWAP Strategies Competition:Buy100,000 shares over the day and max P/L • The common complaint re. VWAP is that it does not ‘optimize’ P/L Crude VWAP algo does not try and get price improvements and does not place greater volume at more advantageous prices during the day Eg: Consider DMGT, whilst buying using crude VWAP one could have bought it through out It is hard to ask your broker to do better than VWAP : but you can get an algo to do better Results on 1st of March, 2007 P/L BGY (ADV %) DMGT (ADV %) Ordinary Vwap Advanced 1 Vwap Advance 2 Vwap -4612.90 -297.25 +2657.50 -1617.00 -395.00 +190.22 Advance 2 VWAP Pairs Trading:Simple Take • Hard to predict directional changes in stock price movements accurately; instead take relative movements • The pairs trade was developed in the late 1980s by quantitative analysts and pioneered by Gerald Bamberger while at Morgan Stanley. With the help of others at Morgan Stanley at the time, including Nunzio Tartaglia, Bamberger found that certain securities, often competitors in the same sector, were correlated in their day-to-day price movements. When the correlation broke down, i.e. one stock traded up while the other traded down, they would sell the outperforming stock and buy the underperforming one, betting that the "spread" between the two would eventually converge. (Wikipedia) Trading Pairs by Douglas S. Ehrman Pairs trading is a non-directional strategy that identifies two companies (or futures contracts) with similar characteristics whose price relationship is outside of its historical range. The strategy simply buys one instrument and sells the other in hopes that relationship moves back toward normal. The idea is the price relationship between two related instruments tends to fluctuate around its average in the short term, while remaining stable over the long term. Pairs Trading Using price ratios and algo triggers using (+1,-1)std deviation bands Ingredients to Pairs Algo: At each cycle/round trip of open and close profit non-negative • Step 1 take a pair of stocks (BGY trading @ 414 and DMGT @710) • Fix quantity of cheap BGY at 1000 • Volume of DMGT is then at price ratio 414/710 • Achieves cash neutrality (zero net position) when long in one and short in another How to install std deviation bands ? Try a dynamic rolling band • Track the price ratio for 10 minutes from opening and take (+1, -1) std dev of it • Project these bands to be the std dev for next 10 minutes • Enter market as price ratio falls and hits the -1 std deviation implying expensive stock price has become more expensive and the cheap one cheaper Reverse position when price ratio hits +1 std dev Tracking a Trade Cycle: start with buy cheap and sell the expensive then reverse trades at +1 std and price ratio has risen TRADE CYCLE Trading Cycle Ratio Of Prices 0.535623 0.539923 Quantity 1000 536 1000 536 Buy /Sell BUY SELL SELL BUY Price 417.25 779 419.25 776.5 Market Time 10:25:19 10:25:08 11:52:42 11:52:42 Profit n Loss -417250 +417544 + 419250 -416204 Net P/L : P/L on BGY (cheaper stock) : 2 p X1000= 2000p = £20 P/L on DMGT (expensive stock): 2.5 p x 536= 1340 = £13.40 If new price ratio is used and 539 is bought of DMGT at 776.5 then outlay is 418533.5 whic exceeds what was sold. Problems with crude price ratio: Use same price ratio in first leg to determine volume of expensive whilst closing ! Consider Reversing by having to sell cheap asset and buy back the expensive one Price Ratio (Cheap Asset/ Expensive Asset Denominator) has gone up These are the possibilities BGY(Cheap) Up Down DMGT (Expensive) Up Down Could lose on the expensive stock Best outcome Not applicable as ratio will go down Could lose on the cheap stock Problems in determining the Std Deviation Bands • Volatile pairs (or price ratios) give you more trading opportunities and profits • But how does one determine these bands ? • If one knew the actual std deviation and also the appropriate time window for which to estimate the bands, there are more profits to be had PROFIT AND LOSS CHART Predicted Standard Deviation 10 Minutes LAST TRADE PRICE RATIOS SERIES 10540p ASK-BID PRICE RATIOS -2385.5p 20 Minutes 6111.5p Actual Standard Deviation 10 Minutes 20 Minutes 16771.5 25578.5p 1990.5p 8110.0p 27614p Competition: Design a simple rule that will improve on the std dev bands for pairs trading • Use bid ask prices rather than traded prices to determine price ratios • Report pairs algo profits at end of day for the same pair of stock in the two teams Concluding Remarks • SETS Simulator which is precisely rebuilt from the SETS Order Book Data will give very good test beds for algo strategies To be able to test out robustness of strategies across stocks and across regimes is ‘priceless’ CCFEA has done extensive precise price impact analysis with sensitivity to time of day/intra day seasonality to help in optimal trade scheduling Behaviour of order book in market crises eg. August 2007 etc can be analysed in detail via the simulator to play the E-Limit Order Book game better Trading Pairs by Douglas S. Ehrman Pairs Trading: Quantitative Methods and Analysis by Ganapathy Vidyamurthy - 2004 - 230 pages Some References: Market Microstructure • • • • • • • • • Hasbrouck, J., 2007, Empirical Market Microstructure: The Institutions, Economics and Econometrics of Securities Trading The Microstructure Approach to Exchange Rates by Richard K. Lyons Easley, D. and M. O’Hara (1987). Price, trade size, and information in securities markets. Journal of Financial Economics 19(1), 69–90. Easley, D. and M. O’Hara (1992). Time and the process of security price adjustment. Journal of Finance 47(2), 576–606. Eisler, Zoltan; Kertesz, Janos; Lillo, Fabrizio; Mantegna, Rosario N. 2007 Diffusive behavior and the modeling of characteristic times in limit order executions, Quantitative Finance. Gabaix, X., P. Gopikrishnan, V. Plerou, and H. E. Stanley (2003). A theory of power-law distributions in financial market fluctuations. Nature 423, 267– 270. Hasbrouck, J. (1991). Measuring the information content of stock trades. The Journal of Finance 46(1), 179–207. Kissell, R. and M. Glantz (2003). Optimal Trading Strategies: Quantitative Approaches for Managing Market Impact and Trading Risk. American Management Association. Gode, D.K and Sunder, S.(1993). “Allocative efficiency of markets with zero intelligence traders : markets as a partial substitute for individual rationality”, Journal of Political Economy, 101, 119-137. High Frequency Financial Econometrics • • • • • • • • Wing Lon Ng, 2007, “Analyzing Liquidity and Absorption Limits of Electronic Markets with Volume Durations”, Mimeo Bauwens and Hautsch (2006), Modelling Financial High Frequency Data using Point Processes, Core Discussion Paper 2006/80., Université catholique de Louvain Carrasco, M., and X. Chen (2002), Mixing and Moment Properties of Various GARCH and Stochastic volatility Models, Econometric Theory, 18(1), 17—39. Dufour, A. and Engle, R. F. (2000), The ACD-Model: Predictability of the time between consecutive trades, Discussion paper, ISMA Centre, University of Reading. Fernandes, M., and J. Grammig (2006), A Family of Autoregressive Conditional Durations Models, Journal of Econometrics, 130(1), 1—23. Härdle, W. (1990), Applied nonparametric regression, Cambridge University Press,Cambridge. Hautsch, N. (2002), Modelling intraday trading activity using Box-Cox ACD models, Working paper, CoFE. Hautsch, N. (2004), Modelling Irregularly Spaced Financial Data, Springer, Heidelberg. Agent Based (ACE)Approach • • • • • • • • Reading on using ACE for real world market design: Markose, M, et. al. A smart market for passenger road transport (SMPRT) congestion: An application of computational mechanism design Journal of Economic Dynamics and Control , Volume 31, Issue 6, June 2007, Pages 2001-2032 Markose, S., J. Arifovic and S. Sunder ( 2007), Advances in Experimental and Agent-based Modelling: Asset Markets, Economic Networks, Computational Mechanism Design and Evolutionary Game Dynamics Volume 31, Issue 6, pages 1801-1807 Readings for rationale for ACE in complex dynamics with contrarian structures Arthur, W.B., (1994). “Inductive Behaviour and Bounded Rationality”, American Economic Review, 84, pp.406-411. Markose, S.M, 2005 , “Computability and Evolutionary Complexity : Markets as Complex Adaptive Systems (CAS)”, Economic Journal , Vol. 115, pp.F159-F192. Markose, S.M, 2004, “Novelty in Complex Adaptive Systems (CAS): A Computational Theory of Actor Innovation”, Physica A: Statistical Mechanics and Its Applications, vol. 344, pp. 41- 49. Fuller details in University of Essex, Economics Dept. Discussion Paper No. 575, January 2004. Markose S.M., 2006 “Gödelian Foundations of Non-Computability and Heterogeneity In Economic Forecasting and Strategic Innovation”, Presented at Gödel Centenary Colloquium at Computability in Europe 2006 Logical Approaches to Computational Barriers http://privatewww.essex.ac.uk/~scher/ Historical Data Analysis Observed Stock DMGT Market Number of Capitalisation Order Daily Average Daily Average Price Volume Small-Cap 43,547 804.07 4,192,801.24 BGY Mid-Cap 46,246 448.09 6,889,446.42 GSK Large-Cap 130,136 1,415.86 30,131,304.88 Duration Analysis • help in analyzing length time spent in certain economic event GSK DGM T BGY Diurnal Pattern