File Exchange

image thumbnail

Financial Seminar Demos

version (1020 KB) by Ameya Deoras
Demos commonly used at The MathWorks financial modeling seminars.


Updated 01 Sep 2016

View Version History

View License

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.
Creates an array in MATLAB and shows indexing ability and examples of matrix math

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

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

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

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

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

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

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

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

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

Cite As

Ameya Deoras (2021). Financial Seminar Demos (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (18)

andrea miniagio

edit: my fault

andrea miniagio

no work monte carlo

Pourya Alinezhad

Allison Zhou

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.


great,great resource


Thank you very much!

Giorgio Solfaroli

Thank you very much!
I just have one question:
on the PortVarmc.m file the time vector is set like this by default:
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.

Thanks in advance for your attention.

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


antonis dendis

Roy Chiu

yuanxin ma

convenient use and fast speed

Dimitri Shvorob

Thank you, Brian.

Kuntamukkala Ravi

MATLAB Release Compatibility
Created with R13
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!