Re: Vega, rho, and theta not provided

Posted by Luigi Ballabio on
URL: http://quantlib.414.s1.nabble.com/Vega-rho-and-theta-not-provided-tp16447p16557.html

Alex,
    did you set your curves with a fixed reference date, or with a moving one?

Luigi


On Thu, May 7, 2015 at 7:21 PM, Alexander Lamana <[hidden email]> wrote:
Ed, 

1. bump looks like:
Date bump(const Date a, const Date b, const double percent) {
const time_duration difference = (b.dateTime() - a.dateTime());
const time_duration adjustedMilliseconds = 
milliseconds(difference.total_milliseconds() * percent);
const ptime adjustedTime = a.dateTime() + adjustedMilliseconds;
return Date(adjustedTime);
}

2. Here, I have an original date of Date(1, December, 2014). The first call to bump returns Date(28, November, 2014), and the second call returns Date(4, December, 2014). Printing Settings::instance().evaluationDate() after making assignments correctly prints both of the bumped dates.

3. It's a DividendVanillaOption with an AmericanExercise and PlainVanillaPayoff. I use a BlackScholesProcess and FDDividendAmericanEngine<CrankNicolson> for it.

4. What did you do for the AmericanOption test? (I'm assuming you mean the EquityOption example.) I added the following between the finite differences section and the binomial one.

std::cout << "--------------------" << std::endl;

Date currentDate = Settings::instance().evaluationDate();
std::cout << "currentDate=" << currentDate << std::endl;

Date nextDate = currentDate + 10;
std::cout << "nextDate=" << nextDate << std::endl;
Settings::instance().evaluationDate() = nextDate;
americanOption.recalculate();
std::cout << "nextNPV=" << americanOption.NPV() << std::endl;


Date prevDate = currentDate - 10;
std::cout << "prevDate=" << prevDate << std::endl;
Settings::instance().evaluationDate() = prevDate;
americanOption.recalculate();
std::cout << "prevNPV=" << americanOption.NPV() << std::endl;

std::cout << "--------------------" << std::endl;

The output I got was
--------------------
currentDate=May 15th, 1998
nextDate=May 25th, 1998
nextNPV=4.486118
prevDate=May 5th, 1998
prevNPV=4.486118
--------------------

Can you try the code I used and confirm that your NPV changes?

On Thu, May 7, 2015 at 11:09 AM, Luigi Ballabio <[hidden email]> wrote:
Hmm, no. I had a suspicion that the date wouldn't be seen as different if only the time changed, but (a) the notification should be sent even if the date is the same and (b) you're calling recalculate() anyway. Have you tried stepping into the calculations with a debugger?

Luigi


On Tue, May 5, 2015 at 8:41 PM, Alexander Lamana <[hidden email]> wrote:
Any ideas about why the date seems to be fixed?

On Tue, Apr 14, 2015 at 12:06 PM, Alexander Lamana <[hidden email]> wrote:
Do you mean the very first time evaluation date is set? Yes, that causes a change.

The bumps I make to the date when calculating theta don't seem to have any effect, though.

const Date d0 = quoteDatetime;
const Real D0 = option->NPV();

const Date b = bump(d0, expiration, 0.10);
quoteDatetime = b;
Settings::instance().evaluatinDate() = b;
option->recalculate();
const Real f_b = option->NPV();

const Date a = bump(d0, expiration, -0.10);
quoteDatetime = a;
Settings::instance().evaluationDate() = a;
option->recalculate();
const Real f_a = option->NPV();

const Time dt = daysBetween(a, b) / 365;
cout << "D0=" << D0 << endl; // prints 6.21017
cout << "f_a=" << f_a << endl; // also prints 6.21017
cout << "f_b=" << f_b << endl; // 6.21017, again
cout << "d0=" << d0 << endl; // December 19, 2014
cout << "a=" << a << endl; // December 10, 2014
cout << "b=" << b << endl; // December 28, 2014
cout << "dt=" << dt << endl; // about 0.05 years

Thanks,
Alex


On Tue, Apr 14, 2015 at 4:14 AM, Luigi Ballabio <[hidden email]> wrote:
Does the NPV change if you set the evaluation date to a different day?

Luigi

On Thu, Apr 9, 2015 at 4:17 PM, Alexander Lamana <[hidden email]> wrote:
I'm not yet fluent in FD, so bump and reprice is a good first approximation.

For theta, my plan was to bump Settings::instance().evaluationDate() by 10% (1% didn't do anything either) in both directions. I'm using the intraday patch, pull #186, so shifting by amounts less than a day won't be an issue.

Doing something like the following doesn't seem to work, though:
const Date date1 = bump(quoteDatetime, expiration, 0.10); // Move forward by 10%.
Settings::instance().evaluationDate() = date1;
// option->recalculate(); // This doesn't help either.
const Real D1 = option->NPV();

const Date date2 = bump(quoteDatetime, expiration, -0.10); // Move backward by 10%.
Settings::instance().evaluationDate() = date2;
// option->recalculate();
const Real D2 = option->NPV();

// Theta is scaled by days/year.
const Time dt = daysBetween(date1, date2) / 365;
const Real theta = (D1 - D2) * dt;

D1 is always the same as D2, giving a theta of zero.


On Wed, Apr 8, 2015 at 4:50 AM, Ferdinando M. Ametrano <[hidden email]> wrote:
If I had to do it my favorite approach would be to solve with FD the differential equation for vega, as proposed (among others) by D. Tavella and C. Randall in their "Pricing Financial Instruments: The Finite Difference Method"

To the best of my knowledge that would be state-of-the-art: efficient and numerically robust. Of course it is not a walk in the park if you are not fluent in C++ and FD, in which case bump and reprice becomes appealing

On Wed, Apr 8, 2015 at 10:31 AM, Luigi Ballabio <[hidden email]> wrote:
It looks correct (and no, you don't need to call update()).  What results do you expect? What are you getting instead?

Luigi

On Tue, Apr 7, 2015 at 9:56 PM, Alexander Lamana <[hidden email]> wrote:
Hi, I'm trying to get the Greeks for an AmericanOption. Delta and gamma are provided, but the other three are not.

I tried something like the following. It's basically what Luigi suggested in another thread (http://quantlib.10058.n7.nabble.com/Vega-and-Rho-calculation-for-European-and-American-Options-using-Finite-Difference-Method-tp7925p7928.html). 

void calculateGreeks(boost::shared_ptr<SimpleQuote> rQuote,
boost::shared_ptr<SimpleQuote> pQuote,
boost::shared_ptr<SimpleQuote> dQuote,
boost::shared_ptr<SimpleQuote> vQuote,
boost::shared_ptr<OneAssetOption> option) {

// Perturb the implied volatility to calculate vega.
const Rate v0 = vQuote->value();

// Bump it by 1%.
const Spread dv = v0 * 0.01;

vQuote->setValue(v0 + dv);
option->update();
const Real V1 = option->NPV();

vQuote->setValue(v0 - dv);
option->update();
const Real V2 = option->NPV();

const Real vega = (V1 - V2) / (2 * dv);

vQuote->setValue(v0); // Restore the original implied volatility.

// Do something similar for rho and theta...
}

Is there a better way to do this? The values I get for rho, vega, and theta don't really align with the expected results.

Also, since I'm using SimpleQuotes (and passing handles to the term structures), do I need to call update()?


Thanks,
Alex



------------------------------------------------------------------------------
BPM Camp - Free Virtual Workshop May 6th at 10am PDT/1PM EDT
Develop your own process in accordance with the BPMN 2 standard
Learn Process modeling best practices with Bonita BPM through live exercises
http://www.bonitasoft.com/be-part-of-it/events/bpm-camp-virtual- event?utm_
source=Sourceforge_BPM_Camp_5_6_15&utm_medium=email&utm_campaign=VA_SF
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users




--

------------------------------------------------------------------------------
BPM Camp - Free Virtual Workshop May 6th at 10am PDT/1PM EDT
Develop your own process in accordance with the BPMN 2 standard
Learn Process modeling best practices with Bonita BPM through live exercises
http://www.bonitasoft.com/be-part-of-it/events/bpm-camp-virtual- event?utm_
source=Sourceforge_BPM_Camp_5_6_15&utm_medium=email&utm_campaign=VA_SF
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users






--





--




--

------------------------------------------------------------------------------
One dashboard for servers and applications across Physical-Virtual-Cloud
Widest out-of-the-box monitoring support with 50+ applications
Performance metrics, stats and reports that give you Actionable Insights
Deep dive visibility with transaction tracing using APM Insight.
http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users