Posted by
steven e. pav on
Nov 05, 2010; 11:02pm
URL: http://quantlib.414.s1.nabble.com/using-quantlib-in-Matlab-tp9078.html
hello;
I am trying to use the quantlib library from Matlab. As a test case, I
adapted the EquityOption.cpp example code from the quantlib webpage to a cpp
file which would generate the price of an American Put option with parameters
given by the user, using a few different pricing engines. Before writing the
mex, I had created a standalone version which accepted input from std::cin, and
this ran fine.
However, when I run the code from matlab, the results always come back as 0. I
do not know a lot about the guts of quantlib, and the lazy evaluation methods
being used. However, it seems that when I run the standalone, it takes about 1
second or so (there are some binomial lattice engines being used), whereas when
I run the mex file from matlab, it returns zeros instantaneously. I suspect
somehow that the << operator in the standalone (copied from EquityOption.cpp)
forces the option to be evaluated under the given engine, but this is not being
done in my matlab mex.
Am I wrong about this? Do I have to force evaluation somehow? As a snippet of
code, I have things like this in the mex:
americanOptionPut.setPricingEngine(boost::shared_ptr<PricingEngine>(
new BinomialVanillaEngine<JarrowRudd>(bsmProcess,timeSteps)));
P[iii] = (double)americanOptionPut.NPV(); //puts the results in the output
whereas in the standalone it looks more like:
americanOptionPut.setPricingEngine(boost::shared_ptr<PricingEngine>(
new BinomialVanillaEngine<JarrowRudd>(bsmProcess,timeSteps)));
std::cout << "the result is " << americanOptionPut.NPV() << std::endl;
any hints? thanks,
--sep
[ Steven E. Pav {bikes/bitters/linux} nerd ]
[ google voice: 909.SHBYCHF shabbychef a.t gmail d0t com ]
[ parent of tinyurl.com/oskarpix ]
[ a palindrome: wondered now ]
------------------------------------------------------------------------------
The Next 800 Companies to Lead America's Growth: New Video Whitepaper
David G. Thomson, author of the best-selling book "Blueprint to a
Billion" shares his insights and actions to help propel your
business during the next growth cycle. Listen Now!
http://p.sf.net/sfu/SAP-dev2dev_______________________________________________
QuantLib-dev mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-dev