Matematica per l`Economia e la Finanza

Matematica per l’Economia e la Finanza
Part I: Matlab Programming and Optimization Methods in
Portfolio Management.
M. Dolfin
Univ. of Messina - Italy
https://www.marinadolfin.it
UNIME, April 2017
Master in Economia Bancaria e Finanziaria
M. Dolfin - Univ. of Messina - ITALY
Outline
Part I
Matlab programming and optimization methods in portfolio
management.
Part II
Monte Carlo simulations - Option Pricing with Binomial
lattices and Black-Scholes formula
Master in Economia Bancaria e Finanziaria
M. Dolfin - Univ. of Messina - ITALY
Motivation
Given a set of assets in which one can invest his wealth, we
must decide how much should be allocated to each of them,
given some characterization of the uncertainty in asset return.
Asset pricing and portfolio optimization are not necessarily
disjoint topics.
Portfolio optimization is just one part of portfolio management.
We need some formalization.
Master in Economia Bancaria e Finanziaria
M. Dolfin - Univ. of Messina - ITALY
Formalization
Let’s consider two risky assets: i = 1, 2.
r̃i random rate of return.
r̄i expected value.
σi standard deviation.
The inclusion of the second asset may be beneficial in reducing
risk, if its return is negatively correlated with the return of the
first asset.
We are interested in defining the portfolio weights w1 , w2
(w1 + w2 = 1)
If one rules out short-selling wi ≥ 0.
Master in Economia Bancaria e Finanziaria
M. Dolfin - Univ. of Messina - ITALY
Formalization
Portfolio with two risky assets:
Portfolio rate of return r̃ = w1 r̃1 + w2 r̃2
Expected return r̄ = w1 r̄1 + w2 r̄2
Variance σ = Var (w1 r̃1 + w2 r̃2 ) = w12 σ12 + 2w1 w2 σ12 + w22 σ22
Portfolio with n risky assets
r̄ =
n
X
wi r̄i = w0 r̄
i=1
σ2 =
n
X
wi wj σij = w0 Σw,
Σ = [σij ]
i,j=1
Master in Economia Bancaria e Finanziaria
M. Dolfin - Univ. of Messina - ITALY
Portfolio optimization
By choosing the weights wi , get different portfolios with
expected value of return and variance (or standard deviation),
assumed as risk measure.
Any investor wants to maximize the expected return and
minimize variance. Since these two objectives are, in general,
conflicting, we must find a trade off.
Optimal Portfolios
Maximize the return, given the risk.
Minimize the risk, given the return.
Master in Economia Bancaria e Finanziaria
M. Dolfin - Univ. of Messina - ITALY
Optimal portfolios
Minimizes the following expression depending on the risk
tolerance q:
wT Σw − q RT w
w
P
vector of portfolios weights ( i wi = 1).
Σ covariance matrix for the returns on the assets in the
portfolio.
q ∈ [0, ∞]
R
"risk tolerance" factor.
vector of expected returns.
Master in Economia Bancaria e Finanziaria
M. Dolfin - Univ. of Messina - ITALY
Optimal portfolios
No other portfolio exists with a higher expected return but with
the same standar deviation of return.
Efficient frontier
Every possible combination of risky-assets can be plotted on
the risk/expected return plane. The collection of all such
possible portfolios defines a line in this plane.
Master in Economia Bancaria e Finanziaria
M. Dolfin - Univ. of Messina - ITALY
Graphical User Interface (GUI) - optport
Optimize a portfolio of mutual funds.
Six funds are listed in the upper right of the screen, each with a
rate of return and risk.
Select the funds (at least two) and click Generate Frontier to
obtain the efficient frontier.
Master in Economia Bancaria e Finanziaria
M. Dolfin - Univ. of Messina - ITALY
Graphical User Interface (GUI) - optport
Master in Economia Bancaria e Finanziaria
M. Dolfin - Univ. of Messina - ITALY
To calculate the efficient frontier
Expected return vector R
Average expected return for each asset in the portfolio.
Covariance matrix Σ
Square matrix representing the interrelationships between
pairs of assets.
It can be:
directly specified;
estimated from an asset return time series
(see the function ewstats).
Master in Economia Bancaria e Finanziaria
M. Dolfin - Univ. of Messina - ITALY
Mean-Variance portfolio optimization
Portfolio
The symplest syntax to set up a portfolio optimization problem
is
p = Portfolio
It creates a Portfolio object, p such that all object properties are
empty.
Asset mean and covariance
m = [......],
C = [......]
p = Portfolio (0 assetmean0 , m,0 assetcovar 0 , C,0 lowerbudget 0 , 1, ...
0 upperbudget 0 , 1,0 lowerbound 0 , 0);
p.plotFrontier
Master in Economia Bancaria e Finanziaria
M. Dolfin - Univ. of Messina - ITALY
Mean-Variance portfolio optimization - Portfolio
Two risky assets: data
r̄1 = 0.2,
σ12 = 0.2,
Master in Economia Bancaria e Finanziaria
r̄2 = 0.1
σ22 = 0.4,
σ12 = −0.1
M. Dolfin - Univ. of Messina - ITALY
Covariance - corr2cov
One can calculate covariance using:
standard deviation and
correlation.
Transformation of the volatilities of n random processes and the
degrees of correlation between them into a n × n covariance
matrix.
Vector of lenght n with the standard deviations of n given
random processes.
(Optional) n × n correlation coefficient matrix. If not
specified, processes are uncorrelated and it is the identity
matrix.
Master in Economia Bancaria e Finanziaria
M. Dolfin - Univ. of Messina - ITALY
corr2cov - Exercise
Standard deviations
0.5 2.0
Correlations coefficients
1.0 −0.5
−0.5 1.0
Calculate the covariance matrix.
Master in Economia Bancaria e Finanziaria
M. Dolfin - Univ. of Messina - ITALY
Exercise
Plot the efficient frontier (20 portfolios) knowing the expected
returns, the standard deviations and correlation matrix.
returns = 0.1 0.15 0.12
STDs = 0.2 0.25 0.18


1 0.3 0.4
correlations = 0.3 1 0.3
0.4 0.3 1
Master in Economia Bancaria e Finanziaria
M. Dolfin - Univ. of Messina - ITALY
Remark on random sampling
Random sampling is not really possible with a computer, but we
can generate a sequence of pseudo-random numbers using
generators provided by Matlab (or other programming
languages).
The Matlab function rand generates uniformly distributed
random numbers.
We may use other Matlab functions to generate random
numbers distributed using different probability distributions.
Master in Economia Bancaria e Finanziaria
M. Dolfin - Univ. of Messina - ITALY
Randomize Asset weights
Project
Randomly generate a set of 100 portfolios weights adding the
random portfolios to an existing plot for 20 portfolios, for
comparison with the efficient frontier.
Data
returns = 0.1 0.15 0.12
STDs = 0.2 0.25 0.18


1 0.3 0.4
correlations = 0.3 1 0.3
0.4 0.3 1
Master in Economia Bancaria e Finanziaria
M. Dolfin - Univ. of Messina - ITALY
Step 1
Compute the covariances.
Step 2: generate the efficient frontier
Compute and plot the efficient frontier for 20 portfolios using the
built-in function portopt.
Step 3
Randomly generate the asset weights of 100 portfolios
uniformly distributed on the sets of portfolios using a rnadm
number generator with an exponential distribution (exprnd).
Master in Economia Bancaria e Finanziaria
M. Dolfin - Univ. of Messina - ITALY
Step 4
Compute the expected return and risk of each portfolio.
[portrisk , portReturn] = portstats(returns, covariances, weights);
Step 5
Compare Risk-Return results with the efficient frontier.
hold on
plot(portRisk , portReturn,0 r 0 );
title(0 Mean − Variance Efficient Frontier and Random Portfolios0 )
Master in Economia Bancaria e Finanziaria
M. Dolfin - Univ. of Messina - ITALY
Randomize Asset weights
Comparison with the efficient frontier
Efficient Frontier and Random Portfolios
0.16
0.15
Expected Return
0.14
0.13
0.12
0.11
0.1
Master in Economia Bancaria e Finanziaria
0.16
0.17
0.18
0.19
0.2
0.21
0.22
Risk (Standard Deviation)
0.23
0.24
0.25
M. Dolfin - Univ. of Messina - ITALY