quantlib


“end must be large than start” in Uniform1dMesher


I try to build a pyd-file with QuantLib and Boost where I want to calculate the NPV for a barrier option. However the QuantLib pyd throws:
RuntimeError: end must be large than start
The error originates from the following Quantlib class in uniform1dmesher.hpp:
class Uniform1dMesher : public Fdm1dMesher {
public:
Uniform1dMesher(Real start, Real end, Size size)
: Fdm1dMesher(size) {
QL_REQUIRE(end > start, "end must be large than start");
const Real dx = (end-start)/(size-1);
for (Size i=0; i < size-1; ++i) {
locations_[i] = start + i*dx;
dplus_[i] = dminus_[i+1] = dx;
}
locations_.back() = end;
dplus_.back() = dminus_.front() = Null<Real>();
}
};
My c++-code is the following:
struct OptionInputs
{
QuantLib::Real S;
QuantLib::Real K;
QuantLib::Spread f;
QuantLib::Rate r;
QuantLib::Volatility vol;
QuantLib::Date maturity;
QuantLib::DayCounter dayCounter;
};
double FxOptEx(const OptionInputs &in,
const QuantLib::Date &todaysDate,
const QuantLib::Date &settlementDate)
{
using namespace QuantLib;
Calendar calendar = TARGET();
Settings::instance().evaluationDate() = todaysDate;
QuantLib::Real rebate = 0.05;
Size timeGird = 365;
Size underlyingGird = 100;
Size dampingSteps = 0;
Real theta = 0.05;
bool localVolatility = true;
boost::shared_ptr<Exercise> europeanExercise(
new EuropeanExercise(
in.maturity));
Handle<Quote>
underlyingH(boost::shared_ptr<Quote>(new SimpleQuote(in.S)));
Handle<YieldTermStructure>
rTS(boost::shared_ptr<YieldTermStructure>(new FlatForward(settlementDate,
in.r,
in.dayCounter)));
Handle<YieldTermStructure>
fTS(boost::shared_ptr<YieldTermStructure>(new FlatForward(settlementDate,
in.f,
in.dayCounter)));
Handle<BlackVolTermStructure>
flatVolTS(boost::shared_ptr<BlackVolTermStructure>(new BlackConstantVol(settlementDate,
calendar,
in.vol,
in.dayCounter)));
boost::shared_ptr<StrikedTypePayoff>
payoff(new PlainVanillaPayoff(Option::Put,
in.K));
boost::shared_ptr<BlackScholesMertonProcess> blackScholesMertonProcess(new BlackScholesMertonProcess(
underlyingH,
fTS,
rTS,
flatVolTS));
BarrierOption barrierOption(
QuantLib::Barrier::UpIn,
QuantLib::Option::Put,
rebate,
payoff,
europeanExercise);
barrierOption.setPricingEngine(
boost::shared_ptr<PricingEngine>(
new FdBlackScholesBarrierEngine (
blackScholesMertonProcess,
timeGird,
underlyingGird,
dampingSteps,
FdmSchemeDesc::ImplicitEuler(),
localVolatility,
-Null< Real >())));
return barrierOption.NPV();
}
struct FXOption
{
double value;
void set(int S, int K, double f, double r, double vol, std::string maturity, std::string dayCounter)
{
OptionInputs in;
in.S=S;
in.K=K;
in.f=f;
in.r=r;
in.vol=vol;
in.maturity=QuantLib::DateParser::parseISO(maturity);
if (dayCounter == "Actual365Fixed")
{
in.dayCounter = Actual365Fixed();
}
value = FxOptEx(in, Date(15, May, 1998), Date(17, May, 1998));
}
double get()
{
return value;
}
};
using namespace boost::python;
BOOST_PYTHON_MODULE(quant)
{
class_<FXOption>("FXOption")
.def("get", &FXOption::get)
.def("set", &FXOption::set)
;
}
Any idea why this error is thrown?
Sorry I'm late to the party.
Difficult to say without seeing the actual invocation, but could it be that the maturity of the option is earlier than the settlement date?

Related Links

Unhandled exception in Yield Curve Quantlib .exe
How to obtain the “time” values of a schedule
Why did QuantLib introduce the Handle class?
Can't expose monotone convex interpolation in python quantlib
unable to start program QuantLib-vc120-mt-gd.lib
C++: Derive a class template from QuantLib::PiecewiseYieldCurve
clean or dirty price for FixedRateBondHelper
Which version of QuantLib is the basis for QLNet ?
xlquantlib bootstrapping Offshore KRW Curve
“end must be large than start” in Uniform1dMesher
How do I get coupon payment dates for a simple fixed bond using quantlib, quantlib-swig and python
How to calculate the local volatilty surface using QuantLib?

Categories

HOME
django
asp.net-web-api
beautifulsoup
grok
scikit-learn
delphi-7
prism
ecmascript-6
angular2-material
components
appcelerator
iis-6
bing-maps
ibeacon-android
appcelerator-studio
ipmitool
comsol
gource
enterprise-architect
scrolltop
magnetic-cards
dreamweaver
google-picker
google-container-registry
solrcloud
drive
googlebot
visual-glitch
easeljs
jquery-callback
direct3d11
perlbrew
ckfinder
fragment-backstack
intersystems-cache
tpm
cppreference
iis-express
jaws
aws-codecommit
database-comparison
quickfixj
least-squares
roblox
hivemq
tex
resolution
plaintext
congestion-control
dynamic-linq
openal
yii2-api
java-bytecode-asm
yii2-user
flac
restore
slackware
omxplayer
redistributable
hadoop-2.7.2
async.js
uicolor
jquery-jscrollpane
android-dateutils
bizagi
phpwebsocket
design-principles
directdraw
concurrentmodification
grgit
rewrite
cgi-bin
visual-sourcesafe-2005
jsvc
phpldapadmin
beatsmusic
ghcjs
alternate
jquery-slider
extjs2
maven-scm
bin
hibernate-entitymanager
mbunit
unit-of-work
node-blade
joomla-template
font-awesome-4.0.0
preload
joomla3.1
pdfviewer
midlet
extconf.rb
floating-point-exceptions
cross-database
node-redis
htdocs
google-ajax-api
tmx
request-headers
duplex
todos
fdf
java1.4
great-circle

Resources

Encrypt Message