Professional Documents
Culture Documents
Portfolio Risk Management Matlab
Portfolio Risk Management Matlab
Portfolio Risk Management Matlab
2
Challenges in Financial Analysis
Financial
Volatile markets Engineer
Quant Group
– Ever-changing needs
Subpar computational
Spreadsheets, Excel
speed, limited data size
In-house development with
Long development time
traditional languages
Inefficiencies in
Combination of the above
Integration & Automation
4
Who uses MATLAB in Financial Services?
5
Agenda
6
Computational Finance Workflow
Financial
Databases Applications
Modeling
Application
Development
Datafeeds Production
Automate
7
Portfolio Optimization
-3
x 10 Efficient Frontier
3.5
2.5
1.5
1
0.005 0.01 0.015 0.02
Standard Deviation of Portfolio Returns
Efficient Frontier
0.35
Mean of Portfolio Returns
0.3
0.25
0.2
0.15
0.1
0.005 0.01 0.015 0.02
Standard Deviation of Portfolio Returns
8
Modeling Market Risk Factor Time Series
9
Market Risk Using Copulas, GARCH & EVT
“Forecasting risk factors”
Need model that captures:
10
Market Risk Using Copulas & Extreme Value Theory
“Asymmetric GARCH using a GJR Model”
R M
yt C i yt i j t j t
AR i 1 j 1 ARMA
P Q
Gi
t
2 2
t i A j t2 j
i 1 j 1
t t zt
zt ~ N (0,1) GARCH ARCH
12
Credit Classification
“Logistic Regression Vs. TreeBagger”
Logistic: [Training Set] Actual Vs Estimated Credit Ratings
CCC 2.00% 0.00% 0.00% 0.00% 0.00% 0.00% 0.00% 15.00%
B 1.43% 3.71% 2.29% 0.00% 0.00% 0.00% 0.00%
BB 0.00% 4.29% 16.29% 5.14% 0.29% 0.00% 0.00% 10.00%
BBB 0.00% 0.00% 3.71% 12.86% 3.71% 0.00% 0.00%
A 0.00% 0.00% 0.00% 1.71% 9.14% 4.00% 0.00%
5.00%
AA 0.00% 0.00% 0.00% 0.00% 2.86% 9.14% 1.14%
AAA 0.00% 0.00% 0.00% 0.00% 0.00% 1.43% 14.86%
0.00%
C
A
BB
AA
B
A
CC
BB
AA
Logistic: [Testing Set] Actual Vs Estimated Credit Ratings
CCC 2.65% 0.39% 0.00% 0.00% 0.00% 0.00% 0.00%
15.00%
B 1.09% 2.40% 1.06% 0.00% 0.00% 0.00% 0.00%
BB 0.00% 5.70% 17.06% 5.42% 0.03% 0.00% 0.00%
10.00%
BBB 0.00% 0.00% 3.07% 14.57% 3.38% 0.00% 0.00%
A 0.00% 0.00% 0.00% 2.21% 10.36% 1.62% 0.00%
5.00%
AA 0.00% 0.00% 0.00% 0.00% 2.18% 10.16% 1.01%
AAA 0.00% 0.00% 0.00% 0.00% 0.00% 1.76% 13.90%
0.00%
C
A
BB
AA
B
A
CC
BB
AA
>> doc mnrfit Popular in classifying the credit quality of instruments is the use of logistic
>> doc mnrval regression. This example illustrates this classification but takes a step
>> doc treebagger further by using a Tree Bagger classifier.
>> doc confusionmat
13
Credit Value Adjustment – Expected loss on portfolio
0.1
0.08
Rates
0.06
0.04
Jan15 300
Jul12 200
Jan10 100
Jul07 Tenor (Months)
Observation Date
[Section 3|EX 1] 14
Evaluate Counterparty Exposures
5000
4000
CVA $
3000
2000
1000
0
1 2 3 4 5
Counterparty
[Section 3 | EX 1] 15
Connect to Data from Various Sources
16
Leverage Built-in Functions to Save Time
Mathematics
Regression (Linear, Non-Linear)
Curve Fitting
Probability Distributions, RNG
Clustering
Multivariate & Factor Analysis
Predictive Modeling, AI
Optimization, Parameter Estimation
Financial Modeling
Portfolio Optimization & Analysis
Derivative Pricing & Hedging
Yield Curve Modeling
Monte Carlo Simulation
Risk Quantification
ARMA/GARCH Analysis
17
Sharing MATLAB Applications
MATLAB
MATLAB MATLAB
Compiler Compiler SDK
MATLAB
MATLAB .exe Excel
Hadoop Production
C/C++ Java .NET
Server
Royalty free
Financial
Databases Applications
Modeling
Report Generator
Production Server
Database Financial
MATLAB Compiler
Application SDK
Datafeed Statistics & Machine
Development Optimization
Datafeeds Learning Production
MATLAB Compiler
Trading
MATLAB
Automate
19
Deploying MATLAB Applications to Excel
3
Toolboxes
1 MATLAB End-User
Desktop Machine
MATLAB Compiler
2
MATLAB
Builder EX
.bas/
.dll .xla
20
Production Deployment Workflow
Development MATLAB Algorithm
Developer
MATLAB
Compiler
CTF
Enterprise
Application Web
Developer Application MATLAB Production Server
Production
MATLAB Production Server
Web
.. Application
.
Client
Library
21
Value of MATLAB Production Server
22
CAMRADATA Models Dependencies for
Quantitative Risk Assessment with
MathWorks Tools
Challenge
Rapidly develop quantitative tools for factor analysis,
risk analysis, and defensive asset allocation Risk-assessment model developed in
MATLAB.
Solution
Use MATLAB to model complex non-linear dependencies
between assets, liabilities, and economic variables using
copulas
Results
Development time reduced by 90 percent “Using MATLAB we can build a
Risk calculated in hours, not weeks model in one morning. It would
Diverse skill sets leveraged
take two weeks to write the
equivalent code in Visual Basic.”
Martyn Dorey
CAMRADATA
23
Capgemini Helps Clients Achieve Basel II
Compliance and Deliver Economic Capital,
Risk, and Valuation Models with MATLAB
Challenge
Enable banking clients to meet Basel II regulatory
guidelines and perform other risk management tasks
Scatterplots showing 500,000 simulations
drawn from bivariate t-copulas with the same
Solution correlation coefficient but differing degrees
Use MATLAB to develop risk management models and of freedom.
24
Intuitive Analytics Uses MATLAB to Build
Quantitative Tools to Help Bond Issuers
Manage Risk
Challenge
Build and market a quantitative tool for reducing Using MATLAB technical computing
software to provide visual representations
expected cost and risk for municipal bond issuers of interest rate models.
Solution
Use MathWorks tools to develop algorithms, visualize
results, and simplify deployment of an advanced
analytical tool
“Because MATLAB enables us to
Results build and distribute applications to
Development productivity increased by 90%
analysts that are accessible from
Deployment simplified
Excel, we are quickly bringing to
Visual environment created
market products that are adopted
and deployed by investment banks.”
Peter Orr
Intuitive Analytics
25
IPD Develops and Deploys Real
Estate Cash Flow Models with
MathWorks Tools 25%
20%
15% '06
10%
5% '07
0%
'08
2
Challenge 4 6 8 10 12 14 16 18
Create cash flow models of real estate investment 0-0.05 0.05-0.1 0.1-0.15 0.15-0.2 0.2-0.25
portfolios and project returns using Monte Carlo MATLAB graph generated to indicate how total returns
simulations from industrial property are likely to behave.
Solution
Use MATLAB and MATLAB Builder NE to develop “The only other approach we
optimization algorithms, build financial models, and seriously considered involved
deploy solutions developing a class library in
Results .NET and C#. Development,
Development time cut by 16 weeks debugging, and testing would
Updates completed in hours have taken us 37 weeks. Using
Deployment simplified MATLAB, we completed the
project in 21 weeks.”
Peter McAnena
Investment Property Databank
Link to user story
26
Nykredit Develops Risk Management and
Portfolio Analysis Applications to Minimize
Operational Risk
Challenge
Nykredit’s tool for calculating and
Enable financial analysts to make rapid, fact-based visualizing risk statistics. The plot
shows portfolio expected tracking
decisions by providing them with direct access to risk error broken out by industry.
management and portfolio analysis information
Solution “Data handling, programming, debugging,
Develop and deploy easy-to-use graphical financial and plotting are much easier in MATLAB,
analysis applications using MATLAB and MATLAB where everything is in one environment.
Compiler For performance calculation GUIs,
Results MATLAB provides a real error-checked
Productivity increased threefold application that makes cool customized
Operational risk mitigated plots for client reports. This has turned a
Analysis time reduced from days to hours several-hour task in a spreadsheet into a
two-minute no-brainer.”
Peter Ahlgren
Nykredit Asset Management
Link to user story
27
Macroeconomic Modeling and Inflation
Rate Forecasting at the Reserve Bank of
New Zealand
Challenge
Support New Zealand monetary policy with a
Sample fancharts produced by RBNZ’s
theoretically well-founded model macroeconomic model.
Solution
Use MATLAB to analyze and forecast macroeconomic
variables, and communicate results to stakeholders
Results
Entire workflow completed in a single environment “With all RBNZ models now
Code shared with other central banks and implemented in MATLAB, the
financial institutions RBNZ has a common platform
Technical rigor of macroeconomic forecasting for evaluating the economy and
increased making informed decisions.”
Jaromir Benes
International Monetary Fund
Link to article
28
Robeco Develops Quantitative Stock
Selection and Portfolio Optimization
Models with MathWorks Tools
Challenge
Develop, distribute, and maintain quantitative
tools for portfolio construction and management
Interest rate paths for the risk analysis of a
Solution savings product.
29
MATLAB Solutions
Challenge Solution
Flexible modeling
Inability to customize
Complete development environment
White-box modeling
Lack of transparency
Viewable-source functions
Quick prototyping
Long development time
Focus on modeling not programming
30
Questions
31