Posted by
Luigi Ballabio-2 on
Nov 04, 2004; 4:38am
URL: http://quantlib.414.s1.nabble.com/European-Option-that-comes-due-this-month-tp3410p3411.html
At 16:41 03/11/2004, Robert F. Hoffman wrote:
>I am interested in using the Black Scholes calculation on an option
>which comes due in the current month.
>
>By editing the example to hard-code the current month in the today,
>settlement, and exercise date fields I get the following error in
>blackvariancesurface.cpp:55:
>
>QuantLib::BlackVarianceSurface::BlackVarianceSurface(const
>QuantLib::Date&, const std::vector<QuantLib::Date,
>std::allocator<QuantLib::Date> >&, const std::vector<Time,
>std::allocator<Time> >&, const QuantLib::Matrix&,
>QuantLib::BlackVarianceSurface::Extrapolation,
>QuantLib::BlackVarianceSurface::Extrapolation, const
>QuantLib::DayCounter&): dates must be sorted unique!
Robert,
the error is raised during the instantiation of the
BlackVarianceSurface. If you're not using it (i.e., if you're using a flat
volatility as in the example) you can safely comment its construction out.
If you want to keep it, the problem is the one reported---"dates must be
sorted unique", i.e., must be sorted and without duplicates. You can try
and print out the dates you're passing to the surface to see whether they
satisfy the requirement. For instance,
dates[0] = settlementDate.plusMonths(1);
dates[1] = exerciseDate;
are guaranteed to be unsorted if the exercise is closer than one month.
Also, I think that dates[0] must be strictly later than the settlement.
But really, if a flat volatility is enough for you, just comment out the
BlackVarianceSurface thing. It is there only because Nando is a pack rat :)
Later,
Luigi