Hi,
Am trying to implement Vega and Rho calculator using FD method but am not able to decide the level at which it should be implemented. Also since it requires construction of temporary grid using perturbed value of volatility/RiskFree rate, I would like it to do so only when .vega is asked by the testfile (equityoption.cpp in present case) + it will be an infinite loop if it tries to calculate vega for every option. Kindly let me know the files I should tamper for a clean implementation. Thanks in advance. Ravi ------------------------------------------------------------------------------ This SF.Net email is sponsored by the Verizon Developer Community Take advantage of Verizon's best-in-class app development support A streamlined, 14 day to market process makes app distribution fast and easy Join now and get one step closer to millions of Verizon customers http://p.sf.net/sfu/verizon-dev2dev _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
On Wed, Jan 13, 2010 at 12:01 AM, ravi agrawal <[hidden email]> wrote:
> Hi, > Am trying to implement Vega and Rho calculator using FD method but am not > able to decide the level at which it should be implemented. Also since it > requires construction of temporary grid using perturbed value of > volatility/RiskFree rate, I would like it to do so only when .vega is asked > by the testfile (equityoption.cpp in present case) + it will be an infinite > loop if it tries to calculate vega for every option. Kindly let me know the > files I should tamper for a clean implementation. Are you trying to calculate Greeks in the tree or FD framework? While I don't feel comfortable about providing directions (and that's why I didn't tackle the issue before), I suggest you look into the possibility of solving the Vega/Rho PDE equation instead of the "brute force" perturbed grid approach. ciao -- Nando ------------------------------------------------------------------------------ This SF.Net email is sponsored by the Verizon Developer Community Take advantage of Verizon's best-in-class app development support A streamlined, 14 day to market process makes app distribution fast and easy Join now and get one step closer to millions of Verizon customers http://p.sf.net/sfu/verizon-dev2dev _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
In reply to this post by ravi agrawal-2
Hi, Ravi As u can see QL architecture doesnt allow u to calculate vega/rho by perturbation within corresponding method of OneAssetOption class, cause itsn't possible to create a clone object with shift vol/rate parameter. My suggestion is to develop your own Instrument class which also inherenced from LazyObject class and additionally have shiftedNPV(variable, value) function with NPV calculation of shifted clone object. Maybe this way also requires you to create Underlying class with clone interface (vol, rate, etc), so to change in some way QL architecture. |
Hi,
I am trying to calculate greeks from the FD framework. Presently I moved to using wrapper for vega and rho. Also I notice that Theta is being calculated in FD framework by using black scholes equation using the values of FD delta and gamma. I wanted to calculate it by grid method but am searching for grid and value 2-d array where I could get call option value which has expiry some grid times less that the present option. Could anyone tell me where I can find this value 2 d grid and price 2d grid? Thanks Andrew, i was thinking something in this direction. Regards Ravi On Fri, Jan 15, 2010 at 5:14 AM, Andrew Kolesnikov <[hidden email]> wrote:
------------------------------------------------------------------------------ Throughout its 18-year history, RSA Conference consistently attracts the world's best and brightest in the field, creating opportunities for Conference attendees to learn about information security's most important issues through interactions with peers, luminaries and emerging and established companies. http://p.sf.net/sfu/rsaconf-dev2dev _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
On Sat, 2010-01-16 at 12:39 -0800, ravi agrawal wrote:
> I am trying to calculate greeks from the FD framework. Presently I > moved to using wrapper for vega and rho. Also I notice that Theta is > being calculated in FD framework by using black scholes equation using > the values of FD delta and gamma. I wanted to calculate it by grid > method but am searching for grid and value 2-d array where I could > get call option value which has expiry some grid times less that the > present option. Could anyone tell me where I can find this value 2 d > grid and price 2d grid? You can look, e.g., at <ql/pricingengines/vanilla/fdeuropeanengine.hpp>, around line 75. There's a call to model.rollback(...), that evolves the prices to t=0 (their values after the call are in the prices_ array.) After extracting the value at center and the greeks, you can add another call to model.rollback(...) taking the prices some time before 0. After that call, you can extract the value at center again and use it to calculate theta. The same can be done in the FD engines for american and bermudan options. As for the rho/vega issue: > On Fri, Jan 15, 2010 at 5:14 AM, Andrew Kolesnikov <[hidden email]> > wrote: > > > Hi, Ravi > As u can see QL architecture doesnt allow u to calculate > vega/rho by perturbation within corresponding method of > OneAssetOption class, cause itsn't possible to create a clone > object with shift vol/rate parameter. That's because you can't shift it in a general way. At the instrument level, you don't know if you're using a Black-Scholes model, a Heston model, or something else entirely. > My suggestion is to develop your own Instrument class which > also inherenced from LazyObject class and additionally have > shiftedNPV(variable, value) function with NPV calculation of > shifted clone object. If you go for shifting and recalculating, you can do it right now using quotes. You can do something like the following: // put the values in quotes: shared_ptr<SimpleQuote> riskFreeRate(new SimpleQuote(0.02)); shared_ptr<SimpleQuote> volatility(new SimpleQuote(0.15)); // ... other required parameters ... // create flat curves with the above values: Handle<YieldTermStructure> r( shared_ptr<YieldTermStructure>( new FlatForward(today, Handle<Quote>(riskFreeRate), Actual365()))); Handle<BlackVolTermStructure> sigma( shared_ptr<BlackVolTermStructure>( new BlackConstantVol(today, NullCalendar(), Handle<Quote>(volatility), Actual365())); // ...and the others. // create the process: shared_ptr<BlackScholesMertonProcess> process( new BlackScholesMertonProcess(s0, q, r, sigma)); // instantiate the option and set it an engine using the process VanillaOption option(...); option.setPricingEngine( boost::shared_ptr<PricingEngine>( new FDEuropeanEngine<CrankNicolson>(process, timeSteps,gridSteps))); // now you're set. // first you get the unperturbed price: Real P = option.NPV(); // then by shifting the quotes you can get any perturbed value: Rate r0 = riskFreeRate->value(); Spread dr = 0.0001; riskFreeRate->setValue(r0 + dr); // the quote change is propagated automatically, // and this now gives you the value for the new rate: Real P1 = option.NPV(); // same downwards: riskFreeRate->setValue(r0 - dr); Real P2 = option.NPV(); // put them together for the rho: Real rho = (P1-P2)/(2*dr); // and don't forget to restore the original rate. riskFreeRate->setValue(r0); // do the same for the volatility quote, and you get the vega. Hope this helps, Luigi -- For every problem there is one solution which is simple, neat, and wrong. -- H. L. Mencken ------------------------------------------------------------------------------ Throughout its 18-year history, RSA Conference consistently attracts the world's best and brightest in the field, creating opportunities for Conference attendees to learn about information security's most important issues through interactions with peers, luminaries and emerging and established companies. http://p.sf.net/sfu/rsaconf-dev2dev _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
Free forum by Nabble | Edit this page |