|
From: steve.affine <st...@af...> - 2007-04-02 07:21:57
|
Concerning the FR to add Greeks (http://sourceforge.net/tracker/index.php?func=detail&aid=910972&group_id=12740&atid=362740), I have looked at this today and implemented most of them. My suggestion is to use points on the binomial tree as per Odergaard (http://finance-old.bi.no/~bernt/gcc_prog/recipes/recipes.pdf). This gives delta, gamma & theta in quick and straightforward way without the need for recomputation. The code in binomialengine.hpp is basically: DiscretizedVanillaOption option(arguments_); //Go to maturity option.initialize(lattice, maturity); //Partial derivatives calculated from various points in the binomial tree (Odegaard) //Rollback to third-last step, and get underlying price (s) & option value (p) at this point option.rollback(grid[2]); Array va2(option.values()); QL_ASSERT(va2.size() == 3, "Expect 3 nodes in grid at second step"); Real p2h = va2[2]; // high-price Real p2m = va2[1]; // mid-price Real s2 = bslattice->underlying(2, 2); //high price //Rollback to second-last step, and get underlying price (s) & option value (p) at this point option.rollback(grid[1]); Array va(option.values()); QL_ASSERT(va.size() == 2, "Expect 2 nodes in grid at first step"); Real p1 = va[1]; //Rollback to t=0 option.rollback(0.0); Real p0 = option.presentValue(); Real s1 = bslattice->underlying(1, 1); //Calc partials Real delta0 = (p1-p0)/(s1-s0); //dp/ds Real delta1 = (p2h-p1)/(s2-s1); //dp/ds //Return results results_.value = p0; results_.delta = delta0; results_.gamma = 2.0*(delta1-delta0)/(s2-s0); //d(delta)/ds results_.theta = (p2m-p0)/(grid[2]); //dp/dT Any comments on this? Does anyone disagree, or think there is a better method or better place to put this code? cheers Steve affine group limited http://www.affine.hk -- View this message in context: http://www.nabble.com/Greeks-for-vanilla-binomial---implementation-tf3504086.html#a9786157 Sent from the quantlib-dev mailing list archive at Nabble.com. |