Copyright © 2018 by John Wiley & Sons, Inc. All rights reserved.
Published by John Wiley & Sons, Inc., Hoboken, New Jersey.
Published simultaneously in Canada.
No part of this publication may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, electronic, mechanical, photocopying, recording, scanning, or otherwise, except as permitted under Section 107 or 108 of the 1976 United States Copyright Act, without either the prior written permission of the Publisher, or authorization through payment of the appropriate per-copy fee to the Copyright Clearance Center, Inc., 222 Rosewood Drive, Danvers, MA 01923, (978) 750–8400, fax (978) 646–8600, or on the Web at www.copyright.com. Requests to the Publisher for permission should be addressed to the Permissions Department, John Wiley & Sons, Inc., 111 River Street, Hoboken, NJ 07030, (201) 748–6011, fax (201) 748–6008, or online at www.wiley.com/go/permissions.
Limit of Liability/Disclaimer of Warranty
MATLAB® is a trademark of The MathWorks, Inc. and is used with permission. The MathWorks does not warrant the accuracy of the text or exercises in this book. This work's use or discussion of MATLAB® software or related products does not constitute endorsement or sponsorship by The MathWorks of a particular pedagogical approach or particular use of the MATLAB® software. While the publisher and authors have used their best efforts in preparing this work, they make no representations or warranties with respect to the accuracy or completeness of the contents of this work and specifically disclaim all warranties, including without limitation any implied warranties of merchantability or fitness for a particular purpose. No warranty may be created or extended by sales representatives, written sales materials or promotional statements for this work. The fact that an organization, website, or product is referred to in this work as a citation and/or potential source of further information does not mean that the publisher and authors endorse the information or services the organization, website, or product may provide or recommendations it may make. This work is sold with the understanding that the publisher is not engaged in rendering professional services. The advice and strategies contained herein may not be suitable for your situation. You should consult with a specialist where appropriate. Further, readers should be aware that websites listed in this work may have changed or disappeared between when this work was written and when it is read. Neither the publisher nor authors shall be liable for any loss of profit or any other commercial damages, including but not limited to special, incidental, consequential, or other damages.
For general information on our other products and services or for technical support, please contact our Customer Care Department within the United States at (800) 762–2974, outside the United States at (317) 572–3993, or fax (317) 572–4002.
Wiley publishes in a variety of print and electronic formats and by print-on-demand. Some material included with standard print versions of this book may not be included in e-books or in print-on-demand. If this book refers to media such as a CD or DVD that is not included in the version you purchased, you may download this material at http://booksupport.wiley.com. For more information about Wiley products, visit www.wiley.com.
Library of Congress Cataloging-in-Publication Data
Names: McCarthy, Ed (Edward), 1955– author.
Title: Foundations of computational finance with MATLAB / by Ed McCarthy.
Description: Hoboken, New Jersey : John Wiley & Sons, Inc., [2018] | Includes index. |
Identifiers: LCCN 2018014808 (print) | LCCN 2018016054 (ebook) | ISBN 9781119433873 (epub) | ISBN 9781119433910 (pdf) | ISBN 9781119433859 (cloth)
Subjects: LCSH: Finance—Mathematical models. | Finance—Data processing.
Classification: LCC HG106 (ebook) | LCC HG106 .M396 2018 (print) | DDC 332.0285/53—dc23
LC record available at https://lccn.loc.gov/2018014808
Cover Design: Wiley
Cover Image: © monsitj/iStockphoto
To my wife, Diane
If you're planning a career in corporate or investment finance or already working in one of those areas, you're probably proficient with financial calculators and spreadsheets. Those technologies have proven their value, and it's likely they will remain essential tools for many years. (I still use a 30-year-old Hewlett Packard 12C calculator regularly and it works perfectly, albeit a bit slower than newer models.)
But the nature of data and analytics are changing, and those changes are influencing financial analysis and management. Traditional financial data still drive decisions, but those data are being supplemented by increasing volumes of nontraditional information and new computational tools. Consider these headlines from recent years, which are just a small sample of the articles on these themes:
I believe this paradigm shift requires a new approach to financial analysis and management. Specifically, finance professionals must supplement their calculators and spreadsheets with more flexible and powerful computational platforms. These platforms can work with the new data models while still providing the tools needed for traditional financial analysis. As the headlines suggest, remaining competitive in financial analysis and management will require an understanding of and skill with computational finance. This knowledge will allow you to access data from multiple sources, develop customized financial analytics, and then distribute your tools and findings across a variety of platforms.
Transitioning to the new paradigm is a challenge, though, because it means learning about computational finance. Other authors have addressed this topic, but they focused on advanced material for readers who combine extensive math, statistics, programming, and finance backgrounds, such as financial engineers and academics.
In contrast, I wrote this book for readers seeking an introductory text that links traditional finance material to the MATLAB computational platform. This includes upper-level undergraduate finance students, graduate students, finance practitioners, and those with STEM backgrounds seeking to learn about finance. My assumption is that your background will be: (1) A business student or finance professional who is comfortable with finance theory but has modest computer programming experience beyond spreadsheets, or (2) A STEM student or professional who has a more extensive programming background but less experience with finance.
I'm also assuming you have completed first courses in linear algebra and statistics and will have access to MATLAB and the required MATLAB Toolboxes. Many universities have MATLAB licenses, but if you must buy the software, it's very inexpensive for students, and the MATLAB Home edition makes it readily affordable for nonacademic users. (Pricing details are available on the mathworks.com site.)
That's a fair question, because there are a host of programming languages being used in finance. But there's a question-and-answer dialogue I've seen numerous times on web message boards for quantitative and computational finance that helps answer the question. It goes something like this:
Q. I'm thinking of getting into quantitative finance (or applying to a quant educational program) and need advice on programming languages. Should I start with MATLAB or Python? R or S? C++ or Java?
A. Yes.
The answer is a bit snarky, so the respondent usually explains that learning a programming language is not a one-and-done lifetime proposition. People change employers during their careers and the new employer might emphasize a different language. Computer technologies and programming languages evolve, too, and it's necessary to keep up with those changes, as those of us who started programming with punched cards and card readers can attest.
I have no business affiliation with The MathWorks but I believe the MATLAB software is well-suited for an introduction to computational finance for several reasons:
Part I introduces the MATLAB syntax and how to use the program. If you're new to MATLAB or need a review, start with those chapters. For a deeper introduction, you can supplement that material with the resources online The MathWorks offers, including the no-cost MATLAB Onramp course at matlabacademy.mathworks.com. That course uses an interactive format and takes about two hours to complete. Other online tutorials can be found at www.mathworks.com/support/learn-with-matlab-tutorials.html. If you have the time and funds, the MATLAB Fundamentals course is an excellent in-depth introduction.
Part II demonstrates how MATLAB can be used as a computational platform in finance. The material in Chapter 5, “The Time Value of Money,” has general applications throughout the remaining chapters, so I suggest reviewing that material. The text reviews the underlying finance material being discussed in each chapter and includes suggestions for further reading.
Finally, practice using the program interactively or programmatically by entering commands in the MATLAB Command window as you work through the examples. Learning to use software is somewhat like learning to drive. Reading a book on safe driving gives you an intellectual perspective but it makes driving sound deceptively easy. Coding—like getting behind the steering wheel and pulling into high-speed traffic for the first time—is best experienced hands-on. Fortunately, writing code is a lot less nerve-wracking than highway driving.
The book uses several different font styles to help you distinguish the material:
Bold: Function names, reserved keywords, matrices, and vectors
Monospaced italic: Command window inputs. Example:
x = 7
Monospaced: MATLAB
output and responses. Example:
x =
7
Monospaced starting with %
: Code comment lines that do not execute
Normally spaced lines starting with %: Text comments
I have worked as a freelance finance writer since the mid-1980s, and during that time I have written for many of the financial service industry's leading publications. These include Bloomberg Wealth Manager, CFA Institute Magazine, Institutional Investor online, Financial Planning, Journal of Accountancy, and the Journal of Financial Planning. Earlier in my career I published a technology book for financial advisors, The Financial Advisor's Analytical Toolbox (Irwin), and one for consumers, Fast Forward MBA in Personal Finance (Wiley). I have also written numerous print and web articles for custom publishers and many of the largest U.S. and international financial services firms. My primary experience as a writer and the focus for many of my articles has been explaining complex finance topics and technologies to readers.
My first exposure to MATLAB was in the mid-1990s when I was doing research for my first book, which included a discussion of the software's financial modeling capabilities. My use of the program intensified while I was studying for a PhD in finance, and I believe my experience at that time supports the premise for this book. The lack of available resources to link finance theory with the requisite computer programming made that aspect of the work more difficult than it needed to be. I chose not to finish my dissertation and left school to write full-time, but I continued to use the software and periodically work through new financial mathematics and MATLAB texts to stay current. I am a MathWorks Certified MATLAB Associate and am working toward The MathWorks Certified MATLAB Professional designation.
The material in this book was developed using the MATLAB R2016B, 2017A, and 2017B releases and MATLAB Toolboxes for the same releases.
For MATLAB and Simulink product information, please contact: