File Exchange

Financial Seminar Demos

version 1.2.0.1 (1020 KB) by

Demos commonly used at The MathWorks financial modeling seminars.

Updated

Ten demos, most of which are shown at The MathWork's financial modeling seminars. All of the demos are in their own folders, which contain the code, and a ReadMe file that explains what the demos do and gives directions on how to run it. The ReadMe also mentions which Toolboxes are needed for each demo. To run all of the demos, you'll need the Toolboxes listed in the required list. However, not all of the demos require all of the Toolboxes.
MLTutorial:
Creates an array in MATLAB and shows indexing ability and examples of matrix math

DFDBportOpt:
GUI that inputs data from database or Yahoo(Datafeed) and finds the efficient frontier

BLSVIS:
Plots a 3d visualization of option sensitivities ? Delta and Gamma

GarchFXdemo:
GARCH demo showing time-series, simulation, optimization, and graphics abilities of MATLAB.

OpriceAnimation:
Animates option prices, gamma, and volatility in 3D as time to maturity changes

Xlderiv:
Illustrates how to price an fixed-income instrument portfolio using the Heath-Jarrow-Morton and Black-Derman-Toy interest rate models

SpotCurveFit:
Computes and compares spot and forward curves calculated from bootstrapping and spline fitting methods

OptVar:
Calculates the Value at Risk (VaR) of a portfolio of equity options using the delta-gamma

method.PortVaRmc:
Calculates the Value at Risk (VaR) of a portfolio of equities using Monte Carlo simulation

PortVaRreturns:
Calculates the Value at Risk (VaR) of a portfolio of equities using historical return data

andrea miniagio

edit: my fault

andrea miniagio

andrea miniagio (view profile)

no work monte carlo

Allison Zhou

Allison Zhou (view profile)

Great sample files. I think there is an error in the Monte Carlo simulation though. If my understanding is correct, time=0:20 is the number of steps in each simulation. As such, we need to adjust the drifts and std's by it. So in the montecarlo.m file,

drifts = mRet.*dt/(tLen-1);
stds = valat.*sqrt(dt/(tLen-1));

Otherwise we are not projecting one-day returns.

Grace

Grace (view profile)

great,great resource

?

? (view profile)

Thank you very much!

Giorgio Solfaroli

Giorgio Solfaroli (view profile)

Thank you very much!
I just have one question:
on the PortVarmc.m file the time vector is set like this by default:
time=0:20;
exactly, what does it means?

I have a 74 daily observation time series, how do i have to change it?

Sorry to seem dumb but i'm just new to MatLab.

Marcelo Perlin

I forgot to take the square..

The right equation is:

Port_std=sqrt( E[x_t - E(x_t)]^2 )

Simplifying this formula will show the covariance part..

Marcelo Perlin

faezeh raei is right.

At line 86 of PortVarMC.m the standard deviation is not taking into account the existence of correlation between the assets.

If you're simulating uncorrelated assets, then no problem, but since you used Cholesky factorization for the creation of random correlated returns, then the equation doesn't hold.

The right equation is:

Port_std=E[x_t - E(x_t)]^2

where x_t is the portfolio return in time t (calculated using the weights) and E() is the expectation operator.

Since you're dealing with 9 assets, the equation is very big so i'm not going to post it here. A better way of calculating the std would be to build the portfolio return trough time and then just take the std of such vector.

Also, I don't get it for you to be using uigetfile() when you have next the line range='a1:j789' , meaning that the algorithm will only work properly for that particular file at the example (equity.xls).

Why not change the function for a excel file of any range ??

faezeh raei

I think there is an error in PortVaRmc.m
At the end, for computation of VAR, standard deviation of whole portfolio is considered to be weighted sum of std of return of its constituent assets. However the constituent assets are correlated and their covariances should be included in std of portfolio as well.

Sophia Zhao

gregorio vargas

esto es una maravilla

Trung Nguyen

user

antonis dendis

Roy Chiu

yuanxin ma

convenient use and fast speed

Dimitri Shvorob

Thank you, Brian.

Kuntamukkala Ravi

MATLAB 6.5 (R13)