Using MATLAB To Develop and Deploy Financial Models
Using MATLAB To Develop and Deploy Financial Models
2
The MathWorks at a Glance
Headquarters:
Natick, Massachusetts USA
USA:
California, Michigan,
Washington DC, Texas
Europe:
UK, France, Germany,
Switzerland, Italy,
Spain, Benelux, Nordic
Asia-Pacific:
Korea Earth’s topography on an
equidistant cylindrical projection,
Worldwide training created with the MATLAB Mapping
and consulting Toolbox
Distributors in 20 countries
3
The MathWorks Today
4
Business Challenges
Development time
Computational speed
Deployment time
5
Customer Quote
6
Customer Quote
“MATLAB can reduce programming time by about
75 percent. In some cases it would be weeks
before we could run the calculations in C++.”
“MATLAB is virtually the only program that can
handle the large-scale problems that we model. It
is a powerful tool that provides a very flexible
Environment in which to build models rapidly.”
Alexander Eydeland
Mirant
7
Customer Quote
By using MATLAB as the computation engine
for our Excel models, we have been able to
significantly improve the accuracy of our
simulations and reduce computing time by up to 95%.
Don Mango
American Reinsurance
8
Customer Quote
“We found the development cycle in MATLAB to
be 10 times shorter than in C++, dramatically
reducing project costs without any significant
penalties to computation speed.”
Zaf Bhuia
Credit Suisse First Boston
9
Trading Application
A statistical arbitrage trading system for a London hedge fund
ROI
Developed for 20% of their
expected cost in only 3 months.
10
Data Analysis Applications
Economic charting system for a major insurance company
11
Energy Trading Applications
Analysis and reporting tool for energy trading companies
12
Asset allocation Application
Analysis tool for Privately managed investment company
An environment for detailed analysis of their holdings.
Analysis includes:
• Visualizing efficient frontiers
• Monte-Carlo simulation
• Performance reporting
13
Re-Insurance Application
Pricing and risk tool for major re-insurance company
Used Excel as front end user interface
Needed access to several databases
Analysis includes:
• Statistical routines
• Monte-Carlo simulations
• Cash flows
ROI
Calculation time reduced from
2 hours to 3 minutes
Won $130M order due to quick
response time
14
Securities Trading Application
Analysis and development tool for major investment banking
ROI
15
Overview of MATLAB and Toolboxes
Data
Data
Analysis Deploy
Deploy
Analysis &&
Visualization Applications
Applications
Visualization
Derivatives
Financial
Fin Time
GARCH
Income
Series
Fixed-
For Excel
for COM
Builder
Builder
Generator
Excel Link
Database
Report
Datafeed
Financial
MATLAB
Statistics Optimization Compiler
MATLAB
17
The Power of MATLAB
MATLAB is both
A Computational Environment:
Financial professional develop complex financial models
using MATLAB and its family of toolboxes
and
An Application Development Environment:
Models developed in MATLAB by financial professionals are
translated into components using the MATLAB Compiler and
distributed as stand-alone applications or quickly integrated
into new or existing legacy applications by Information
Technology Engineers
18
Why MATLAB?
• Quick Prototyping environment
- Less Programming
- Matrix Based
- Easy Syntax (no overhead)
- 1000’s Math & Graphics
19
Data I/O Overview
20
Core MATLAB Data I/O functionality
Save options
• 8-digit or 16-digit ASCII format
• Delimits with tabs or spaces
• Text data (ASCII)
• Binary data (MAT-file)
21
Connections to Data Providers
Supported connections:
Bloomberg, FactSet,
Financial Times Interactive Data (IDC)
Yahoo, and Hyperfeed
Potential connections
Reuters and Datastream
Need connection/license
22
Database Connections
23
Database Connections
24
Data Analysis in MATLAB (library of functions)
Statistics
analyzing historical data, modeling data,
simulating systems, and developing statistical
algorithms.
Curve Fitting
routines for preprocessing data, as well as
creating, comparing, analyzing, and managing
models.
Optimization
proven algorithms for general and large-scale
optimization
linear programming, quadratic programming,
nonlinear least-squares, and nonlinear equations.
Genetic algorithm tools with numerous options for
creation, fitness scaling, selection, crossover, and
mutation
Signal Processing, Neural Networks, Wavelets ..
25
Complete Development Environment
• MATLAB Editor/Debugger
- Capture work from history
- Color coded
- Break points
• Performance Tools
• Profiler
• M-Lint
• GUI Builder
• Drag and drop graphical user
interface
• Multi-platform Support
– Windows, Unix, Linux, & Mac
26
Financial Modeling with MATLAB (library of functions)
Financial
perform portfolio optimizations, risk analyses,
asset allocations, fixed income pricing, and much
more
Fixed Income
determine the price, yield, and cash flows for many
types of fixed-income securities including
mortgage-backed
Financial Derivatives
analyzing and modeling equity and fixed-income
derivatives and securities contingent on interest
rates
GARCH
perform Monte Carlo simulation of univariate
returns, perform pre- and post-estimation
diagnostic and hypothesis testing, estimate
parameters of general ARMAX/GARCH models
27
Examples
Option modeling
Volatility modeling
Technical Analysis
28
Faster Simulation Times
30
Break
31
Application Deployment
Strength Weakness
Requests
Investment
Professionals:
Analysts, Traders,
Analytic Port folio
Academic Quantitative Prototyping and Managers.
Research Research Application Finance
Development Professionals:
Accountants,
Financial Analysts,
MATLAB Analytic Actuaries
Prototyping
34
The MATLAB Compiler
Deploy as a
Your standalone
MATLAB
App
36
Compiler architecture … 3 Components
38
Integration With Other Environments
- C/C++
- Visual Basic
- Excel
39
MATLAB Builder for Excel
VBA wrapper &
.dll file
MATLAB Builder for Excel
works with the MATLAB
Compiler to generate stand-
alone Excel add-ins from
MATLAB algorithms.
40
MATLAB Builder for COM
MATLAB Builder for COM works with the MATLAB Compiler to
automatically generate COM wrappers for MATLAB algorithms.
41
Web Deployment with MATLAB Builder for COM
Apache/IIS
42
Deploying with MATLAB
COM Excel
C/C++
C/C++ Shared Objects
Stand-alone
Stand- Web
43
Reporting
Documentation of code
Display code and comments
Headings, links, and fonts
Graphics
Multi –output formats
HTML, XML, Word, LaTex, PowerPoint
Performance reports
Recommendations for improvements
Check unused variables
45
Custom Report Generation
Template
Create based report design
Develop report outline
Reusable templates
Scripting features
Chapters
Text, tables, links, graphs, code, etc
46
Distributed Computing
48
Coarse-grained Distributed Computing
Task
CPU1
Result
Job Task
MATLAB
Client CPU2
Toolboxes machine Result
Result Job Task
Manager
CPU3
Result
Task
CPU4
Result
49
Coarse-grained Distributed Computing Solution
Functionality :
• Queue Jobs MATLAB Distributed
• Dynamically license workers Computing Engine
Task
Client Worker
CPU1
Result
Job Task
MATLAB Distributed
Worker
CPU2
Computing
Toolboxes Result
Toolbox Result Job
Task
Manager
Worker
CPU3
Result
Functionality: Task
• Create Jobs Worker
CPU4
• Create Tasks Result
• Pass data
• Retrieve results
50
Dynamic Licensing
MATLAB Distributed
Computing Engine
Client 1 Stats
Optim
MATLAB
Job
Statistics Distributed Task
Computing Worker
Stats
Wavelets
Optimization Optim
Toolbox Result
Result
Job Task
Manager Stats
Wavelets
Worker Optim
Client 2 Result
Wavelets
MATLAB Task
Job
Wavelets Distributed Worker
Stats
Wavelets
Optim
Computing
Result
Neural Network Toolbox Result
51
Key Features
Dynamic licensing
Engine is the only product required in the cluster
Eliminates the need to buy multiple toolboxes licenses for worker
nodes
52
Demonstration
Toolbox Engine
Network
• Functional interface
• Object interface
• Single CPU
• Multi-CPU
53
Portfolio Optimization (non-distributed)
54
Portfolio Optimization (distributed)
3 Workers
55
Distributed Computing Tools Summary
56
Wrap Up
• Interactive environment
59
The MATLAB Advantage
60
Representative Customers
• Federal Reserve Bank • Putnam Investments
• Goldman Sachs • Prudential Securities
• J.P. Morgan Chase • Bank of America
• State Street • Freddie Mac
• Salomon Smith Barney • Fannie Mae
• Merrill Lynch • Moody’s Investors
• Ernst & Young • Scudder Investment
• Deloitte & Touche • Price Waterhouse
• Lehman Brothers Coopers
61
Insurance and Energy Trading Companies
• Allstate Insurance • Williams Energy
• American RE • Reliant Energy
• AXA • TXU
• Element RE • Mirant
• John Hancock • ExxonMobil
• Kemper RE • Entergy Koch
• Liberty Mutual • Constellation Power
• New York Life Source
• Zurich RE • Sempra Energy
• Allegheny Energy
• Dominion Energy
62
Representative U.K. & US Business
Schools
• Judge Institute, University of Cambridge
• Cornell University, Johnson School of Business
• Sloan School (MIT)
• Carnegie Mellon University
• London Business School
• Harvard Business School
• Imperial College, Centre for Quantitative Finance
• Warwick Business School
• University of California at Berkeley
• University of Chicago, GSB
• Cass Business School
63
Support and Community
64
Consulting from The Ma thWorks
www.mathworks.com/consulting 65
Traini ng fro m The Mat hWorks
Public Training
Offered throughout the world
Schedule and course information at
http://www.mathworks.com/training
On-Site Training
Bring training to your site, with course customization
available
Web-Based Training
Instructor-led e-learning
Train at work or at home, with flexible dates and times
www.mathworks.com/training 66
MA TLAB Central
www.mathworks.com/matlabcentral 67
The MathWorks Connections Program
68
The MathW orks Book Progra m
www.mathworks.com/books
69
Technical Support
• Technical Support
- 90% of problems solved in 24 hours
- 60+ Application Engineers on staff, ½ with
Masters Degrees
• Newsgroup (comp.soft-sys.matlab)
70
Further information
• Stay for questions
• Visit MATLAB Central for some
of the tools you’ve seen today
• Trials, onsite demonstrations,
technical literature:
John.Cunningham@mathworks.com
508.647.7122 or visit:
http://www.mathworks.com/products/i
ndustry/finance
71