2016年6月18日 星期六

選擇權定價實作:American put options on zero-coupon bonds under the CIR model

 

cir model pricing 來結束這學期的財務演算法課程^^  這個故事告訴我們小時候數學要學好,不然長大會被霸凌XD

感謝耕竹大大的指導!




一、問題描述:American put options on zero-coupon bonds under the CIR model


price an x-year American-style put option on a zero-coupon bond that matures at year y with a par value of 1 dollar. Use trees for the CIR model.

Inputs:

  • x (year), 
  • y (year), 
  • r (%) (initial short rate), 
  • b (%) and 
  • m (%), 
  • s (%), 
  • n (the number of steps during the option's life), and 
  • strike price X (% of par). 

For example,  when

  • x = 1, y = 2, r = 4 (%), b = 20 (%), m = 4 (%), s = 10 (%), n = 30, and X = 95 (%). 

the option price is about 2.65173 (% of par)

---

R語言執行方式:直接使用 R 直譯器執行即可

R語言執行結果:






二、設計與實作



1. 產生 short rate tree


approximate the short rate process

  • direct discretization of the process is problematic because the resulting binomial tree will not combine
  • using transformed process to generate short rate tree




R code

# generate short rate tree
shortrate_tree <- matrix(data = 0, nrow = n+1, ncol = n+1)
shortrate_tree <- initShortRateTree(shortrate_tree,
                                    x = 2*sqrt(r_0)/sigma,
                                    delta_t)
shortrate_tree <- transformR(shortrate_tree, sigma)



2. 產生 prob. tree


由  short rate tree 代入以下公式即可得 prob. tree。



R code

# generate prob tree
prob_tree <- matrix(data = 0, nrow = n, ncol = n)
prob_tree <- initProbTree(prob_tree, shortrate_tree, mu, beta, delta_t)



3. 產生 price tree


由 "Numerical pricing of American put options on zero-coupon bonds" 這篇paper提供的cir model公式可獲得cir model price tree。




R code


# generate price tree
price_tree <- matrix(data = 0, nrow = n+1, ncol = n+1)
price_tree <-initCIRPriceTree( price_tree, shortrate_tree,
                               sigma = sigma, r_inf = mu, kapa = beta,
                               E = 1, T_star = y,
                               delta_t = delta_t)



4. 產生 value tree


用 classical American put 的架構,把binomial tree的price值改成cir model預估的值,並把機率也改成cir model預估的機率即可。

R code


# generate value tree (pricing)
valueTree <- matrix(data = 0, nrow = n+1, ncol = n+1)
X = X*0.01

for(i in 1:(n+1)){
  valueTree[i,n+1] = max(X-price_tree[i,n+1], 0);
}

for(j in n:1){
  for(i in 1:j){
    q = prob_tree[i,j]
    valueTree[i,j] =  max(X-price_tree[i,j] ,
                          q*valueTree[i,j+1] + (1-q)*valueTree[i+1,j+1])
  }
}

cat("price under cir: ", valueTree[1,1])





References


Y.-D. Lyuu - Principles of Financial Computing
http://www.csie.ntu.edu.tw/~lyuu/finance1.html

"Numerical pricing of American put options on zero-coupon bonds" August 2003
Walter Allegretto, Yanping Lin, Hongtao Yang



技術提供:Blogger.