Re: building on Fedora 11

Posted by Chuck Swiger-4 on
URL: http://quantlib.414.s1.nabble.com/building-on-Fedora-11-tp7036p7039.html

On Wed, 2009-11-18 at 11:21 -0500, Chuck Swiger wrote:
> On Wed, 2009-11-18 at 11:01 +0100, Luigi Ballabio wrote:
> > On Mon, 2009-11-16 at 15:42 -0500, Chuck Swiger wrote:
> > > Got QuantLib-SWIG to build and Python runs the examples ok but Perl stil
> > > segfaults.
> >
> > Yes, this has bugged me for a long time.  Do you think you can find some
> > time to try and debug it? (Or to reduce the error to a smaller,
> > self-contained example we can send to the SWIG mailing list?)

Ok - There seems to be a problem with, what you my call, 'embedded instantiation'.  Doing stuff like this:

   my($exercise) = new QuantLib::EuropeanExercise(
                                 new QuantLib::Date(17,$QuantLib::May, 1999));

or:

   $inst = new $Class1 ( new $Class2 )

By removing all of those, and fixing some function calls, it runs and produces the two answers, /then/ segfaults ;)

--Chuck

----------------------------------

[chuck@linux7 examples]$ ./european-option2.pl
analytic: 0.981572157109905
integral: 0.981572233014292
Segmentation fault


[chuck@linux7 examples]$ cat ./european-option2.pl
#!/usr/bin/perl

use QuantLib;
# use strict;
#
my($todaysDate) = new QuantLib::Date(15, $QuantLib::May, 1998);
QuantLib::Settings::instance()->setEvaluationDate($todaysDate);
my($settlementDate) = new QuantLib::Date(17, $QuantLib::May, 1998);

my($count1) = new QuantLib::Actual365Fixed;
my($riskFreeRate) = new QuantLib::FlatForward($settlementDate,
                                              0.05,
                                              $count1);

my($Ex_Date) = new QuantLib::Date(17,$QuantLib::May, 1999);
my($exercise) = new QuantLib::EuropeanExercise(
                                 $Ex_Date);
my($payoff) = new QuantLib::PlainVanillaPayoff($QuantLib::Option::Put, 8.0);

my($underlying) = new QuantLib::SimpleQuote(7.0);

my($cal) = new QuantLib::TARGET;
my($count2) = new QuantLib::Actual365Fixed;
my($volatility) = new QuantLib::BlackConstantVol($todaysDate,
                                                 $cal,
                                                 0.10,
                                                 $count2);

my($count3) = new QuantLib::Actual365Fixed;
my($dividendYield) = new QuantLib::FlatForward($settlementDate,
                                               0.05,
                                               $count3);

my($quote) = new QuantLib::QuoteHandle($underlying);
my($dividendYieldHandle) = new QuantLib::YieldTermStructureHandle($dividendYield);
my($riskFreeRateHandle) = new QuantLib::YieldTermStructureHandle($riskFreeRate);
my($volatilityHandle) = new QuantLib::BlackVolTermStructureHandle($volatility);
my($process) = new QuantLib::BlackScholesMertonProcess(
                      $quote,
                      $dividendYieldHandle,
                      $riskFreeRateHandle,
                      $volatilityHandle);

# removed $process from the following args
my($option) = new QuantLib::VanillaOption($payoff, $exercise);

# and added it here
$option->setPricingEngine(new QuantLib::AnalyticEuropeanEngine($process));
print "analytic: ", $option->NPV(), "\n";

$option->setPricingEngine(new QuantLib::IntegralEngine($process));
print "integral: ", $option->NPV(), "\n";




------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users