Вы находитесь на странице: 1из 1

Analysing options in R

This is a demonstration of the basic features of R for nance, prepared for students in the UNISA Programme in Mathematical Modelling of Derivatives.

which gives quite a bit of information about the option! One can also build arrays of values und <- seq(10, 180, by = 5) vol <- seq(0.2, 0.8, by = 0.1) EO <- EuropeanOptionArrays("call",und,100,0.0, 0.07,1,vol) persp(EO$parameters$underlying, EO$parameters$volatility,EO$value, theta = 30, phi = 30, expand = 0.5, col = "blue")

What is R ?
R is a computer language for statistical and mathematical analysis. It is similar to the commercial system S, developed at Bell Laboratories . R is available for the operating systems AIX, FreeBSD, GNU/Linux, HPUX, Irix, MacOS X, Solaris, as well as for Microsoft Windows (9x, ME, NT4, 2000, XP). http://www.r-project.org/

What is QuantLib?
QuantLib is a free and open-source library for nance. It aims to provide a comprehensive software framework for numerical nance by providing a standard free/open source library for modeling, trading, and risk management of nancial assets. http://www.quantlib.org/

Why free and open-source software?


Open-source software is not only free but may also be modied, installed on arbitrarily many machines, studied and maintained by anyone.

Starting RQuantLib
In Linux the R environment, if installed, is invoked by simply typing R and pressing the Enter key in a a terminal window. In order to use the QuantLib functions that have been ported to R , the library should be loaded with the command library(RQuantLib) from inside the R environment.

for plotting the value of the option, the Greeks etc.

American options in R
In the presence of dividends the fair value an American call option isunder certain circumstancesnot subject to the Black-Scholes formula. A non-trivial American put option never is. For this reason, we can use the numerical procedures of QuantLib in R in order to value the options, for example AmericanOption(type="put", underlying=100, strike=100, dividendYield=0.03, riskFreeRate=0.07,maturity=0.5, volatility=0.4, timeSteps=150, gridPoints=151) using a nite-dierence method.

European options in R
The Black-Scholes formula is implemented in R and can be used right away for the pricing of European options on non-dividend paying assets. Simply pricing an option is accomplished by a command like EuropeanOption("call", underlying = 100, strike = 100, dividendYield = 0.00, riskFreeRate = 0.07, maturity = 1, volatility = 0.35) for an at-the-money call option, or an abbreviated version of this command, EuropeanOption("call",100,100,0.00,0.07,1,0.35) and the output of either command is
Concise summary of valuation for EuropeanOption value delta gamma vega theta rho divRho 17.0675 0.6462 0.0106 37.1855 -9.8359 47.5495 -64.6170

Other applications
RQuantLib can price certain exotic options, including binary and barrier options, construct yield curves and can use all of the above in building more complex models.

Petrus H. Potgieter

http://www.kolmogorov.net/php/

Вам также может понравиться