An Application of Deep Reinforcement Learning to Algorithmic Trading

Total Page:16

File Type:pdf, Size:1020Kb

An Application of Deep Reinforcement Learning to Algorithmic Trading An Application of Deep Reinforcement Learning to Algorithmic Trading Thibaut Th´eatea,∗, Damien Ernsta aMontefiore Institute, University of Li`ege(All´eede la d´ecouverte 10, 4000 Li`ege,Belgium) Abstract This scientific research paper presents an innovative approach based on deep reinforcement learning (DRL) to solve the algorithmic trading problem of determining the optimal trading position at any point in time during a trading activity in the stock market. It proposes a novel DRL trading policy so as to maximise the resulting Sharpe ratio performance indicator on a broad range of stock markets. Denominated the Trading Deep Q-Network algorithm (TDQN), this new DRL approach is inspired from the popular DQN algorithm and significantly adapted to the specific algorithmic trading problem at hand. The training of the resulting reinforcement learning (RL) agent is entirely based on the generation of artificial trajectories from a limited set of stock market historical data. In order to objectively assess the performance of trading strategies, the research paper also proposes a novel, more rigorous performance assessment methodology. Following this new performance assessment approach, promising results are reported for the TDQN algorithm. Keywords: Artificial intelligence, deep reinforcement learning, algorithmic trading, trading policy. 1. Introduction expected to revolutionise the way many decision-making problems related to the financial sector are addressed, in- For the past few years, the interest in artificial intelli- cluding the problems related to trading, investment, risk gence (AI) has grown at a very fast pace, with numerous management, portfolio management, fraud detection and research papers published every year. A key element for financial advising, to cite a few. Such complex decision- this growing interest is related to the impressive successes making problems are extremely complex to solve as they of deep learning (DL) techniques which are based on deep generally have a sequential nature and are highly stochas- neural networks (DNN) - mathematical models directly in- tic, with an environment partially observable and poten- spired by the human brain structure. These specific tech- tially adversarial. In particular, algorithmic trading, which niques are nowadays the state of the art in many appli- is a key sector of the FinTech industry, presents particu- cations such as speech recognition, image classification or larly interesting challenges. Also called quantitative trad- natural language processing. In parallel to DL, another ing, algorithmic trading is the methodology to trade using field of research has recently gained much more attention computers and a specific set of mathematical rules. from the research community: deep reinforcement learn- ing (DRL). This family of techniques is concerned with The main objective of this research paper is to an- the learning process of an intelligent agent (i) interacting swer the following question: how to design a novel trad- in a sequential manner with an unknown environment (ii) ing policy (algorithm) based on AI techniques that could aiming to maximise its cumulative rewards and (iii) us- compete with the popular algorithmic trading strategies ing DL techniques to generalise the information acquired widely adopted in practice? To answer this question, this from the interaction with the environment. The many re- scientific article presents and analyses a novel DRL solu- cent successes of DRL techniques highlight their ability to tion to tackle the algorithmic trading problem of deter- arXiv:2004.06627v3 [q-fin.TR] 9 Oct 2020 solve complex sequential decision-making problems. mining the optimal trading position (long or short) at any point in time during a trading activity in the stock market. Nowadays, an emerging industry which is growing ex- The algorithmic solution presented in this research paper tremely fast is the financial technology industry, generally is inspired by the popular Deep Q-Network (DQN) algo- referred to by the abbreviation FinTech. The objective of rithm, which has been adapted to the particular sequential FinTech is pretty simple: to extensively take advantage decision-making problem at hand. The research question of technology in order to innovate and improve activities to be answered is all the more relevant as the trading envi- in finance. In the coming years, the FinTech industry is ronment presents very different characteristics from those which have already been successfully solved by DRL ap- proaches, mainly significant stochasticity and extremely ∗Corresponding author. Email addresses: [email protected] (Thibaut poor observability. Th´eate), [email protected] (Damien Ernst) The scientific research paper is structured as follows. et al. (2017) which introduced the fuzzy recurrent deep First of all, a brief review of the scientific literature around neural network structure to obtain a technical-indicator- the algorithmic trading field and its main AI-based contri- free trading system taking advantage of fuzzy learning to butions is presented in Section 2. Afterwards, Section 3 in- reduce the time series uncertainty. One can also mention troduces and rigorously formalises the particular algorith- Carapu¸coet al. (2018) which studied the application of the mic trading problem considered. Additionally, this section deep Q-learning algorithm for trading in foreign exchange makes the link with the reinforcement learning (RL) ap- markets. Finally, there exist a few interesting works study- proach. Then, Section 4 covers the complete design of the ing the application of DRL techniques to algorithmic trad- TDQN trading strategy based on DRL concepts. Subse- ing in specific markets, such as in the field of energy, see quently, Section 5 proposes a novel methodology to objec- e.g. the article Boukas et al. (2020). tively assess the performance of trading strategies. Section 6 is concerned with the presentation and discussion of the To finish with this short literature review, a sensi- results achieved by the TDQN trading strategy. To end tive problem in the scientific literature is the tendency to this research paper, Section 7 discusses interesting leads prioritise the communication of good results or findings, as future work and draws meaningful conclusions. sometimes at the cost of a proper scientific approach with objective criticism. Going even further, Ioannidis (2005) 2. Literature review even states that most published research findings in cer- tain sensitive fields are probably false. Such concern ap- To begin this brief literature review, two facts have to pears to be all the more relevant in the field of financial be emphasised. Firstly, it is important to be aware that sciences, especially when the subject directly relates to many sound scientific works in the field of algorithmic trad- trading activities. Indeed, Bailey et al. (2014) claims that ing are not publicly available. As explained in Li (2017), many scientific publications in finance suffer from a lack due to the huge amount of money at stake, private FinTech of a proper scientific approach, instead getting closer to firms are very unlikely to make their latest research results pseudo-mathematics and financial charlatanism than rig- public. Secondly, it should be acknowledged that making a orous sciences. Aware of these concerning tendencies, the fair comparison between trading strategies is a challenging present research paper intends to deliver an unbiased sci- task, due to the lack of a common, well-established frame- entific evaluation of the novel DRL algorithm proposed. work to properly evaluate their performance. Instead, the authors generally define their own framework with their 3. Algorithmic trading problem formalisation evident bias. Another major problem is related to the trading costs which are variously defined or even omitted. In this section, the sequential decision-making algorith- mic trading problem studied in this research paper is pre- First of all, most of the works in algorithmic trading are sented in detail. Moreover, a rigorous formalisation of this techniques developed by mathematicians, economists and particular problem is performed. Additionally, the link traders who do not exploit AI. Typical examples of clas- with the RL formalism is highlighted. sical trading strategies are the trend following and mean reversion strategies, which are covered in detail in Chan 3.1. Algorithmic trading (2009), Chan (2013) and Narang (2009). Then, the major- Algorithmic trading, also called quantitative trading, ity of works applying machine learning (ML) techniques in is a subfield of finance, which can be viewed as the ap- the algorithmic trading field focus on forecasting. If the proach of automatically making trading decisions based on financial market evolution is known in advance with a rea- a set of mathematical rules computed by a machine. This sonable level of confidence, the optimal trading decisions commonly accepted definition is adopted in this research can easily be computed. Following this approach, DL tech- paper, although other definitions exist in the literature. niques have already been investigated with good results, Indeed, several authors differentiate the trading decisions see e.g. Ar´evalo et al. (2016) introducing a trading strat- (quantitative trading) from the actual trading execution egy based on a DNN, and especially Bao et al. (2017) using (algorithmic trading). For the sake of generality, algo- wavelet transforms, stacked autoencoders and long short- rithmic trading and
Recommended publications
  • The Future of Computer Trading in Financial Markets an International Perspective
    The Future of Computer Trading in Financial Markets An International Perspective FINAL PROJECT REPORT This Report should be cited as: Foresight: The Future of Computer Trading in Financial Markets (2012) Final Project Report The Government Office for Science, London The Future of Computer Trading in Financial Markets An International Perspective This Report is intended for: Policy makers, legislators, regulators and a wide range of professionals and researchers whose interest relate to computer trading within financial markets. This Report focuses on computer trading from an international perspective, and is not limited to one particular market. Foreword Well functioning financial markets are vital for everyone. They support businesses and growth across the world. They provide important services for investors, from large pension funds to the smallest investors. And they can even affect the long-term security of entire countries. Financial markets are evolving ever faster through interacting forces such as globalisation, changes in geopolitics, competition, evolving regulation and demographic shifts. However, the development of new technology is arguably driving the fastest changes. Technological developments are undoubtedly fuelling many new products and services, and are contributing to the dynamism of financial markets. In particular, high frequency computer-based trading (HFT) has grown in recent years to represent about 30% of equity trading in the UK and possible over 60% in the USA. HFT has many proponents. Its roll-out is contributing to fundamental shifts in market structures being seen across the world and, in turn, these are significantly affecting the fortunes of many market participants. But the relentless rise of HFT and algorithmic trading (AT) has also attracted considerable controversy and opposition.
    [Show full text]
  • Algorithmic Approach to Options Trading
    International Research Journal of Engineering and Technology (IRJET) e-ISSN: 2395-0056 Volume: 08 Issue: 05 | May 2021 www.irjet.net p-ISSN: 2395-0072 Algorithmic Approach to Options Trading Shubham Horambe1, Ketan Khanolkar1, Dhairya Dixit1, Huzaifa Shaikh1, Prof. Manasi U. Kulkarni2 1B. Tech Student, Dept of Computer Engineering and IT, VJTI College, Mumbai, Maharashtra, India 2 Assistant Professor, Dept of Computer Engineering and IT, VJTI College, Mumbai, Maharashtra, India ----------------------------------------------------------------------***--------------------------------------------------------------------- Abstract - Majority of the traders lose money whilst trading sitting in front of the screen for hours. Due to this continuous in options owing to market speculation, emotional trading and monitoring requirement, the performance of Manual Trading lack of risk management. The purpose of this research paper is is limited to the amount of time of the day the trader can to introduce an automated way of trading in options in order dedicate to trading. Other than this, Manual Trading also to tackle these problems. To achieve this, we have adopted suffers from time delays, which is the ability to execute some basic option strategies namely Covered Call, Protective trades in a small-time window. Also, for predicting Put and Covered Strangle. These strategies have been tested unprecedented non-random changes that take place in trade over a period of 5 years (2015-2019) for a set of stocks in the prices, a trader must delve into and analyze more and more U.S options market. information which is more powerful than information available on open-sources like news platforms. This is very Key Words: Options, Algorithmic Trading, Call Option, Put difficult to do for humans, as unlike computers, we can Option.
    [Show full text]
  • Theoretical and Practical Aspects of Algorithmic Trading Dissertation Dipl
    Theoretical and Practical Aspects of Algorithmic Trading Zur Erlangung des akademischen Grades eines Doktors der Wirtschaftswissenschaften (Dr. rer. pol.) von der Fakult¨at fuer Wirtschaftwissenschaften des Karlsruher Instituts fuer Technologie genehmigte Dissertation von Dipl.-Phys. Jan Frankle¨ Tag der m¨undlichen Pr¨ufung: ..........................07.12.2010 Referent: .......................................Prof. Dr. S.T. Rachev Korreferent: ......................................Prof. Dr. M. Feindt Erkl¨arung Ich versichere wahrheitsgem¨aß, die Dissertation bis auf die in der Abhandlung angegebene Hilfe selbst¨andig angefertigt, alle benutzten Hilfsmittel vollst¨andig und genau angegeben und genau kenntlich gemacht zu haben, was aus Arbeiten anderer und aus eigenen Ver¨offentlichungen unver¨andert oder mit Ab¨anderungen entnommen wurde. 2 Contents 1 Introduction 7 1.1 Objective ................................. 7 1.2 Approach ................................. 8 1.3 Outline................................... 9 I Theoretical Background 11 2 Mathematical Methods 12 2.1 MaximumLikelihood ........................... 12 2.1.1 PrincipleoftheMLMethod . 12 2.1.2 ErrorEstimation ......................... 13 2.2 Singular-ValueDecomposition . 14 2.2.1 Theorem.............................. 14 2.2.2 Low-rankApproximation. 15 II Algorthmic Trading 17 3 Algorithmic Trading 18 3 3.1 ChancesandChallenges . 18 3.2 ComponentsofanAutomatedTradingSystem . 19 4 Market Microstructure 22 4.1 NatureoftheMarket........................... 23 4.2 Continuous Trading
    [Show full text]
  • The Future of Computer Trading in Financial Markets (11/1276)
    City Research Online City, University of London Institutional Repository Citation: Atak, A. (2011). The Future of Computer Trading in Financial Markets (11/1276). Government Office for Science. This is the published version of the paper. This version of the publication may differ from the final published version. Permanent repository link: https://openaccess.city.ac.uk/id/eprint/13825/ Link to published version: 11/1276 Copyright: City Research Online aims to make research outputs of City, University of London available to a wider audience. Copyright and Moral Rights remain with the author(s) and/or copyright holders. URLs from City Research Online may be freely distributed and linked to. Reuse: Copies of full items can be used for personal research or study, educational, or not-for-profit purposes without prior permission or charge. Provided that the authors, title and full bibliographic details are credited, a hyperlink and/or URL is given for the original metadata page and the content is not changed in any way. City Research Online: http://openaccess.city.ac.uk/ [email protected] The Future of Computer Trading in Financial Markets Working paper Foresight, Government Office for Science This working paper has been commissioned as part of the UK Government’s Foresight Project on The Future of Computer Trading in Financial Markets. The views expressed are not those of the UK Government and do not represent its policies. Introduction by Professor Sir John Beddington Computer based trading has transformed how our financial markets operate. The volume of financial products traded through computer automated trading taking place at high speed and with little human involvement has increased dramatically in the past few years.
    [Show full text]
  • Algorithmic Trading Strategies
    CSP050 MAY 2020 Algorithmic Trading Strategies ANZHELIKA ISHKHANYAN AND ASHER TRANGLE Memorandum TO: Special Counsel, CFTC Division of Market Oversight FROM: Director, CFTC Division of Market Oversight RE: Algorithmic Trading and Regulation Automated Trading DATE: January 9, 2020 Welcome to DMO. I’m confident that you’ll find the position a challenging one, and I’ve already got a meaty topic to get you started on. I recently received an email from the Chairman expressing his concerns regarding the negative effects of algorithmic trading on financial markets. The Chairman is convinced that the CFTC should have direct access to trading systems’ source code to prevent potential market abuses with systemic implications. To that end, the Chairman proposes we reconsider Regulation Automated Trading (“Regulation AT”) which would require all traders using algorithms to register with the CFTC and would give CFTC direct and unfettered access to their source code. Please find attached the Chairman’s email which outlines his priorities and main concerns pertaining to algorithmic trading. In addition, I have sketched out my own reactions to reconsidering Regulation AT in an informal memo, attached as Appendix I. In addition, you may find it useful to refer to a legal intern’s memoranda, attached as Appendix II, which offers a brief overview of Regulation AT, its history, and a short discussion of other regulators’ efforts to address algorithmic trading. After considering these materials, please come and brief me on the following questions: ● What, precisely, are the public policy challenges posed by the emergence of algorithmic trading, and does this practice pose any serious problems to U.S.
    [Show full text]
  • Staff Report on Algorithmic Trading in U.S. Capital Markets
    Staff Report on Algorithmic Trading in U.S. Capital Markets As Required by Section 502 of the Economic Growth, Regulatory Relief, and Consumer Protection Act of 2018 This is a report by the Staff of the U.S. Securities and Exchange Commission. The Commission has expressed no view regarding the analysis, findings, or conclusions contained herein. August 5, 2020 1 Table of Contents I. Introduction ................................................................................................................................................... 3 A. Congressional Mandate ......................................................................................................................... 3 B. Overview ..................................................................................................................................................... 4 C. Algorithmic Trading and Markets ..................................................................................................... 5 II. Overview of Equity Market Structure .................................................................................................. 7 A. Trading Centers ........................................................................................................................................ 9 B. Market Data ............................................................................................................................................. 19 III. Overview of Debt Market Structure .................................................................................................
    [Show full text]
  • The Rise of Algorithmic Trading and Its Effects on Return Dispersion and Market Predictability
    ______________________________________________________________________________ The rise of Algorithmic Trading and its effects on Return Dispersion and Market Predictability Master Thesis Finance ______________________________________________________________________________ Name: Rick Verheggen Student Number: u1257435 Student E-mail: Personal E-mail: Date: November, 2017 Supervisor: dr. R.G.P. Frehen Second Reader: dr. F. Castiglionesi ______________________________________________________________________________ ALGORITHMIC TRADING & MARKET PREDICTABILITY 2 Abstract A revolution is happening within the financial markets as trading algorithms are executing the grand majority of all trades. Moreover, computers are substituting human traders as well as the emotion involved in their trading. Since trading algorithms are not subject to emotion which is known to cause market inefficiencies, markets are thought to have become more efficient. Additionally, as fewer human traders are active within the market fewer predictable biases apply that are known within behavioral finance and thus is expected that the market has become less predictable. This study was designed to determine the effects of algorithmic trading on dispersion and forecast accuracy. Dispersion is measured through idiosyncratic volatility and tested against algorithmic trading, and by measuring the prediction error of the remaining human traders on the market it is tested to see if analysts’ predictions have indeed become less accurate with the rise of algorithmic trading. Instead,
    [Show full text]
  • The Economics of Algorithmic Trading
    The Economics of Algorithmic Trading Zur Erlangung des akademischen Grades eines Doktors der Wirtschaftswissenschaften (Dr. rer. pol.) von der Fakult¨atf¨ur Wirtschaftswissenschaften der Universit¨atKarlsruhe (TH) genehmigte Dissertation von Ryan Joseph Riordan Tag der m¨undlichen Pr¨ufung:04.08.2009 Referent: Prof. Dr. Christof Weinhardt Koreferent: Prof. Dr. Marliese Uhrig-Homburg Pr¨ufer:Prof. Dr. Gerhard Satzger 2009 Karlsruhe ii Acknowledgements I would like to express my gratitude and thanks to my advisor Prof. Dr. Christof Weinhardt for his support, trust, and advice throughout the preparation of this dissertation. He always knew the right time to encourage me and the right time to challenge me. Without his support my research would not be what it is today. I would also like to thank Prof. Dr. Marliese Uhrig-Homburg for her support as my co-advisor. She was always capable of providing a different point of view on my results. My thanks also go to Prof. Dr. Gerhard Satzger who acted as my examiner and Prof. Dr. Martin Ruckes, the chairman of my committee. I would be remiss if I forgot to mention my colleagues at the Institute of Informa- tion Systems and Management (IISM) and the Information and Market Engineering (IME) graduate school. I would like to thank my colleague Matthias Burghardt who had to endure my complaints about empirical research. I would also like to thank Benjamin Blau for interesting and interdisciplinary discussions. My thanks also go to all of my co-authors, but especially Terrence Hendershott for his insight and positive impact on my approach to research.
    [Show full text]
  • The Evolution of Algorithmic Classes (DR17)
    The evolution of algorithmic classes The Future of Computer Trading in Financial Markets - Foresight Driver Review – DR17 The Evolution of Algorithmic Classes 1 Contents The evolution of algorithmic classes ....................................................................................................2 1. Introduction ..........................................................................................................................................3 2. Typology of Algorithmic Classes..........................................................................................................4 3. Regulation and Microstructure.............................................................................................................4 3.1 Brief overview of changes in regulation .........................................................................................5 3.2 Electronic communications networks.............................................................................................6 3.3 Dark pools......................................................................................................................................8 3.4 Future ............................................................................................................................................9 4. Technology and Infrastructure ...........................................................................................................10 4.1 Future ..........................................................................................................................................10
    [Show full text]
  • The Impact of Algorithmic Trading in a Simulated Asset Market
    Journal of Risk and Financial Management Article The Impact of Algorithmic Trading in a Simulated Asset Market Purba Mukerji 1,* , Christine Chung 2, Timothy Walsh 2 and Bo Xiong 2 1 Department of Economics, Connecticut College, New London, CT 06320, USA 2 Department of Computer Science, Connecticut College, New London, CT 06320, USA; [email protected] (C.C.); [email protected] (T.W.); [email protected] (B.X.) * Correspondence: [email protected] Received: 13 March 2019; Accepted: 17 April 2019; Published: 20 April 2019 Abstract: In this work we simulate algorithmic trading (AT) in asset markets to clarify its impact. Our markets consist of human and algorithmic counterparts of traders that trade based on technical and fundamental analysis, and statistical arbitrage strategies. Our specific contributions are: (1) directly analyze AT behavior to connect AT trading strategies to specific outcomes in the market; (2) measure the impact of AT on market quality; and (3) test the sensitivity of our findings to variations in market conditions and possible future events of interest. Examples of such variations and future events are the level of market uncertainty and the degree of algorithmic versus human trading. Our results show that liquidity increases initially as AT rises to about 10% share of the market; beyond this point, liquidity increases only marginally. Statistical arbitrage appears to lead to significant deviation from fundamentals. Our results can facilitate market oversight and provide hypotheses for future empirical work charting the path for developing countries where AT is still at a nascent stage. Keywords: algorithmic trading; market quality; liquidity; statistical arbitrage 1.
    [Show full text]
  • The Handbook of Trading: Strategies for Navigating And
    The HANDBOOK of TRADING Other McGraw-Hill Books Edited by Greg N. Gregoriou The Credit Derivatives Handbook: Global Perspectives, Innovations, and Market Drivers (2008, with Paul U. Ali) The Handbook of Credit Portfolio Management (2008, with Christian Hoppe) The Risk Modeling Evaluation Handbook (2010, with Christian Hoppe and Carsten S. Wehn) The VaR Implementation Handbook (2009) The VaR Modeling Handbook: Practical Applications in Alternative Investing, Banking, Insurance, and Portfolio Management (2009) The HANDBOOK of TRADING STRATEGIES FOR NAVIGATING AND PROFITING FROM CURRENCY, BOND, AND STOCK MARKETS Greg N. Gregoriou Editor New York Chicago San Francisco Lisbon London Madrid Mexico City Milan New Delhi San Juan Seoul Singapore Sydney Toronto Copyright © 2010 by The McGraw-Hill Companies, Inc. All rights reserved. Except as permitted under the United States Copyright Act of 1976, no part of this publication may be reproduced or distributed in any form or by any means, or stored in a database or retrieval system, without the prior written permission of the publisher. ISBN: 978-0-07-174354-9 MHID: 0-07-174354-5 The material in this eBook also appears in the print version of this title: ISBN: 978-0-07-174353-2, MHID: 0-07-174353-7. All trademarks are trademarks of their respective owners. Rather than put a trademark symbol after every occurrence of a trademarked name, we use names in an editorial fashion only, and to the benefi t of the trademark owner, with no intention of infringement of the trademark. Where such designations appear in this book, they have been printed with initial caps.
    [Show full text]
  • Algorithmic Trading & Computational Finance Using Python 05
    Academy CERTIFIED PROGRAMME ON Algorithmic Trading & Computational Finance using Python & R 01 Academy OVERVIEW NSE Academy & TRADING CAMPUS presents "Algorithmic Trading & Computational Finance using Python & R"- a certified course enabling students to understand practical implementation of Python and R for trading across various asset classes. Financial Markets have revolutionized the way financial assets are traded. Thus it is imperative to develop domain knowledge in Equity analysis, Technical Analysis & Algorithmic Trading. Python and R are technology platform of choice for automated trading as these platform provides multiple APIs and Libraries for quick implementation of trading strategy. Within this course, technology and well defined strategies will be used extensively to maximize returns in a highly competitive environment. This course will provide exposure to application of Python for Algorithmic Trading and "R" for Computational Finance. Students will learn to develop Real-Time Strategies and create a trading engine that will be supported by advance data analytics. Python and R provides a quantitative edge in Advance Capital Markets - Our students will be a step ahead of competition. PROGRAM HIGHLIGHTS The aim of the Certified Program on "Algorithmic Trading & Computational Finance using Python & R" is to develop skills and competency of market participants in securities markets. It's a gateway for every participants to Algorithmic Trading with solid foundation of financial markets. The evaluation process involves project reports
    [Show full text]