An Introduction To Algorithmic Finance,

Transcription

An Introduction to Algorithmic Finance,Algorithmic Trading and Blockchain

This page intentionally left blank

An Introduction to AlgorithmicFinance, Algorithmic Tradingand BlockchainSATYA R. CHAKRAVARTYIndian Statistical Institute, IndiaPALASH SARKARIndian Statistical Institute, IndiaUnited Kingdom – North America – Japan – India – Malaysia – China

Emerald Publishing LimitedHoward House, Wagon Lane, Bingley BD16 1WA, UKFirst edition 2020Copyright 2020 Emerald Publishing LimitedReprints and permissions serviceContact: permissions@emeraldinsight.comNo part of this book may be reproduced, stored in a retrieval system, transmittedin any form or by any means electronic, mechanical, photocopying, recording orotherwise without either the prior written permission of the publisher or a licencepermitting restricted copying issued in the UK by The Copyright Licensing Agencyand in the USA by The Copyright Clearance Center. Any opinions expressed inthe chapters are those of the authors. Whilst Emerald makes every effort to ensurethe quality and accuracy of its content, Emerald makes no representation impliedor otherwise, as to the chapters’ suitability and application and disclaims anywarranties, express or implied, to their use.British Library Cataloguing in Publication DataA catalogue record for this book is available from the British LibraryISBN: 978-1-78973-894-0 (Print)ISBN: 978-1-78973-893-3 (Online)ISBN: 978-1-78973-895-7 (Epub)

Satya R. Chakravarty dedicates this book to his granddaughter,Anvi Ananyo Chakravarty (Gini).Palash Sarkar dedicates this book to his mother.

This page intentionally left blank

ContentsPrefacexiiiPart I Derivatives, Options and Stochastic DominanceChapter 1 Background and Preliminaries3Chapter 2 Valuation of Cash Flows and Fixed Income Securities:An Abridged Analysis2.1 Introduction2.2 Net Present Value2.3 Bond as a Fixed Income Security7779Chapter 3 A Brief Analytical Exposition of Markets for Options3.1 Introduction3.2 Payoff and Profit Functions of Some StandardOptions3.3 Options as Hedging Strategies3.4 Forward and Futures Contracts1111Chapter 4 The4.14.24.3191919Binomial Model: A Simplified AnalysisIntroductionFormal FrameworkValuation of Options in the Cox–Ross–RubinsteinModelChapter 5 Brownian Motion, Itô Lemma and theBlack–Scholes–Merton Model5.1 Introduction5.2 Preliminaries11141722252525

viiiContents5.35.45.55.6Itô Lemma, Distribution of Stock Price and Priceof a Forward ContractThe Black–Scholes–Merton Partial DifferentialEquationBlack–Scholes–Merton Pricing FormulaeThe Greek Letters27293032Chapter 6 Exotic Options: An Illustrative Presentation6.1 Introduction6.2 Asian Options6.3 Binary or Digital Options6.4 Barrier Options3535353738Chapter 7 An Abbreviated Theoretical Treatment of StochasticDominance Relations7.1 Introduction7.2 First-order Stochastic Dominance7.3 Second-order Stochastic Dominance41414143Part II Algorithmic IssuesChapter 8 Option Pricing Using Finite Difference Method8.1 Crank-Nicolson Method8.2 American Options495053Chapter 9 Option Pricing Using Monte Carlo Methods9.1 Simulation of Wiener Process9.2 Simulating Itô Stochastic Differential Equation9.3 Valuing European Options9.4 Valuing American Options9.5 Monte Carlo Integration575758595961Chapter 10 Determining Stochastic Dominance Relations63Chapter 11 Trading: Background Notions and MarketMicrostructure11.1 Trading Systems6768

Contents11.211.311.411.511.611.7Some Relevant NotionsOrder BookOrderOrder Matching AlgorithmsAlgorithmic TradingEfficient Market HypothesisChapter 12 Algorithmic Trading Strategies12.1 Time Weighted Average Price12.2 Volume Weighted Average Price12.3 Percentage of Volume12.4 Participation of Weighted Price12.5 Bertsimas–Lo Dynamic ProgrammingStrategy12.6 Implementation Shortfall12.7 Almgren–Chriss Efficient Trading Frontierix6972737475777979808181818485Chapter 13 Portfolio Optimisation13.1 Markowitz Portfolio Optimisation13.2 Kelly Criterion13.3 Universal Portfolios9192101103Chapter 14 Measures of Risk14.1 VaR and CVaR14.2 Sharpe Ratio14.3 Copula109109112115Chapter 15 High-frequency Trading15.1 Market Making15.2 Exploiting Limit Order Book15.3 Mean Reversion and Pairs Trading15.4 Arbitrage15.5 Market Manipulation119120120121121125

xContentsPart III Blockchain and CryptocurrencyChapter 16 Background Concepts for Blockchain16.1 Cryptography16.2 Distributed Computing129129133Chapter 17 Introduction to Blockchain17.1 Transactions17.2 Blocks of Transactions17.3 Public Ledger as a Blockchain17.4 Distributed Public Ledger17.5 Permissionless versus Permissioned Blockchain137137137138140143Chapter 18 Cryptocurrency: Basics18.1 Owner18.2 Transactions18.3 Cryptocurrency Addresses18.4 Recapitulation18.5 Creation of a Block via Proof of Work18.6 Block Reward and Creation of Cryptocurrency18.7 Hash Rate18.8 Updating the Difficulty Parameter18.9 Controlling the Rate of Money Creation18.10 Choosing between Competing Blocks18.11 Confirmation of Transaction18.12 No Double Spending18.13 The 51% apter 19 Cryptocurrency: Further Issues19.1 Mining Pools19.2 Change of Rules19.3 Forks19.4 Value of a Cryptocurrency19.5 Cryptocurrency Exchange19.6 Cryptocurrency Community19.7 Stablecoin19.8 Criticisms of Cryptocurrencies157157157158160160161162162

Contents19.919.1019.1119.1219.13Government RegulationsCentral Bank–issued Digital CurrencyLightning NetworkSidechainProof of Stakexi163164165166166Chapter 20 Examples of Cryptocurrencies20.1 Bitcoin20.2 Ethereum and Smart Contracts20.3 Ripple and Payment Systems169169171173Chapter 21 Applications of Blockchain21.1 Fintech Applications21.2 Logistics Management21.3 Supply Chain Management21.4 Governance177177178178179References181Index185

This page intentionally left blank

PrefaceOur motivation for writing this book is to provide a broad-based and accessibleintroduction to three of the presently most important areas of computationalfinance, namely, option pricing, algorithmic trading and blockchain. To the bestof our knowledge, no other book in the market provides such a coverage. It is ourhope that the book will be useful to senior undergraduates, graduates and MBAstudents, as well as researchers and practitioners. In its first part, the book reflectsoption pricing in different frameworks. A simple treatment of assessment of cashflows and fixed security derivatives is also presented. Finally, the problem of assetranking is addressed in this part of the book. In a broad sense, the second part ofthe book covers algorithmic issues related to finance. The first three chapters ofthe second part addresses some computational issues related to the theory discussed in the first part. The rest of the second part, consisting of five chapters,discusses approaches for algorithmic trading, portfolio optimisation and riskmanagement. The third part of the book is devoted to blockchain and cryptocurrency. A fairly detailed introduction to both of these topics is presented alongwith various applications of blockchain to financial and other applications. Thewide coverage of the book and its authentic and well-expressive presentationmake the book quite up-to-date from both theoretical and practical sides, andhighly reactive to the problems of recent concern. We believe that in satisfying itsobjectives, our book offers a unique perspective to contemporary aspects offinance in a lucid manner for senior undergraduates, graduates, MBA studentsand regulators. Further, the book can serve as a useful reference for basic theoryto practitioners in the area. Much of finance today involves a fair amount ofmathematics. In the book, we have tried to find a balance between having toomuch and too little mathematics. Detailed mathematical derivations have beengiven in some cases, helpful aids have been provided in some other cases so that areader can complete the derivations, and for cases where the proofs takes us toofar away from the discussion at hand, the proofs have been omitted. In ouropinion, the first two parts of the book can be understood by somebody having acollege-level introduction to calculus, linear algebra, probability and statistics.The mathematical requirement for the third part is markedly different from thatof the first two parts. It is due to this reason we have tried to keep the mathematical description of the third part to a bare minimum. Several chapters of thebook have been used for offering a course on the theory of finance to Master ofScience in Quantitative Economics students at the Indian Statistical Institute,Kolkata, India, in the Fall Semester of 2019. The materials were well received by

xivPrefacethe students. We express our sincere gratitude to the students for their enthusiasmand helpful comments in the process of direct interactions. We thank PinakiSarkar for providing several suggestions to improve the coverage of the book. Wealso thank Sanjay Bhattacherjee for reading and commenting on some chapters ofthe third part.Satya R. Chakravarty and Palash SarkarKolkata, IndiaDecember 2019

Part IDerivatives, Options and StochasticDominance

This page intentionally left blank

Chapter 1Background and PreliminariesThe financial industry is enormously important to state, national and worldeconomies. This industry relies extensively on mathematical modeling of underlying instruments. Computational techniques become helpful in designing relatedalgorithms that enable us to understand how markets function and also lendthemselves to highly relevant research problems.To understand the application of a specific computational technique to theparticular financial instrument, it becomes indispensable to have a clear perception of the underlying theory. However, because of vastness of the theoreticalliterature, some selection becomes necessary.We choose the highly attractive field of option pricing, a core task ofcomputational finance and risk analysis. An option is a contract that gives theholder the right, but not an obligation, to buy or sell an asset at a pre-agreedprice, the strike price, on or before the date of expiry, the maturity date. Thebroad field of option pricing is quite ambitious and diverse enough to call for awide range of computational tools. Confining mostly to option pricing enablesus to have a more coherent and comprehensive textbook, to a large extent, andavoids being distracted away from computational issues. An option is a standard example of a derivative, a financial instrument whose value relies on oneor more assets that are usually referred to as underlying assets. Generally, ittakes the form of a contract to buy or sell an asset or item like commodity,property, etc. at the strike price, on or before the expiration date. Otherexamples of a derivative include bonds, futures contracts, forward contracts andswaps. (For detailed discussions see, among others, Jarrow and Turnbull, 2000.)The financial market in which derivatives are traded may be designated as thederivatives market. We assume a perfect market in the sense that there are nocosts of transactions, no restrictions on short sales and existence of a commonborrowing and lending rate. Short selling is a business tactic that involvesborrowing an asset and selling it immediately, repurchasing the asset (hopefullyat a lower price) and returning it to the lender to close the process. (Chapters 11and 15 of this monograph provide further discussions along this line.)A derivatives market can be partitioned into two subgroups, one in whichderivatives are traded in an organised exchange market where maintenance ofmarket price and all transparencies are provided. An example of an exchangetraded derivative is an option. Under a futures contract, an exchange-tradedAn Introduction to Algorithmic Finance, Algorithmic Trading and Blockchain, 3–5Copyright 2020 Emerald Publishing LimitedAll rights of reproduction in any form reserveddoi:10.1108/978-1-78973-893-320201001

4An Introduction to Algorithmic Finance, Trading and Blockchainagreement, the buyer is accountable to buy the underlying asset at a prearranged price at a future date. The seller makes the commitment to handover the asset at the settled price and date. Another market-traded derivative is abond, a debt security issued by government and corporate sectors to raise fundsfor various purposes including expansion of one or more sectors, infrastructuralimprovements and payment of existing debts. A financial market in whichtrading of bonds takes place is known as a bond or credit or debt market. Atrading in the other market is of over-the-counter (OTC) type. This type of offexchange trading takes place directly between the traders without supervision ofan exchange. An example of an OTC derivative is a forward contract underwhich two parties make an agreement to buy or sell an asset at a designated dateon a promised price. A swap is an off exchange-traded derivative under which afinancial instrument is exchanged between the parties concerned at a prespecified time.A highly significant component of the derivatives market is risk. Risks can beof various types such as asset risk, interest rate risk, foreign exchange risk, creditrisk, commodity risk and so on. While asset risk arises from volatility in assetprices, interest rate risk refers to the chance that variations in rate of interest maynegatively affect an investment. Likewise, foreign exchange risk emerges fromfluctuations in exchange rate between two different currencies. On the other hand,credit risk indicates the possibility of a lender’s loss of principal and interest if aborrower fails to make committed payments. Commodity risk is related to theapprehension of loss that may arise because of oscillation in a commodity price inthe future. But risks may also bring about unexpected benefit. Investors wish tomake risky investments with the expectation of making profits in the future.Given that there can be alternative notions of risk, use of appropriate tools for thepurpose of risk management becomes essential. Different forms of derivativesbecome useful in this situation. More precisely, derivatives are financial instruments for administering financial risks. They transfer different forms of financialrisks to derivatives market. They are financial securities for hedging or borderingrisks in the sense of protecting or at least reducing risks. The basic principleunderlying asset pricing is the existence of non-arbitrage. According to anarbitrage opportunity, a trader can take advantage of price imbalance to extractrapid profit without any risk. Consequently, the non-arbitrage assumption meansthe rule of a single price. (Further discussions on arbitrage are available inChapters 11 and 15 of this monograph.)Since in the first part of the monograph we will be mainly concerned withoptions, a brief, rigorous and authoritative discussion on options and relatedphenomena is presented in Chapters 3–6. For the sake of completeness, anabridged analysis of valuation of cash flows and fixed income securities is presented in Chapter 2.Given that any investment in a risky asset includes the chance of a loss, it isquite likely that an investor will look into the problem of risk management in aportfolio, a composition of assets held by the investor. The investor often maybe confronted with the necessity of ordering distributions of random returns onvarious financial assets or combinations of them on the basis of his preferences,

Background and Preliminaries5represented by a von Neumann–Morgenstern utility function. This issue hasbeen addressed in several pioneering contributions to the literature. A quitegeneral approach to the resolution of the problem is the rule of stochasticdominance that enables us to order the distributions of random rates of returnon assets for large classes of utility functions. No specific knowledge about theform of utility function is necessary. A concise illustrative introduction to theconcept of stochastic dominance is presented in Chapter 7.

This page intentionally left blank

Chapter 2Valuation of Cash Flows and Fixed IncomeSecurities: An Abridged Analysis2.1 IntroductionIn order to judge profitability of an investment, say, a firm’s investment in aproject, it becomes necessary to compare present values of cash inflows(benefits) and outflows (costs). The net present value (NPV) criterion thatlooks at the difference between present values of benefits and costs is astandard tool for this type of analysis. Alternatives to this are benefit–costratio and internal rate of return (IRR), a discount rate that makes NPVequal to zero. In this chapter, we present a brief discussion on these criteria.A brief discussion on bond as a particular type of constant earning security isalso presented.2.2 Net Present ValueWhen a firm has decided to start a project, this decision will have some importantimplications on the firm’s financial position for one or more periods. The firm hasto obtain an overall indicator that will judge whether it will become better off orworse off when the project has been undertaken.The NPV method, which is employed to determine current values of all inflowsand outflows associated with an investment, is an appropriate tool for this purpose. The risk-free interest rate r over the lifespan of the project is assumed toremain constant.We denote money inflows (benefits) and outflows (costs) occurring in period tby Bt and Ct, respectively, where t 5 0,1 ,T. Here, t 5 0 and t 5 T represent,respectively, the current period and final period for which the investment affectsbenefits and costs. While C0 indicates the size of the initial investment, for t 1, Ctmay be regarded as the maintenance cost. It is natural to assume that C0 . 0 andCt 0 for t 1. On the other hand, B0 is likely to be 0, but from t 5 1 onwards,Bts are non-negative. Then the discounted present value (DPV) of the inflowsAn Introduction to Algorithmic Finance, Algorithmic Trading and Blockchain, 7–10Copyright 2020 Emerald Publishing LimitedAll rights of reproduction in any form reserveddoi:10.1108/978-1-78973-893-320201002

8An Introduction to Algorithmic Finance, Trading and BlockchainTcomes to be t50Bt.ð1 1 rÞtTSimilarly, the DPV of the outflows becomes t50Ct.ð1 1 rÞtThen the NPV of the project can now be defined asBt 2 Ctt:t ¼ 0 ð1 1 rÞTNPV ¼ (2.1)The project should be undertaken or rejected according as NPV . 0 orNPV , 0. The firm is indifferent between the two options if NPV 5 0. ForNPV to be an appropriate guideline for launching a new project, it becomesnecessary to get correct estimates of Bt and Ct in different periods. If investment amounts differ across projects, then the NPV criterion cannot be used tocompare them. Also the lifespan of the projects have to be the same for thepurpose of comparison.A firm can also use the benefit–cost ratio as a yardstick to judge whether aproject should be undertaken or not. It is formally defined asTB¼C Btð1 1 rÞt Ctð1 1 rÞtt¼0Tt¼0:(2.2)Evidently, B/C is greater or less than 1 if and only if the NPV is positiveor negative. Higher values of both the criteria NPV and B/C are better forthe investor. However, they may rank alternative projects in differentdirections.The final evaluator we use in the current context is the IRR, the rate ofinterest rate that makes the NPV of the project equal to 0. Since interest ratecan be interpreted as time value of money, IRR is the interest rate that aninvestor can expect from his investment. If IRR is higher than the rate ofdiscounting then the project should be undertaken. IRR can be implicitlydefined asT Bt 2 Ctt ¼ 0 ð1 1 IRRÞt¼ 0:(2.3)In general, there are T roots of this equation. In such a case, the highest rootwhose value exceeds the discount rate may be used as IRR. In case there aremutually several exclusive projects, then the firm should choose the one thatproduces the highest IRR. When the discount rate varies over time, the use ofthe IRR criterion as an evaluation principle for selection of a project may not befeasible. Thus, while the concern of NPV is project surplus, IRR is concernedwith break-even money flow. Of these two criteria, NPV is more popular as aproject selection yardstick because it is easy to understand in terms of profitability of a project. (For further discussions, see Bierwag, 1987 and Damodaran,2010.)

11.3 Order Book 72 11.4 Order 73 11.5 Order Matching Algorithms 74 11.6 Algorithmic Trading 75 11.7 Efficient Market Hypothesis 77 Chapter 12 Algorithmic Trading Strategies 79 12.1 Time Weighted Average Price 79 12.2 Volume Weighted Average Price 80 12.3 Percentage of Volume 81 12.4