24,99 €
Graduate from Excel to MATLAB¯® to keep up with the evolution of finance data Foundations of Computational Finance with MATLAB¯® is an introductory text for both finance professionals looking to branch out from the spreadsheet, and for programmers who wish to learn more about finance. As financial data grows in volume and complexity, its very nature has changed to the extent that traditional financial calculators and spreadsheet programs are simply no longer enough. Today's analysts need more powerful data solutions with more customization and visualization capabilities, and MATLAB provides all of this and more in an easy-to-learn skillset. This book walks you through the basics, and then shows you how to stretch your new skills to create customized solutions. Part I demonstrates MATLAB's capabilities as they apply to traditional finance concepts, and PART II shows you how to create interactive and reusable code, link with external data sources, communicate graphically, and more. * Master MATLAB's basic operations including matrices, arrays, and flexible data structures * Learn how to build your own customized solutions when the built-ins just won't do * Learn how to handle financial data and industry-specific variables including risk and uncertainty * Adopt more accurate modeling practices for portfolios, options, time series, and more MATLAB is an integrated development environment that includes everything you need in one well-designed user interface. Available Toolboxes provide tested algorithms that save you hours of code, and the skills you learn using MATLAB make it easier to learn additional languages if you choose to do so. Financial firms are catching up to universities in MATLAB usage, so this is skill set that will follow you throughout your career. When you're ready to step into the new age of finance, Foundations of Computational Finance with MATLAB provides the expert instruction you need to get started quickly.
Sie lesen das E-Book in den Legimi-Apps auf:
Seitenzahl: 356
Veröffentlichungsjahr: 2018
Cover
Introduction
Why You Should Read This Book
The Intended Reader
Why MATLAB®?
How to Use This Book
Font Conventions
About the Author
MathWorks Information
References
PART I: MATLAB Conventions and Basic Skills
CHAPTER 1: Working with MATLAB® Data
1.1 Introduction
1.2 Arrays
1.3 Character Arrays
1.4 Flexible Data Structures
References
Further Reading
CHAPTER 2: Working with Dates and Times
2.1 Introduction
2.2 Finance Background: Why Dates and Times Matter
2.3 Dates and Times in MATLAB
References
Notes
CHAPTER 3: Basic Programming with MATLAB®
3.1 Introduction
3.2 MATLAB Scripts and Functions
References
CHAPTER 4: Working with Financial Data
4.1 Introduction
4.2 Accessing Financial Data
4.3 Working with Spreadsheet Data
4.4 Data Visualization
References
PART II: Financial Calculations with MATLAB
CHAPTER 5: The Time Value of Money
5.1 Introduction
5.2 Finance Background
5.3 MATLAB Time Value of Money Functions
5.4 Internal Rate of Return
5.5 Effective Interest Rates
5.6 Compound Annual Growth Rate
5.7 Continuous Interest
5.8 Loans
References
CHAPTER 6: Bonds
6.1 Introduction
6.2 Finance Background
6.3 MATLAB Bond Functions
6.4 Bond Analytics
6.5 Callable Bonds
References
Further Reading
Note
CHAPTER 7: Dealing with Uncertainty and Risk
7.1 Introduction
7.2 Overview of Financial Risk
7.3 Data Insights
7.4 Data Relationships
7.5 Creating a Basic Simulation Model
7.6 Value at Risk (VaR)
References
Further Reading
Notes
CHAPTER 8: Equity Derivatives
8.1 Introduction
8.2 Options
8.3 Option Pricing Models
8.4 Options' Uses
8.5 Appendix: Other Types of Derivatives
References
Further Reading
Note
CHAPTER 9: Portfolios
9.1 Introduction
9.2 Finance Background
9.3 Portfolio Optimization
9.4 MATLAB Portfolio Object
References
CHAPTER 10: Regression and Time Series
10.1 Introduction
10.2 Basic Regression
10.3 Working with Time Series
References
APPENDIX 1: Sharing Your Work
A1.1 Introduction
A1.2 Publishing a Script
References
APPENDIX 2: Reference for Included MATLAB® Functions
Index
End User License Agreement
Chapter 1
Table 1.1 MATLAB Data Terminology
Table 1.2 MATLAB Array Types
Table 1.3 Functions that Create Vectors
Table 1.4 Functions that Generate Random Numbers
Table 1.5 Common Scalar Operations
Table 1.6 Row-column Compatibility
Table 1.7 Correlation Coefficients for Stocks, Bills, and Bonds
Table 1.8 Row and Column Index Reference Values
Table 1.9 Relational Operators
Table 1.10 Logical Operators and Functions
Table 1.11 Stock Data
Chapter 2
Table 2.1 Common Day-Count Methods
Table 2.2 Date and Time Variables
Table 2.3 Common Datetime Identifiers
Table 2.4 Serial Date Conversion Functions
Table 2.5 Calculating Time Between Dates
Table 2.6 Elapsed Time Functions for Different Date Formats
Chapter 4
Table 4.1 Built-in Financial Charts
Chapter 5
Table 5.1 Simple Interest Calculation
Table 5.2 Simple Interest Period Adjustments
Table 5.3 Compound Interest
Table 5.4 Compound Interest Formula Derivation
Table 5.5 Future Value of Unequal Cash Flows
Table 5.6 Future Value of Equal Cash Flows
Table 5.7 Present Value Formulas
Table 5.8 Year-End Investment Values
Chapter 6
Table 6.1 Bond Classifications
Table 6.2 Bond Terms
Table 6.3 Bond Usage Abbreviations
Table 6.4 Bndprice Function Arguments
Table 6.5 Percentage Change in Price with Interest Rate Changes
Table 6.6 US Treasury Rates
Chapter 7
Table 7.1 Covariance Table Interpretation
Table 7.2 Correlation Table Interpretation
Chapter 8
Table 8.1 Fundamental Option Terms
Table 8.2 Intrinsic Value Versus Option Price
Table 8.3 Replicated Portfolio Terminal Value
Table 8.4 Binprice Function
Table 8.5 The Greeks
Table 8.6 The Greeks' Syntax
Table 8.7 Comparative Profits
Table 8.8 Option Spreads
Table 8.9 MATLAB Supported Exotic Options
Chapter 9
Table 9.1 Unconstrained Portfolio Weights
Table 9.2 Constrained Portfolio Weights
Table 9.3 Optimal Unconstrained Allocations for Target Returns
Chapter 1
Figure 1.1 Variables Listed in Workspace Window
Figure 1.2 Data Import Options
Figure 1.3 10-Year Treasury Yields 1998–2017
Figure 1.4 Plotting with Missing Data
Figure 1.5 Filling Missing Data With Estimated Value
Figure 1.6 Variable Data Editor
Figure 1.7 Reviewing Data Cells
Figure 1.8 Structure Data Fields
Figure 1.9 CSV Data Format
Figure 1.10 Microsoft Excel File Format
Figure 1.11 Import Data Tool
Figure 1.12 Imported Data
Figure 1.13 Data Import Options
Chapter 2
Figure 2.1 Import Tool
Figure 2.2 Import Date Formats
Figure 2.3 Custom Date Format Field
Figure 2.4 Dates Converted to Datetime Format
Figure 2.5 Imported Table
Figure 2.6 Date Conversion in Microsoft Excel
Figure 2.7 x2mdate Excel to MATLAB Conversion
Figure 2.8 Microsoft Excel Dates in MATLAB
Figure 2.9 Plotting with Datetime Variables
Chapter 3
Figure 3.1 Editor Toolbar
Figure 3.2 Future Value Script
Figure 3.3 Set Path Dialog Box
Figure 3.4 Function Template
Figure 3.5 futureValueCalc Function
Figure 3.6 futureValueCalc Help Screen
Figure 3.7 Input Prompt
Figure 3.8 Input Request
Figure 3.9 Warning Dialog Box
Figure 3.10 Error Dialog Box
Figure 3.11 Input Problem Box
Figure 3.12 Potential Error Highlights
Figure 3.13 Possible Error Correction
Figure 3.14 Code Improvement Suggestion
Chapter 4
Figure 4.1 Google Finance Download
Figure 4.2 Yahoo! Finance Download
Figure 4.3 10-Year Bond Rate
Figure 4.4 Data Import Tool
Figure 4.5 Import Tool Data Display
Figure 4.6 Importing Datetime Variables
Figure 4.7 Specifying Data Types
Figure 4.8 Importing Selected Variables
Figure 4.9 Full Import Tab
Figure 4.10 Data Import to Table
Figure 4.11 Variables Window Data View
Figure 4.12 Imported FRED Data
Figure 4.13 Import Selection Options
Figure 4.14 Data Import Problem
Figure 4.15 Corrected Data Import
Figure 4.16 Importing Data to Column Vectors
Figure 4.17 Data Imported as Column Vectors
Figure 4.18 Attempted Import as Matrix
Figure 4.19 Date Data Fails to Import
Figure 4.20 Downloaded FRED Data
Figure 4.21 Spreadsheet Data Import
Figure 4.22 Selected Workspace Variables
Figure 4.23 Plots Tab
Figure 4.24 Apple Close Price
Figure 4.25 AAPL and IBM Plot
Figure 4.26 Show Plot Tools Icon
Figure 4.27 Plot Property Editor Dialogue Box
Figure 4.28 AAPL and IBM Prices
Figure 4.29 Dates Displayed as Serial Dates
Figure 4.30 Dates with DatetimeTickFormat Argument
Figure 4.31 Series Comparison with a Single
y
-axis
Figure 4.32 Data Plot with Double
y
-axes
Figure 4.33 Single Data Series in Single Figure
Figure 4.34 2 × 1 Array of Blank Plots
Figure 4.35 Two Data Series in Two Plots
Figure 4.36 Property Editor Display Name
Figure 4.37 Insert Legend Icon
Figure 4.38 Legend Locator
Figure 4.39 Adding Text to Plot
Figure 4.40 Surface Plot
Figure 4.41 Hi-Lo-Close Plot for AAPL
Figure 4.42 Candlestick Plot for AAPL
Chapter 6
Figure 6.1 Normal Yield Curve
Chapter 7
Figure 7.1 Historical Asset Returns Excel Worksheet
Figure 7.2 MATLAB Import Screen
Figure 7.3 MATLAB Workspace after Data Import
Figure 7.4 Annualized S&P 500 Returns
Figure 7.5 Treasury Bills vs. Treasury Bonds, 1928 to 2016
Figure 7.6 Histogram of S&P 500 Annual Returns
Figure 7.7 Histogram of S&P 500 Annual Returns (12 Bins)
Figure 7.8 Histogram of Treasury Bond Annual Returns (12 Bins)
Figure 7.9 Histfit of Normal(5,1) Distribution
Figure 7.10 HIsfit of Normal(5,1) Distribution with 10,000 Points
Figure 7.11 S&P 500 Returns Versus Normal Distribution
Figure 7.12 T-bond Returns Versus Normal Distribution
Figure 7.13 Probplot with Normal(5,1) Random Data
Figure 7.14 Probplot for S&P 500 Data
Figure 7.15 AMZN Daily Close Price 2015–2016
Figure 7.16 Simulated 10-Day Amazon Price Paths
Figure 7.17 Simulated Returns for Normal (12,20) Distribution
Figure 7.18 Simulated Returns with VaR Levels
Chapter 8
Figure 8.1 CBOE Price Data for AAPL
Chapter 9
Figure 9.1 Three-asset Class Efficient Frontier
Figure 9.2 Imported Stock Data
Figure 9.3 Returns Data
Figure 9.4 Portfolio Object Efficient Frontier
Figure 9.5 Optimal Portfolio
Chapter 10
Figure 10.1 Scatterplot of Consumer Confidence Versus Durable Goods Orders
Figure 10.2 Scatterplot of Consumer Confidence Versus Durable Goods Orders with Line
Figure 10.3 Fitting a Straight Line to a Curve
Figure 10.4 Fitted Curve Comparisons
Figure 10.5 Fitting a Line with polyfit
Figure 10.6 Plot Function Output
Figure 10.7 Histogram of Model Residuals
Figure 10.8 FTS Icon in the Apps Menu
Figure 10.9 FTS Dialog Box with Data Loaded
Figure 10.10 Access the FTSGUI Tools
Figure 10.11 FTS Data Tools
Figure 10.12 FTS Technical Analysis Tools
Figure 10.13 FTS Graphs Tools
Figure 10.14 File Load for FTSGUI
Figure 10.15 Basic AMZN Close Price Line Plot with Volume
APPENDIX 1
Figure A1.1 Publishing Tool Strip
Figure A1.2 Publish Options
Figure A1.3 Edit Configurations Dialog Box
Figure A1.4 Output File Format Options
Figure A1.5 HTML Output Format
Figure A1.6 Creating a Live Script
Figure A1.7 Live Editor Tool Strip
Figure A1.8 Live Script Inputs
Figure A1.9 Live Script Options
Figure A1.10 Live Script Two-Column Format
Figure A1.11 Live Script Figure Output
Figure A1.12 Equation Menu
Figure A1.13 Live Script Inserted Equation
Cover
Table of Contents
Begin Reading
C1
iii
iv
v
xiii
xiv
xv
xvi
xvii
xviii
1
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
335
336
337
338
339
340
341
342
343
344
345
346
347
E1
Ed McCarthy
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