Hello Quantlibbers,
I am having a problem approximating theta because it seems the option I have has constant NPV over time for a given underlying price. Here is a test function, Real approximateTheta(VanillaOption & option) { DayCounter dc = Actual365Fixed(); Date today = Settings::instance().evaluationDate();
Time dT = dc.yearFraction(today-5,today+5); std::cout<<"today="<<today<<" dT="<<dT<<std::endl;
Settings::instance().evaluationDate()=today-5; Real value_m=option.NPV();
Settings::instance().evaluationDate()=today+5; Real value_p=option.NPV();
Settings::instance().evaluationDate()=today; std::cout<<"m="<<value_m<<" p="<<value_p<<std::endl;
Real theta=(value_p - value_m)/dT; return theta; } When I run this, I get that value_p=value_m. The option uses the AnalyticEuropeanEngine. I thought that options registered with the evaluationDate, so simply moving the date should be enough to get them to decay. I must be doing something wrong. I can provide a more complete example if it will help.
Thanks in advance, Dan
------------------------------------------------------------------------------ Enable your software for Intel(R) Active Management Technology to meet the growing manageability and security demands of your customers. Businesses are taking advantage of Intel(R) vPro (TM) technology - will your software be a part of the solution? Download the Intel(R) Manageability Checker today! http://p.sf.net/sfu/intel-dev2devmar _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
Dan, you probably gave a fixed reference date to your curves. Use the constructors taking a calendar and a number of settlement days instead. Luigi On Tue, 2011-03-22 at 23:42 -0500, Dan Krop wrote: > Hello Quantlibbers, > I am having a problem approximating theta because it seems the > option I have has constant NPV over time for a given underlying > price. > > > Here is a test function, > > > Real approximateTheta(VanillaOption & option) > { > DayCounter dc = Actual365Fixed(); > > > Date today = Settings::instance().evaluationDate(); > Time dT = dc.yearFraction(today-5,today+5); > > > std::cout<<"today="<<today<<" dT="<<dT<<std::endl; > > Settings::instance().evaluationDate()=today-5; > Real value_m=option.NPV(); > > Settings::instance().evaluationDate()=today+5; > Real value_p=option.NPV(); > > > Settings::instance().evaluationDate()=today; > std::cout<<"m="<<value_m<<" p="<<value_p<<std::endl; > > > Real theta=(value_p - value_m)/dT; > return theta; > } > > > When I run this, I get that value_p=value_m. The option uses the > AnalyticEuropeanEngine. I thought that options registered with the > evaluationDate, so simply moving the date should be enough to get them > to decay. I must be doing something wrong. I can provide a more > complete example if it will help. > > > Thanks in advance, > Dan > ------------------------------------------------------------------------------ > Enable your software for Intel(R) Active Management Technology to meet the > growing manageability and security demands of your customers. Businesses > are taking advantage of Intel(R) vPro (TM) technology - will your software > be a part of the solution? Download the Intel(R) Manageability Checker > today! http://p.sf.net/sfu/intel-dev2devmar > _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users -- There are two ways of constructing a software design. One way is to make it so simple that there are obviously no deficiencies. And the other way is to make it so complicated that there are no obvious deficiencies. -- C. A. R. Hoare ------------------------------------------------------------------------------ Enable your software for Intel(R) Active Management Technology to meet the growing manageability and security demands of your customers. Businesses are taking advantage of Intel(R) vPro (TM) technology - will your software be a part of the solution? Download the Intel(R) Manageability Checker today! http://p.sf.net/sfu/intel-dev2devmar _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
Thanks! I very quickly tried to add a theta calculation to pricingengines/vanilla/fdstepconditionengine.hpp, but it gave crazy results. Here is the non-working code I added at the end of calculate(PricingEngine::results*):
Time dt=0.001; model.rollback(arraySet, getResidualTime(),-dt, timeSteps_, conditionSet); SampledCurve earlyPrices(gridPoints_); SampledCurve earlyControl(gridPoints_);
earlyPrices.values() = arraySet[0]; earlyControl.values() = arraySet[1]; Real earlyValue=earlyPrices.valueAtCenter()- earlyControl.valueAtCenter()+ black.value(); results->theta = (results->value - earlyValue)/dt; Am I not evolving the prices back in time correctly? I leave this here in case anybody wants to fix this and commit since it could be generally useful.
Dan Dan On Wed, Mar 23, 2011 at 2:52 AM, Luigi Ballabio <[hidden email]> wrote:
------------------------------------------------------------------------------ Enable your software for Intel(R) Active Management Technology to meet the growing manageability and security demands of your customers. Businesses are taking advantage of Intel(R) vPro (TM) technology - will your software be a part of the solution? Download the Intel(R) Manageability Checker today! http://p.sf.net/sfu/intel-dev2devmar _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
On Thu, 2011-03-24 at 20:32 -0500, Dan Krop wrote:
> Thanks! I very quickly tried to add a theta calculation to > pricingengines/vanilla/fdstepconditionengine.hpp, but it gave crazy > results. I haven't checked your code, but you might want to try using the blackScholesTheta function, which is defined in <pricingengines/greeks.hpp> and uses the relationship between Greeks implied by the Black-Scholes formula to get the theta from value, delta and gamma. It's used in a few engines; for instance, you can look at fdeuropeanengine.hpp. I don't know why it's not in fdstepconditionengine.hpp; it might just be that it was overlooked. Let me know how that works for you. Luigi > Here is the non-working code I added at the end of > calculate(PricingEngine::results*): > > > Time dt=0.001; > model.rollback(arraySet, getResidualTime(),-dt, timeSteps_, > conditionSet); > > > SampledCurve earlyPrices(gridPoints_); > SampledCurve earlyControl(gridPoints_); > earlyPrices.values() = arraySet[0]; > earlyControl.values() = arraySet[1]; > > > Real earlyValue=earlyPrices.valueAtCenter()- > earlyControl.valueAtCenter()+ black.value(); > > > results->theta = (results->value - earlyValue)/dt; > > > Am I not evolving the prices back in time correctly? I leave this here > in case anybody wants to fix this and commit since it could be > generally useful. > > > Dan > > > Dan > > On Wed, Mar 23, 2011 at 2:52 AM, Luigi Ballabio > <[hidden email]> wrote: > > Dan, > you probably gave a fixed reference date to your > curves. Use the > constructors taking a calendar and a number of settlement days > instead. > > Luigi > > > > On Tue, 2011-03-22 at 23:42 -0500, Dan Krop wrote: > > Hello Quantlibbers, > > I am having a problem approximating theta because it > seems the > > option I have has constant NPV over time for a given > underlying > > price. > > > > > > Here is a test function, > > > > > > Real approximateTheta(VanillaOption & option) > > { > > DayCounter dc = Actual365Fixed(); > > > > > > Date today = Settings::instance().evaluationDate(); > > Time dT = dc.yearFraction(today-5,today+5); > > > > > > std::cout<<"today="<<today<<" dT="<<dT<<std::endl; > > > > Settings::instance().evaluationDate()=today-5; > > Real value_m=option.NPV(); > > > > Settings::instance().evaluationDate()=today+5; > > Real value_p=option.NPV(); > > > > > > Settings::instance().evaluationDate()=today; > > std::cout<<"m="<<value_m<<" p="<<value_p<<std::endl; > > > > > > Real theta=(value_p - value_m)/dT; > > return theta; > > } > > > > > > When I run this, I get that value_p=value_m. The option uses > the > > AnalyticEuropeanEngine. I thought that options registered > with the > > evaluationDate, so simply moving the date should be enough > to get them > > to decay. I must be doing something wrong. I can provide a > more > > complete example if it will help. > > > > > > Thanks in advance, > > Dan > > > > ------------------------------------------------------------------------------ > > Enable your software for Intel(R) Active Management > Technology to meet the > > growing manageability and security demands of your > customers. Businesses > > are taking advantage of Intel(R) vPro (TM) technology - will > your software > > be a part of the solution? Download the Intel(R) > Manageability Checker > > today! http://p.sf.net/sfu/intel-dev2devmar > > _______________________________________________ > QuantLib-users mailing list > [hidden email] > https://lists.sourceforge.net/lists/listinfo/quantlib-users > > -- > > There are two ways of constructing a software design. One way > is to > make it so simple that there are obviously no deficiencies. > And the > other way is to make it so complicated that there are no > obvious > deficiencies. > -- C. A. R. Hoare > > > > > ------------------------------------------------------------------------------ > Enable your software for Intel(R) Active Management Technology to meet the > growing manageability and security demands of your customers. Businesses > are taking advantage of Intel(R) vPro (TM) technology - will your software > be a part of the solution? Download the Intel(R) Manageability Checker > today! http://p.sf.net/sfu/intel-dev2devmar > _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users -- All generalizations are dangerous, even this one. -- Alexandre Dumas ------------------------------------------------------------------------------ Create and publish websites with WebMatrix Use the most popular FREE web apps or write code yourself; WebMatrix provides all the features you need to develop and publish your website. http://p.sf.net/sfu/ms-webmatrix-sf _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
Free forum by Nabble | Edit this page |