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 |
On Mon, 2007-04-02 at 00:21 -0700, steve.affine wrote:
> 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). Steve, looks ok to me. May you send a patch? Thanks, Luigi P.S. Is the Nabble archive a public one? If so, I'll link it from the mailing list page on the QuantLib site. ---------------------------------------- Don't let school get in the way of your education. -- Mark Twain ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys-and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ QuantLib-dev mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-dev |
Free forum by Nabble | Edit this page |