Cover Page

Foundations of Computational Finance with MATLAB®




Ed McCarthy













Wiley Logo

To my wife, Diane

Introduction

Why You Should Read This Book

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:

  • “Stop Using Excel, Finance Chiefs Tell Staffs” (Wall Street Journal, 1/22/1017)
  • “The Quants Run Wall Street Now” (Wall Street Journal, article series in May 2017)
  • “At New Digital Lenders, Math Rules” (New York Times, 1/19/2016)
  • “Leveraging Data to Own the Engaged Customer” (Utility Analytics, 11/4/2015)
  • “The Morning Ledger: The Rising Profile of Financial Planning and Analysis” (Wall Street Journal, 12/22/2015)
  • “How Computers Trawl a Sea of Data for Stock Picks” (Wall Street Journal, 4/1/2015)
  • “As Big Data and AI Take Hold, What Will It Take to Be an Effective Executive?” (Wall Street Journal, 1/23/2015)

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.

The Intended Reader

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.)

Why MATLAB®?

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:

  • It's an integrated development environment that combines a code editor, compiler, debugger, interpreter, and graphics capability in a well-designed graphical user interface.
  • It's relatively easy to develop basic MATLAB skills. Of course, it takes time and effort to learn any computer language but the program's consistent syntax usage and extensive documentation improve user productivity.
  • The finance-related MATLAB Toolboxes provide access to multiple financial functions running tested algorithms, which can save many programming hours and much frustration. Additional MATLAB Toolboxes can make it easier to move into other areas, such as big data analytics, as well.
  • MATLAB is used in numerous financial firms, other industries, and over 5,000 universities. If you're a student, your school probably has a MATLAB license.
  • Prices for students and educators have always been low, and several years ago The MathWorks began offering inexpensive personal licenses.
  • Users can access multiple training and support channels through general and specialized books, online and live training courses, and formal and informal (community) support resources. I've completed several of the online training programs offered by The MathWorks, and they were very good.
  • Finally, I believe the knowledge and skills developed in learning MATLAB make it easier to subsequently learn other programming languages.

How to Use This Book

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.

Font Conventions

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

About the Author

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.

MathWorks Information

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:

  • The MathWorks, Inc.
  • 3 Apple Hill Drive
  • Natick, MA, 01760-2098 USA Tel: 508-647-7000
  • Fax: 508-647-7001
  • E-mail: info@mathworks.com
  • Web: mathworks.com
  • How to buy: www.mathworks.com/store

References

  1. Hope, Bradley. “How Computers Trawl a Sea of Data for Stock Picks.” Wall Street Journal, April 1, 2015. Accessed January 15, 2016. https://www.wsj.com/articles/how-computers-trawl-a-sea-of-data-for-stock-picks-1427941801.
  2. Lohr, Steve. “At New Digital Lenders, Math Rules.” New York Times, January 19, 2016. Accessed January 20, 2016. https://bits.blogs.nytimes.com/2016/01/19/at-new-digital-lenders-math-rules/.
  3. Shumsky, Tatyana. “Stop Using Excel, Finance Chiefs Tell Staffs.” Wall Street Journal, January 22, 2017. Accessed January 22, 2017. https://www.wsj.com/articles/stop-using-excel-finance-chiefs-tell-staffs-1511346601.
  4. Willhite, James. “The Morning Ledger: The Rising Profile of Financial Planning and Analysis.” Wall Street Journal, December 22, 2015. Accessed January 15, 2016. https://blogs.wsj.com/cfo/2015/12/22/the-morning-ledger-the-rising-profile-of-financial-planning-analysis/.
  5. Wladawsky-Berger, Irving. “As Big Data and AI Take Hold, What Will It Take to Be an Effective Executive?” Wall Street Journal, January 23, 2015. Accessed February 1, 2016. https://blogs.wsj.com/cio/2015/01/23/as-big-data-and-ai-take-hold-what-will-it-take-to-be-an-effective-executive/.
  6. Zuckerman, Gregory and Bradley Hope. “The Quants Run Wall Street Now,” Wall Street Journal. May 21, 2017. Accessed June 1, 2017. https://www.wsj.com/articles/the-quants-run-wall-street-now-1495389108.

PART I
MATLAB Conventions and Basic Skills