Library: | finance |
See also: | american asset bitree BlackScholes european mcmillan optstart IBTcrr IBTbc |
Quantlet: | barrier | |
Description: | calculates barrier option prices. |
Usage: | opv =barrier(S, K, Sb, r, d, sigma, tau, knock, type) | |
Input: | ||
S | d1 x ... x d8 array, the current value of the index | |
K | d1 x ... x d8 array, exercise price | |
Sb | d1 x ... x d8 array, barriers | |
r | d1 x ... x d8 array, riskless interest rate | |
d | d1 x ... x d8 array, divident rate | |
sigma | d1 x ... x d8 array, volatility | |
tau | d1 x ... x d8 array, time to expiration (in years) | |
knock | string, if knock="out", "Out" or "OUT", the knock out option price is calculated; if knock="in", "In" or "IN" , the knock in option price is calculated. | |
type | string, if type="call", "Call" or "CALL", the call option price is calculated; if type="put", "Put" or "PUT" , the put option price is calculated. | |
Output: | ||
opv | d1 x ... x d8 array, call option price or put option price |
library("finance") S=100 Sb = 120 r=0.03 d = 0 K=100 tau=1 sigma=0.1 knock="out" type="call" C=barrier(S, K, Sb, r, d, sigma, tau, knock, type) C
Price of a knock out call option with one year expiration time. Contents of C [1,] 3.4335
library("finance") S=#(100,105)~#(110,115) Sb = 120*matrix(2,2) r=0.03 d = 0 K=100 tau=1 sigma=#(01,0.05)~#(0.2,0.01) knock="out" type="call" C=barrier(S, K, Sb, r, d, sigma, tau, knock, type) C
Price of four knock out call options, all with same parameters but distinct underlying volatilities. Contents of C [1,] 0.012536 0.72439 [2,] 7.4645 15.416