0% found this document useful (0 votes)
153 views71 pages

Using MATLAB To Develop and Deploy Financial Models

Uploaded by

Daefnate Khan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
153 views71 pages

Using MATLAB To Develop and Deploy Financial Models

Uploaded by

Daefnate Khan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 71

Using MATLAB to Develop

and Deploy Financial


Models

© 2005 The MathWorks, Inc.


Financial Products Group

Allen Schweitzer Account Manager


Kas Sharma Applications Engineer
Rob Quinn Technical Marketing
Topics
 Introduction
 Application Examples
 Overview of MATLAB
 Data I/O
 Data Analysis
 Modeling
 Break
 Algorithm Deployment and Reporting
 Distributed Computing
 Wrap up

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

 Revenues of ~$300M in 2004


 Privately held
 Over 1000 employees worldwide,
1 /3
in product development
 Worldwide revenue balance:
50% North America, 50% International
 More than 1,000,000 users
in 175+ countries

1985 1990 1995 2000

4
Business Challenges

 Development time

 Computational speed

 Deployment time

Lost opportunity or added risk

5
Customer Quote

"MathWork's products have saved us significant


time in developing our return forecast models.
MATLAB, coupled with the deployment
capabilities available, enables us to distribute
sophisticated models to portfolio managers and
researchers much quicker than we could have
with other solutions.“
Eric Kisslinger
Barclays Global Investors

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

High speed data analysis and


trading application
• Custom Reuters datafeed
• Read and analyze data
• Estimate risks
• Execute trades

ROI
Developed for 20% of their
expected cost in only 3 months.

10
Data Analysis Applications
Economic charting system for a major insurance company

• Macro economic trending tool for


economists

• Read data from a databases

• Filter using custom user interface

• Report using either Microsoft


Excel or Word

11
Energy Trading Applications
Analysis and reporting tool for energy trading companies

• Customized database access routines


• Extensive use of object oriented programming
• Hierarchical structure for books, deals, derivatives, etc…
• Distribution of nightly position reports to senior management via their
intranet.
• Display of market
curves, sensitivities,
etc…

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

Final application provided:


• Asset and group constraints.
• Statistic calculation against
benchmarks
• Reporting back to Excel
• Extensibility

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

 Application to analyse large volumes of data to determine daily


trading strategies
 Implement new strategies
 Link to Excel
 Link to trading platform

ROI

 Reduce model execution time from 10 hour to 2.5 minutes


 Analyze 500 stocks, up from 150
 Increase trading volume from £30milllion to £120milllion
 Pilot study, using Consulting Services and implemented in 3 days,
paid for itself in 2 trading days.

15
Overview of MATLAB and Toolboxes

© 2005 The MathWorks, Inc.


Typical Process Flow
Financial
Financial Reports
Reports
Modeling
Modeling
Data

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

• Fast computational engine

• Work with various data sources

• Integrate with other programs


- Excel,VB, & C/C++

19
Data I/O Overview

 Data importing functions

 Support for ODBC and JDBC


compliant database

 Interface with data providers

 Many Interfaces to Excel

20
Core MATLAB Data I/O functionality

 Save and load command


 Low-level file I/O functions
 COM/ActiveX
 DDE function
 textscan
 xlsread

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

 GUI Tool (DFTOOL)

 Need connection/license
22
Database Connections

 ODBC or JDBC compliant database


 ODBC and JDBC on PC
 JDBC on UNIX

 Data types are preserved

 Retrieval of large/partial data sets

 Access multiple connections (same or different DB)

 Database connections remain open

23
Database Connections

Visual Query Builder


 Access data without knowing SQL
 Scroll through tables and fields
 Customize your query using Where/Group

 Built-in visualization tools


 Plotting and charting
 Creating HMTL reports
 Handling date strings

 Reuse SQL statements in your own program

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

 Fixed Income Analysis


 Interest rate curves

 Volatility modeling

 Monte Carlo Simulations


 Value at Risk (VaR)
 Credit Risk

 Technical Analysis
28
Faster Simulation Times

Spread Sheet Applications

 MATLAB Excel Link can be the


computational engine
behind your Excel applications

 Faster scalable solution

Collective Risk Model


4.6 Seconds v.s 204.2 Seconds
29
Why MATLAB?
 Quick Prototyping environment
 Less Programming
 Matrix Based
 Easy Syntax (no overhead)
 1000’s Math & Graphics

 Fast computational engine

 Work with various data sources

 Integrate with other programs


 Excel,VB, & C/C++

30
Break

31
Application Deployment

© 2005 The MathWorks, Inc.


Model Development Process
Investment
Professionals:
Analysts, Traders,
Port folio Managers
Analytic
Academic Quantitative Prototyping and Finance
Research Research Application Professionals:
Development Accountants,
Financial Analysts
Actuaries
Analytic
Prototyping

Strength Weakness

Excel  Ease of use  Limited functionality


Excel, C/C++,VB  Deployment

Application  Functionality  Learning curve


Specific Software  Deployment
33
MATLAB Prototype to Production

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

Traditional prototype to production system port


… development timeline : 2 weeks ~ 6+ months

MATLAB prototype to production system


… single command at the command line

34
The MATLAB Compiler

Deploy as a
Your standalone
MATLAB
App

Integrate into other


Your
environments
MATLAB
Functions

• Works with C/C++ compilers (Microsoft Visual Studio)


• Creates executables, components, or libraries
• Supports the entire MATLAB language (OOP’s, JAVA, EVAL, ActiveX)
• Deploy applications at no cost
35
The Distributed MATLAB Application
• MATLAB Compiler command issued at the command prompt
creates an executable, COM, or Lib

• Create a stand-alone executable


mcc -m yourapp.m

• Integrate with other applications (.dlls, .so, etc)


mcc -W lib:libfunction -T link:lib
yourfunc1.m, yourfunc2.m

• MATLAB does not need to be available on the target user’s


desktop

• Generated binary, CTF, and MCR can be packaged and freely


distributed to the target user’s desktop

36
Compiler architecture … 3 Components

1. Executable, Component or EXE, COM, or Lib


Library
Components
built by the
2. Component Technology File compiler
(CTF) (usually 300KB)
• CTF file contains all supporting m
files, mex files, java files, MAT CTF
files, etc. that are needed to allow Archive
application to run.

• Enables customers to protect their


IP due to new encryption model
used in building the CTF archive.

3. MATLAB Component Runtime Deployed


MathWorks
(MCR) supplied MCR
once onto
the desktop
(100 MEG)
37
A Stand-alone Example
MATLAB Editor/GUI Builder Stand-alone application

>> mcc -m rwalk2a.m

38
Integration With Other Environments

 MATLAB Compiler generated shared libraries (lib and


DLL’s) may be integrated with…

- 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

MATLAB Builder for COM enables the


development and distribution of Web-
based MATLAB applications via ASP.

Apache/IIS

42
Deploying with MATLAB

COM Excel
C/C++
C/C++ Shared Objects

Stand-alone
Stand- Web

43
Reporting

© 2005 The MathWorks, Inc.


• Documents for compliance and model verification

• Generating custom daily/nightly reports


Compliance and Model Verification

 Documentation of code
 Display code and comments
 Headings, links, and fonts
 Graphics
 Multi –output formats
 HTML, XML, Word, LaTex, PowerPoint

 Create dependency reports


 Understand parent/child relationships

 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

 Multiple output formats


 HTML
 XML
 RTF

46
Distributed Computing

© 2005 The MathWorks, Inc.


Applications for Distributed Computing

Address the need to solve computationally


intensive problems:
 Enhance productivity
 Improve performance

Examples: (Monte Carlo simulations)


 Risk management simulations
 Derivatives pricing simulations
 Portfolio optimization problems

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

 Access to single or multiple clusters by single or multiple


users
 Distributed processing on both homogeneous and
heterogeneous platforms
 Support for both synchronous and asynchronous operations
 Control of the distributed computing process via a function-
based or object-based interface

52
Demonstration

Toolbox Engine

Network

 Client interface  Job manager


 Job creation  2 Worker
 Graphics display

• Functional interface
• Object interface
• Single CPU
• Multi-CPU
53
Portfolio Optimization (non-distributed)

54
Portfolio Optimization (distributed)

3 Workers

55
Distributed Computing Tools Summary

 Execute independent MATLAB


algorithms models in a
computer cluster
 Performance improvement
 Enhanced productivity

 This is the first release of a


milestone product
 Supports coarse-grained
applications

 Trial versions are now


available!

56
Wrap Up

© 2005 The MathWorks, Inc.


MATLAB for Business Applications
Business Tools on the Desktop MATLAB Tools

- Excel - Excel Link & Data Import Tool


- Word - Publisher, copy figure
- Browsers - Publisher and Report
Generator

- Live Market Data - Datafeed Toolbox

- Databases - Database Toolbox


• Oracle • ODBC & JDBC
• Microsoft Access • …
• Microsoft SQL
Server
• Sybase SQL Server
• ….
58
Benefits of MATLAB

• Interactive environment

• An extensive library of viewable code that can be used


“as is” or modified to incorporate business models

• Matrix based — handle and manipulate large data sets

• First rate graphics engine

• A considerably shorter application development


process resulting in rapid delivery of model to the end
user desktop

59
The MATLAB Advantage

• Develop models faster

• Run large scale simulations

• Reduces the costs of model integration

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

 Engineering expertise and deep product knowledge,


specializing in:
 Application development using MATLAB
 Model-based design using Simulink and Stateflow
 Embedded-system development
 Enterprise-wide integration of MathWorks products into engineering
process and systems
 Jumpstart services

 Project-based services for a growing number of industries,


including Aerospace and Defense, Automotive,
Communications, Power and Marine, and Financial
Services

www.mathworks.com/consulting 65
Traini ng fro m The Mat hWorks

Three ways to get training

 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

File exchange and newsgroup access for MATLAB and


Simulink users

 130,000 visits per month


 Over 2,800 files in the exchange
 General-purpose functions,
industry- and application-specific tools and examples
 100 new submissions per month
 5,000 downloads per day
 5,000 posts to “CSSM” (comp.soft-sys.matlab) per month, 60%
routed through MATLAB Central

www.mathworks.com/matlabcentral 67
The MathWorks Connections Program

Over 300 add-on products and services from partners that


complement and extend MathWorks products

 Specialized third-party toolboxes for MATLAB


 Interfaces to partners’ software and hardware products
 Specialized training courses and consulting services
 System integrators and suppliers that incorporate
MathWorks products

68
The MathW orks Book Progra m

www.mathworks.com/books

750+ textbooks for educational and professional use, in 20


languages
 An Introduction to Market Risk Measurement
 Applied Computational Economic and Finance
 Pricing Derivatives Securities
 Black Scholes and Beyond

69
Technical Support

• Technical Support
- 90% of problems solved in 24 hours
- 60+ Application Engineers on staff, ½ with
Masters Degrees

• World Wide Web


(www.mathworks.com)
- 24x7 self-service technical support
- over 9,000 technical solutions

- software archive (ftp.mathworks.com)


- MATLAB Digest – electronic newsletter

• 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

• Company and product information:


www.mathworks.com

71

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy