5.0

5.0 | 1 rating Rate this file 32 Downloads (last 30 days) File Size: 178.58 KB File ID: #23316
image thumbnail

Volatility Surface

by Rodolphe Sitter

 

17 Mar 2009 (Updated 31 Mar 2009)

Compute and Plot Volatility Surfaces from Market Prices

| Watch this File

File Information
Description

The user inputs:

2 scalars:
- an annualized risk-free rate
- the current price of an underlying asset

3 vectors:
- a vector of time to maturity
- a vector of strike prices
- a vector European call prices gotten from the market for the same underlying asset.

The function VolSurface.m will then:

- compute and output the Black-Scholes implied volatility (this will be a matrix).
- get and plot the corresponding volatility surface using a kernel (Gaussian) density estimation.

Acknowledgements

The author wishes to acknowledge the following in the creation of this submission:
Kernel Smoothing Regression

MATLAB release MATLAB 7.5 (R2007b)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (7)
22 May 2009 derivcraze R S

If I would like to implement this code for a European Put option, do I just have to change the BS formula?

22 May 2009 Rodolphe Sitter

Yes you can just modify the output of the function BlackScholesPricer so that it gives you the put price instead of the call price.
Alternatively you can convert the put prices into call prices using the put-call parity so that you don't have to modify the code.
Hope it helps

13 Jun 2009 Pankaj Kalwani

I get the error message:

??? Error: File: C:\MATLAB6p5\work\VolSurface.m Line: 87 Column: 12
Missing operator, comma, or semicolon.

20 Jun 2009 George Tzallas

Dear Rodolphe,

I can't understand the method you are using in order to calculate the implied volatility, ImpliedVol(i). Why you don't use newton raphson method or bisection method, in order to match the volatility with the option market price coming from the BS formula?

22 Jun 2009 Rodolphe Sitter

Dear George,
I used the fzero command is my code which uses an algorithm originated by T. Dekker: a combination of bisection, secant, and inverse quadratic interpolation methods.
Matlab has the advantage of having a lot of built-in functions like this that you can use to make coding easier. When coding, you don't actually need to write your own algorithms but you should use the available Matlab functions who do the hard work for you.
I hope it answers you question.
thx for the feedback.

23 Jun 2010 Darren

Dear Rodolphe,
In follow up to my previous question: More important than the graph, shouldn't the surface structure return T, M, and IV to Example 1 (once I comment out the graphing issue)? I receive empty matrices.

Output:
Elapsed time is 0.552350 seconds.
>> whos
  Name Size Bytes Class Attributes

  CallPrice 721x1 5768 double
  Maturity 721x1 5768 double
  S0 1x1 8 double
  SPX 723x4 23136 double
  Strike 721x1 5768 double
  r 1x1 8 double
  surface 1x1 636 struct

>> surface

surface =
    hT: NaN
    hM: NaN
     T: [0x2 double]
     M: [0x2 double]
    IV: [1x0 double]

29 Jan 2011 Marc

I like the kernel smoothing part ! thks for sharing

Please login to add a comment or rating.
Updates
31 Mar 2009

-

Tag Activity for this File
Tag Applied By Date/Time
volatility Rodolphe Sitter 17 Mar 2009 15:17:18
surface Rodolphe Sitter 17 Mar 2009 15:17:18
implied volatility Rodolphe Sitter 17 Mar 2009 15:17:18
blackscholes Rodolphe Sitter 17 Mar 2009 15:17:18
black Rodolphe Sitter 17 Mar 2009 15:17:18
scholes Rodolphe Sitter 17 Mar 2009 15:17:18
market Rodolphe Sitter 17 Mar 2009 15:17:18
price Rodolphe Sitter 17 Mar 2009 15:17:18
moneyness Rodolphe Sitter 17 Mar 2009 15:17:18
finance Rodolphe Sitter 17 Mar 2009 15:17:18
implied volatility B R 04 Apr 2009 06:29:25
implied volatility Daniel 21 Aug 2009 10:01:06
black Ali Saad 18 Nov 2009 00:01:45
implied volatility asser Asmussen 12 May 2010 04:52:08
black Daniel 24 May 2010 08:52:16
surface Paul 03 Apr 2011 15:02:20
implied volatility Massimo Pillon 24 Aug 2011 15:57:15
volatility Massimo Pillon 24 Aug 2011 15:57:23
surface ntualex 20 Oct 2011 11:47:05
black alvaro 04 Nov 2011 12:21:19

Contact us at files@mathworks.com