Option pricing in MATLAB
MATLAB’s built-in finance toolbox allows one to quickly and easily calculate the price of options using a variety of models. Here, we’ll focus on pricing a call option for Apple using the Roll-Geske-Whaley model.
Simple option problem: Apple, Inc
Calculate the price of a call option in Apple (AAPL) assuming the following parameters:
Exercise price of $600 on August 15, 2012
Expiration on December 15, 2012
Dividend of $15 on November 15, 2012
AAPL is trading at $581 today
Volatility of ~30% and risk free rate of 5% per annum.
MATLAB code
AssetPrice = 581;
Settle = ‘Aug-15-2012′;
Maturity = ‘Dec-15-2012′;
Strike = 600;
Rate = 0.05;
Sigma = 0.3;
DivAmount = 15;
DivDate = ‘Nov-15-2012′;StockSpec = stockspec(Sigma, AssetPrice, {‘cash’}, DivAmount, DivDate);
RateSpec = intenvset(‘ValuationDate’, Settle, ‘StartDates’, Settle, ‘EndDates’, Maturity, ‘Rates’, Rate, ‘Compounding’, -1, ‘Basis’, 1);OutSpec = {‘Price’, ‘Delta’, ‘Gamma’};
[Price, Delta, Gamma] = optstocksensbyrgw(RateSpec, StockSpec, Settle, Maturity, Strike,’OutSpec’, OutSpec)
Output
The output of the code gives:
Price =
31.4799
Delta =0.4784
Gamma =0.0043
so, the option would cost $31.48. Simple enough.



