Quantitative Finance Collector is a blog on Quantitative finance analysis, methods in mathematical finance focusing on derivative pricing, quantitative trading and quantitative risk management.
Oct
6
Crank-Nicolson for a European put was introduced before, to better master this technique, i share another sample code using Crank-Nicholson finite difference for American option.
BLSPRICEFDAM Black-Scholes put and call pricing for American Options using the Crank-Nicholson finite difference solution of Black-Scholes Partial differential equation. Note that this function returns an approximate solution unlike the analytical solution (BLSPRICE)
SO is the current asset price, X is the exercise price, R is the risk-free interest rate, T is the time to maturity of the option in years, SIG is the standard deviation of the annualized continuously compounded rate of return of the asset (also known as volatility), and Q is the dividend rate of the asset. The default Q is 0. N denotes the number of discretization points in the stock price domain, and M denotes the number of discretization points in time domain used for the PDE solution.Try increasing either of M or N to achieve greater efficiency.
lecture notes can be downloaded at http://www.cs.cornell.edu/Info/Courses/Spring-98/CS522/home.html and matlab file http://www.cs.cornell.edu/Info/Courses/Spring-98/CS522/content/blspricefdam.m.
BLSPRICEFDAM Black-Scholes put and call pricing for American Options using the Crank-Nicholson finite difference solution of Black-Scholes Partial differential equation. Note that this function returns an approximate solution unlike the analytical solution (BLSPRICE)
SO is the current asset price, X is the exercise price, R is the risk-free interest rate, T is the time to maturity of the option in years, SIG is the standard deviation of the annualized continuously compounded rate of return of the asset (also known as volatility), and Q is the dividend rate of the asset. The default Q is 0. N denotes the number of discretization points in the stock price domain, and M denotes the number of discretization points in time domain used for the PDE solution.Try increasing either of M or N to achieve greater efficiency.
lecture notes can be downloaded at http://www.cs.cornell.edu/Info/Courses/Spring-98/CS522/home.html and matlab file http://www.cs.cornell.edu/Info/Courses/Spring-98/CS522/content/blspricefdam.m.
Oct
3
Another sample code of the book An Introduction to Financial Option Valuation: Mathematics, Stochastics and Computation, read Crank-Nicolson for put. This sample calculates a up-and-out call barrier option via Monte Carlo simulation with antithetic variates.
An up and out call is a regular call option that ceases to exist if the asset price reaches a barrier level, H, that is higher than the current asset price, when H is less than or equal to K, the value of the up and out call is zero.
Code can be accessed here http://www.maths.strath.ac.uk/~aas96106/ch21.m.
An up and out call is a regular call option that ceases to exist if the asset price reaches a barrier level, H, that is higher than the current asset price, when H is less than or equal to K, the value of the up and out call is zero.
Code can be accessed here http://www.maths.strath.ac.uk/~aas96106/ch21.m.
Sep
28
Asian options are securities with payoff which depends on the average of the underlying stock price over certain time interval. Since no general analytical solution for the price of the Asian option is known, a variety of techniques have been developed to analyze arithmetic average Asian options.
A simple and numerically stable 2-term partial differential equation characterizing the price of any type of arithmetically averaged Asian option is given. The approach includes both continuously and discretely sampled options and it is easily extended to handle continuous or discrete dividend yields.
The paper "Unified Asian Pricing", Risk, Vol. 15, No. 6, 113-116 and its Mathematica nb file can be downloaded at http://www.stat.columbia.edu/~vecer/.
A simple and numerically stable 2-term partial differential equation characterizing the price of any type of arithmetically averaged Asian option is given. The approach includes both continuously and discretely sampled options and it is easily extended to handle continuous or discrete dividend yields.
The paper "Unified Asian Pricing", Risk, Vol. 15, No. 6, 113-116 and its Mathematica nb file can be downloaded at http://www.stat.columbia.edu/~vecer/.
Sep
26
The Black-Scholes formula, one of the major breakthroughs of modern finance, allows for an easy and fast computation of option prices. But some of its assumptions, like constant volatility or log-normal distribution of asset prices, do not find justification in the markets. More complex models, which take into account the empirical facts, often lead to more computations and this time burden can become a severe problem when computation of many option prices is required, e.g. in calibration of the implied volatility surface. To overcome this problem Carr and Madan (1999) developed a fast method to compute option prices for a whole range of strikes.
Fast Fourier transform (FFT) is applied for this purpose, the use of the FFT is motivated by two reasons. On the one hand, the algorithm offers a speed advantage. This effect is even boosted by the possibility of the pricing algorithm to calculate prices for a whole range of strikes. On the other hand, the cf of the log price is known and has a simple form for many models considered in literature, while the density is often not known in closed form.
Fast Fourier transform (FFT) is applied for this purpose, the use of the FFT is motivated by two reasons. On the one hand, the algorithm offers a speed advantage. This effect is even boosted by the possibility of the pricing algorithm to calculate prices for a whole range of strikes. On the other hand, the cf of the log price is known and has a simple form for many models considered in literature, while the density is often not known in closed form.
Sep
23
A useful tool built to help the user gain an intuitive feel for option pricing and the greeks.
Allows the user to create a portfolio of options (and thus straddles, strangles, butterflies and anything else you fancy can be easily created using the GUI).
Once this is done, the user can plot the option price, delta, gamma, vega and variance vega in 3D and examine how they vary with time to maturity, volatility, interest rates and carry.
It also allows you to perturb a 4th dimension also allowing you to create an animation.
Type PlotMeTheGreeks() on the matlab command line to start the GUI.
http://www.mathworks.com/matlabcentral/fileexchange/10428
Allows the user to create a portfolio of options (and thus straddles, strangles, butterflies and anything else you fancy can be easily created using the GUI).
Once this is done, the user can plot the option price, delta, gamma, vega and variance vega in 3D and examine how they vary with time to maturity, volatility, interest rates and carry.
It also allows you to perturb a 4th dimension also allowing you to create an animation.
Type PlotMeTheGreeks() on the matlab command line to start the GUI.
http://www.mathworks.com/matlabcentral/fileexchange/10428





