If you don’t require a particular Boost version, the path of least resistance is to install the one packaged for your distribution; for instance, on Ubuntu you would execute:
1 |
sudo apt-get install libboost-all-dev |
You can download released QuantLib versions from Bintray at QuantLib-1.4.1.tar.gz.
1 |
tar xzf QuantLib-1.4.1.tar.gz |
1 2 |
cd QuantLib-1.4.1 ./configure |
1 |
./configure --help |
1 |
./configure --with-boost-include=/home/foo/include --with-boost-lib=/home/foo/lib |
1 2 |
Make sudo make install |
1 |
sudo ldconfig |
1 2 |
cd Examples/BermudanSwaption g++ BermudanSwaption.cpp -o BermudanSwaption -l QuantLib ./BermudanSwaption |
1 2 3 |
g++ BermudanSwaption.cpp -I/home/foo/include -o; BermudanSwaption -L/home/foo/lib -l QuantLib #if you ran ./configure with prefix /home/foo |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
#include <ql/qldefines.hpp> #ifdef BOOST_MSVC # include <ql/auto_link.hpp> #endif #include <ql/instruments/vanillaoption.hpp> #include <ql/pricingengines/vanilla/binomialengine.hpp> #include <ql/pricingengines/vanilla/analyticeuropeanengine.hpp> #include <ql/pricingengines/vanilla/analytichestonengine.hpp> #include <ql/pricingengines/vanilla/baroneadesiwhaleyengine.hpp> #include <ql/pricingengines/vanilla/bjerksundstenslandengine.hpp> #include <ql/pricingengines/vanilla/batesengine.hpp> #include <ql/pricingengines/vanilla/integralengine.hpp> #include <ql/pricingengines/vanilla/fdeuropeanengine.hpp> #include <ql/pricingengines/vanilla/fdbermudanengine.hpp> #include <ql/pricingengines/vanilla/fdamericanengine.hpp> #include <ql/pricingengines/vanilla/mceuropeanengine.hpp> #include <ql/pricingengines/vanilla/mcamericanengine.hpp> #include <ql/time/calendars/target.hpp> #include <ql/utilities/dataformatters.hpp> #include <boost/timer.hpp> #include <iostream> #include <iomanip> using namespace QuantLib; ….. ….. ….. // Binomial method: Jarrow-Rudd method = "Binomial Jarrow-Rudd"; europeanOption.setPricingEngine(ext::shared_ptr<PricingEngine>( new BinomialVanillaEngine<JarrowRudd>(bsmProcess,timeSteps))); bermudanOption.setPricingEngine(ext::shared_ptr<PricingEngine>( new BinomialVanillaEngine<JarrowRudd>(bsmProcess,timeSteps))); americanOption.setPricingEngine(ext::shared_ptr<PricingEngine>( new BinomialVanillaEngine<JarrowRudd>(bsmProcess,timeSteps))); std::cout << std::setw(widths[0]) << std::left << method << std::fixed << std::setw(widths[1]) << std::left << europeanOption.NPV() << std::setw(widths[2]) << std::left << bermudanOption.NPV() << std::setw(widths[3]) << std::left << americanOption.NPV() << std::endl; |
Leave a Comment