new developments in matlab for computational finance · mixed integer linear programming new solver...

29
1 © 2014 The MathWorks, Inc. New Developments in MATLAB for Computational Finance Kevin Shea, CFA Principal Software Developer MathWorks

Upload: others

Post on 01-Apr-2021

9 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: New Developments in MATLAB for Computational Finance · Mixed Integer Linear Programming New solver (intlinprog) for mixed-integer linear programming (MILP) problems –Continuous

1© 2014 The MathWorks, Inc.

New Developments in MATLAB for

Computational Finance

Kevin Shea, CFA

Principal Software Developer

MathWorks

Page 2: New Developments in MATLAB for Computational Finance · Mixed Integer Linear Programming New solver (intlinprog) for mixed-integer linear programming (MILP) problems –Continuous

2

Who uses MATLAB in Financial Services?

The top 15 asset-

management companies

The top 10 U.S. commercial

banks

11 of the top 15 hedge funds

The reserve banks of all

OECD member countries

The top 3 credit rating

agencies

Page 3: New Developments in MATLAB for Computational Finance · Mixed Integer Linear Programming New solver (intlinprog) for mixed-integer linear programming (MILP) problems –Continuous

3

Financial Modeling Workflow

Financial

Statistics Optimization

Financial Instruments Econometrics

MATLAB

Parallel Computing MATLAB Distributed Computing Server

Files

Databases

Datafeeds

Access

Reporting

Applications

Production

Share

Data Analysis and Visualization

Financial Modeling

Application Development

Research and Quantify

.NET Builder

Excel Builder

Java Builder

MATLAB

Compiler

Rep

ort G

en

era

tor

Pro

du

ctio

n S

erv

er

Datafeed

Database

Spreadsheet Link EX

Trading

Page 4: New Developments in MATLAB for Computational Finance · Mixed Integer Linear Programming New solver (intlinprog) for mixed-integer linear programming (MILP) problems –Continuous

4

Agenda

Files

Databases

Datafeeds

Access

Reporting

Applications

Production

Share

Data Analysis and Visualization

Financial Modeling

Application Development

Research and Quantify

Access

Research and Quantify

– Example: State Space Modeling

– Example: Mixed Integer Linear Programming

Share

– User Story: Developing a New Interest Rate Model

Future Directions

Page 5: New Developments in MATLAB for Computational Finance · Mixed Integer Linear Programming New solver (intlinprog) for mixed-integer linear programming (MILP) problems –Continuous

5

Database Explorer

Create and configure

JDBC and ODBC data

sources.

Import selected data into

the MATLAB workspace.

Save generated SQL

queries.

Generate MATLAB code.

Page 6: New Developments in MATLAB for Computational Finance · Mixed Integer Linear Programming New solver (intlinprog) for mixed-integer linear programming (MILP) problems –Continuous

6

Native ODBC Database Connection

Support for native ODBC database

connection for Windows® platforms.

The native ODBC interface supports the following functions: fetch, exec,

insert.

conn = database.ODBCConnection('dbtoolboxdemo','admin','admin');

Page 7: New Developments in MATLAB for Computational Finance · Mixed Integer Linear Programming New solver (intlinprog) for mixed-integer linear programming (MILP) problems –Continuous

7

Trading Toolbox

Functionality for accessing trade

and quote pricing data, defining

order types, and sending orders to

financial trading markets.

Supports Bloomberg® EMSX,

CQG® Integrated Client,

Interactive Brokers® TWS, and

Trading Technologies®

X_TRADER®.

Page 8: New Developments in MATLAB for Computational Finance · Mixed Integer Linear Programming New solver (intlinprog) for mixed-integer linear programming (MILP) problems –Continuous

8

What’s New in Econometrics

Linear regression models with

ARIMA error processes,

including AR, MA, ARMA, and

seasonal error models with regARIMA.

Estimate robust covariances

for ordinary least squares

coefficients of multiple linear

regression models under

general forms of

heteroscedasticity and autocorrelation using hac.

Page 9: New Developments in MATLAB for Computational Finance · Mixed Integer Linear Programming New solver (intlinprog) for mixed-integer linear programming (MILP) problems –Continuous

9

State-Space Modeling

ssm model for performing univariate and

multivariate time-series data analysis

– Estimate its parameters using estimate

– Implement forward recursion of the

state-space model using filter

– Implement backward recursion of the state-space

model using smooth

– Simulate states and observations using simulate

– Forecast states and observations using forecast

Use the Kalman filter to estimate the states andto manage missing data

Page 10: New Developments in MATLAB for Computational Finance · Mixed Integer Linear Programming New solver (intlinprog) for mixed-integer linear programming (MILP) problems –Continuous

10

Example: Diebold Li Yield Curve Model

𝑦𝑡 𝜏 = 𝐿𝑡 + 𝑆𝑡1 − 𝑒−𝜆𝜏

𝜆𝜏+ 𝐶𝑡

1 − 𝑒−𝜆𝜏

𝜆𝜏− 𝑒−𝜆𝜏

𝐿𝑡: level/long-term factor

𝑆𝑡: slope/short-term factor

𝐶𝑡: curvature/medium-term

𝜆 : time factor

Page 11: New Developments in MATLAB for Computational Finance · Mixed Integer Linear Programming New solver (intlinprog) for mixed-integer linear programming (MILP) problems –Continuous

11

Estimate Diebold Li Parameters

1. Two step process:

1. Fix 𝜆, estimate 𝐿𝑡, 𝑆𝑡 ,𝐶𝑡 at

each date with linear

regression

2. Fit VAR(1) model to 𝐿𝑡 , 𝑆𝑡 ,𝐶𝑡

2. Kalman Filter

Page 12: New Developments in MATLAB for Computational Finance · Mixed Integer Linear Programming New solver (intlinprog) for mixed-integer linear programming (MILP) problems –Continuous

12

What’s New in Financial Instruments

Pricing spread and swing

options using closed form,

finite difference and Monte

Carlo.

Dual curve construction and

pricing of swaps, caps,

floors and swaptions.

Calibration and simulation

of interest rate models (Hull-

White, G2++, LIBOR Market

Model)

Calibration of SABR

stochastic volatility model

Page 13: New Developments in MATLAB for Computational Finance · Mixed Integer Linear Programming New solver (intlinprog) for mixed-integer linear programming (MILP) problems –Continuous

13

Counterparty Credit Risk

Support for computing credit

exposures.

Support for computing various

credit exposure profiles,

including potential future

exposure and expected

exposure.

Compute exposures and CCR

profiles

Page 14: New Developments in MATLAB for Computational Finance · Mixed Integer Linear Programming New solver (intlinprog) for mixed-integer linear programming (MILP) problems –Continuous

14

Parallel Computing for CCR

Tenors

D

a

t

e

s

Instruments

D

a

t

e

s

Interest

Rates Portfolio

Values

parfor dateidx=1:nDates

Values(dateidx,:,:) = swapbyzero(…)

end

Page 15: New Developments in MATLAB for Computational Finance · Mixed Integer Linear Programming New solver (intlinprog) for mixed-integer linear programming (MILP) problems –Continuous

15

Third Party Interfaces

Support for accessing

Numerix® instruments and risk

models.

Support for accessing FinCAD

through the F3 Toolbox for

MATLAB.

Access third party analytics

Page 16: New Developments in MATLAB for Computational Finance · Mixed Integer Linear Programming New solver (intlinprog) for mixed-integer linear programming (MILP) problems –Continuous

16

What’s new in Portfolio Optimization

New portfolio object PortfolioMAD for mean-

absolute deviation (MAD)

portfolio optimization.

New portfolio object PortfolioCVaR for

conditional value at risk (CVaR) portfolio optimization. Loss

# o

f P

ort

foli

o R

etu

rns

95% CVaR

Page 17: New Developments in MATLAB for Computational Finance · Mixed Integer Linear Programming New solver (intlinprog) for mixed-integer linear programming (MILP) problems –Continuous

17

Mixed Integer Linear Programming

New solver (intlinprog) for mixed-integer

linear programming (MILP) problems

– Continuous and integer variables (Mixed Integer)

– Linear objective and constraints (Linear Programming)

𝑥1 ∈ 0, 100 𝑥2 ∈ {1,2,3,4,5}

min𝑥

−𝑥1 − 2𝑥2

𝑥1 + 4𝑥2 ≤ 20𝑥1 + 𝑥2 = 10

such that

Page 18: New Developments in MATLAB for Computational Finance · Mixed Integer Linear Programming New solver (intlinprog) for mixed-integer linear programming (MILP) problems –Continuous

18

Example: Cash-flow matching

Idea: Buy bonds to cover pension

fund obligations

Variables: How many of each

bond to buy?

Constraints: Payments from

bonds must be greater than or

equal to pension fund obligations

Objective: Minimize the size of

the investment you make 1 2 3 4 5 6 7 80

20

40

60

80

100

120

Time Period

Ca

sh

Flo

w (

$)

1 2 3 4 5 6 7 80

5

10

15x 10

5

Time Period

Pa

ym

en

ts (

$)

Page 19: New Developments in MATLAB for Computational Finance · Mixed Integer Linear Programming New solver (intlinprog) for mixed-integer linear programming (MILP) problems –Continuous

19

MATLAB Production Server™

Directly deploy MATLAB programs into production

– Centrally manage multiple MATLAB programs and runtime versions

– Automatically deploy updates without server restarts

Scalable and reliable

– Service large numbers of concurrent requests

– Add capacity or redundancy with additional servers

Use with web, database and application servers

– Lightweight client library isolates MATLAB processing

– Access MATLAB programs using native data types

MATLAB Production Server(s)

HTML

XML

Java ScriptWeb

Server(s)

Page 20: New Developments in MATLAB for Computational Finance · Mixed Integer Linear Programming New solver (intlinprog) for mixed-integer linear programming (MILP) problems –Continuous

20

What is MATLAB Production Server?

Enterprise framework for running packaged MATLAB programs

Server software

– Manages packaged MATLAB programs & worker pool

Runtime libraries

– MATLAB Compiler Runtime (MCR)

Lightweight client library (.NET & Java)

– Request MATLAB programs (functions)

.NET

MATLAB Production Server

Request

Broker

&

Program

Manager

Page 21: New Developments in MATLAB for Computational Finance · Mixed Integer Linear Programming New solver (intlinprog) for mixed-integer linear programming (MILP) problems –Continuous

21

Integrating with IT systems

Web

Server

Application

Server

Database Server

Pricing

Risk

Analytics

Portfolio

Optimization

MATLAB Production Server

MATLAB

Compiler™

Web

Applications

Desktop

Applications

Excel®

Page 22: New Developments in MATLAB for Computational Finance · Mixed Integer Linear Programming New solver (intlinprog) for mixed-integer linear programming (MILP) problems –Continuous

22

Developing a New Interest Rate Model

Challenge

Develop a new interest rate

model based on work by

Deguillaume, Rebonato and

Pogudin (2013).

Deguillaume, N., Rebonato, R., & Pogudin, A. (2013). The nature of the dependence of the magnitude

of rate moves on the rates levels: a universal relationship. Quantitative Finance, 13(3), 351-367.

Page 23: New Developments in MATLAB for Computational Finance · Mixed Integer Linear Programming New solver (intlinprog) for mixed-integer linear programming (MILP) problems –Continuous

23

Developing a New Interest Rate Model

SolutionThe model was developed in

MATLAB and can be

calibrated to multiple

currencies and markets.

DeploymentThe model was then

deployed to customers via

the SmartModels Excel Add-

In interface.

Deguillaume, N., Rebonato, R., & Pogudin, A. (2013). The nature of the dependence of the magnitude

of rate moves on the rates levels: a universal relationship. Quantitative Finance, 13(3), 351-367.

Page 24: New Developments in MATLAB for Computational Finance · Mixed Integer Linear Programming New solver (intlinprog) for mixed-integer linear programming (MILP) problems –Continuous

24

Future Directions

Page 25: New Developments in MATLAB for Computational Finance · Mixed Integer Linear Programming New solver (intlinprog) for mixed-integer linear programming (MILP) problems –Continuous

25

Graphics

Page 26: New Developments in MATLAB for Computational Finance · Mixed Integer Linear Programming New solver (intlinprog) for mixed-integer linear programming (MILP) problems –Continuous

26

Big Data

Page 27: New Developments in MATLAB for Computational Finance · Mixed Integer Linear Programming New solver (intlinprog) for mixed-integer linear programming (MILP) problems –Continuous

27

Page 28: New Developments in MATLAB for Computational Finance · Mixed Integer Linear Programming New solver (intlinprog) for mixed-integer linear programming (MILP) problems –Continuous

28

MATLAB Online

Page 29: New Developments in MATLAB for Computational Finance · Mixed Integer Linear Programming New solver (intlinprog) for mixed-integer linear programming (MILP) problems –Continuous

29