Hi all,
I am trying to expose MCBarrierEngine into quantLibXL but I am really struggling to pass the PseudoRandomNumber generator... Let appart the relevant includes, in my view you would need to add the following code in pricingengine.cpp template<typename T> class MCBarrierEngine : public PricingEngine { public: MCBarrierEngine( const boost::shared_ptr<ObjectHandler::ValueObject>& properties , const boost::shared_ptr<QuantLib::GeneralizedBlackScholesProcess>& process , const QuantLib::Size maxTimeStepsPerYear , bool brownianBridge , bool antitheticVariate , bool controlVariate , const QuantLib::Size requiredSamples , const QuantLib::Real requiredTolerance , const QuantLib::Size maxSamples , bool isBiased , const T& RSQ , const QuantLib::BigNatural seed , bool permanent ); And this in pricingengine.cpp template<typename T> MCBarrierEngine<T>::MCBarrierEngine( const boost::shared_ptr<ObjectHandler::ValueObject>& properties , const boost::shared_ptr<QuantLib::GeneralizedBlackScholesProcess>& process , const QuantLib::Size maxTimeStepsPerYear , const bool brownianBridge , const bool antitheticVariate , const bool controlVariate , const QuantLib::Size requiredSamples , const QuantLib::Real requiredTolerance , const QuantLib::Size maxSamples , const bool isBiased , const T& RSQ , const QuantLib::BigNatural seed , bool permanent ) : PricingEngine(properties, permanent) { libraryObject_ = boost::shared_ptr<QuantLib::PricingEngine>(new QuantLib::MCBarrierEngine<RSQ>(process, maxTimeStepsPerYear, brownianBridge, antitheticVariate, controlVariate, requiredSamples, requiredTolerance, maxSamples, isBiased, seed)) ; } To finish, you need to add the following constructor in pricingengine.xml <Constructor name='qlMCBarrierEnginer'> <libraryFunction>MCBarrierEngine</libraryFunction> <SupportedPlatforms> <SupportedPlatform name='Excel'/> </SupportedPlatforms> <ParameterList> <Parameters> <Parameter name='ProcessID' > <type>QuantLib::GeneralizedBlackScholesProcess</type> <superType>libraryClass</superType> <tensorRank>scalar</tensorRank> <description>GeneralizedBlackScholesProcess object ID.</description> </Parameter> <Parameter name='TimeStepPerYear'> <type>long</type> <tensorRank>scalar</tensorRank> <description>Time Steps Per Year</description> </Parameter> <Parameter name='BrownianBridge' default='FALSE'> <type>bool</type> <tensorRank>scalar</tensorRank> <description>Using a Brownian Bridge?</description> </Parameter> <Parameter name='AntitheticVariate' default='FALSE'> <type>bool</type> <tensorRank>scalar</tensorRank> <description>Using a Antithetic Variate?</description> </Parameter> <Parameter name='ControlVariate' default='FALSE'> <type>bool</type> <tensorRank>scalar</tensorRank> <description>Using a Control Variate?</description> </Parameter> <Parameter name='RequiredSamples'> <type>long</type> <tensorRank>scalar</tensorRank> <description>Minimum number of pathes</description> </Parameter> <Parameter name='RequiredTolerance'> <type>long</type> <tensorRank>scalar</tensorRank> <description>Tolerance on the error</description> </Parameter> <Parameter name='MaxSamples'> <type>long</type> <tensorRank>scalar</tensorRank> <description>Maximum number of pathes</description> </Parameter> <Parameter name='RandomNumberGenerator'> <type>QuantLib::PseudoRandomSequenceGenerator</type> <superType>underlyingClass</superType> <tensorRank>scalar</tensorRank> <description>Random Number Generator</description> </Parameter> <Parameter name='Seed' default='123'> <type>long</type> <tensorRank>scalar</tensorRank> <description>Seed used for the random numbers</description> </Parameter> </Parameters> </ParameterList> </Constructor> I get an error C3203: 'PseudoRandomSequenceGenerator' : unspecialized class template can't be used as a template argument for template parameter 'T', expected a real type ... since I use a non unspecialized template class for the generator. Is there a way to do 1 XL function for all the Pseudo Random Generators? Cheers |
Hi,
You can't directly expose template classes to Excel. To expose this class the template type will need to be passed as a string eventually, although there's a reasonable amount of extra code you need to write first. Try having a look at the PiecewiseYieldCurve class which has already been done. For this example, in particular have a look at the files termstructuresfactory.hpp (in the project QuantLibObjects/enumerations/factories), register_pais.cpp (in the project QuantLibObjects/enumerations/register), enumeratedpairs.*pp (in the project QuantLibObjects/enumerations/constructors) and enumeratedpais.xml (in the project qlgensrc/enumerations). Cheers, Andrew -----Original Message----- From: Yomi [mailto:[hidden email]] Sent: Saturday, 26 September 2009 12:21 AM To: [hidden email] Subject: [Quantlib-users] QuantLibAddin and Monte Carlo simulation Hi all, I am trying to expose MCBarrierEngine into quantLibXL but I am really struggling to pass the PseudoRandomNumber generator... Let appart the relevant includes, in my view you would need to add the following code in pricingengine.cpp template<typename T> class MCBarrierEngine : public PricingEngine { public: MCBarrierEngine( const boost::shared_ptr<ObjectHandler::ValueObject>& properties , const boost::shared_ptr<QuantLib::GeneralizedBlackScholesProcess>& process , const QuantLib::Size maxTimeStepsPerYear , bool brownianBridge , bool antitheticVariate , bool controlVariate , const QuantLib::Size requiredSamples , const QuantLib::Real requiredTolerance , const QuantLib::Size maxSamples , bool isBiased , const T& RSQ , const QuantLib::BigNatural seed , bool permanent ); And this in pricingengine.cpp template<typename T> MCBarrierEngine<T>::MCBarrierEngine( const boost::shared_ptr<ObjectHandler::ValueObject>& properties , const boost::shared_ptr<QuantLib::GeneralizedBlackScholesProcess>& process , const QuantLib::Size maxTimeStepsPerYear , const bool brownianBridge , const bool antitheticVariate , const bool controlVariate , const QuantLib::Size requiredSamples , const QuantLib::Real requiredTolerance , const QuantLib::Size maxSamples , const bool isBiased , const T& RSQ , const QuantLib::BigNatural seed , bool permanent ) : PricingEngine(properties, permanent) { libraryObject_ = boost::shared_ptr<QuantLib::PricingEngine>(new QuantLib::MCBarrierEngine<RSQ>(process, maxTimeStepsPerYear, brownianBridge, antitheticVariate, controlVariate, requiredSamples, requiredTolerance, maxSamples, isBiased, seed)) ; } To finish, you need to add the following constructor in pricingengine.xml <Constructor name='qlMCBarrierEnginer'> <libraryFunction>MCBarrierEngine</libraryFunction> <SupportedPlatforms> <SupportedPlatform name='Excel'/> </SupportedPlatforms> <ParameterList> <Parameters> <Parameter name='ProcessID' > <type>QuantLib::GeneralizedBlackScholesProcess</type> <superType>libraryClass</superType> <tensorRank>scalar</tensorRank> <description>GeneralizedBlackScholesProcess object ID.</description> </Parameter> <Parameter name='TimeStepPerYear'> <type>long</type> <tensorRank>scalar</tensorRank> <description>Time Steps Per Year</description> </Parameter> <Parameter name='BrownianBridge' default='FALSE'> <type>bool</type> <tensorRank>scalar</tensorRank> <description>Using a Brownian Bridge?</description> </Parameter> <Parameter name='AntitheticVariate' default='FALSE'> <type>bool</type> <tensorRank>scalar</tensorRank> <description>Using a Antithetic Variate?</description> </Parameter> <Parameter name='ControlVariate' default='FALSE'> <type>bool</type> <tensorRank>scalar</tensorRank> <description>Using a Control Variate?</description> </Parameter> <Parameter name='RequiredSamples'> <type>long</type> <tensorRank>scalar</tensorRank> <description>Minimum number of pathes</description> </Parameter> <Parameter name='RequiredTolerance'> <type>long</type> <tensorRank>scalar</tensorRank> <description>Tolerance on the error</description> </Parameter> <Parameter name='MaxSamples'> <type>long</type> <tensorRank>scalar</tensorRank> <description>Maximum number of pathes</description> </Parameter> <Parameter name='RandomNumberGenerator'> <type>QuantLib::PseudoRandomSequenceGenerator</type> <superType>underlyingClass</superType> <tensorRank>scalar</tensorRank> <description>Random Number Generator</description> </Parameter> <Parameter name='Seed' default='123'> <type>long</type> <tensorRank>scalar</tensorRank> <description>Seed used for the random numbers</description> </Parameter> </Parameters> </ParameterList> </Constructor> I get an error C3203: 'PseudoRandomSequenceGenerator' : unspecialized class template can't be used as a template argument for template parameter 'T', expected a real type ... since I use a non unspecialized template class for the generator. Is there a way to do 1 XL function for all the Pseudo Random Generators? Cheers -- View this message in context: http://www.nabble.com/QuantLibAddin-and-Monte-Carlo-simulation-tp2561300 4p25613004.html Sent from the quantlib-users mailing list archive at Nabble.com. "This e-mail and any attachments to it (the "Communication") is, unless otherwise stated, confidential, may contain copyright material and is for the use only of the intended recipient. If you receive the Communication in error, please notify the sender immediately by return e-mail, delete the Communication and the return e-mail, and do not read, copy, retransmit or otherwise deal with it. Any views expressed in the Communication are those of the individual sender only, unless expressly stated to be those of Australia and New Zealand Banking Group Limited ABN 11 005 357 522, or any of its related entities including ANZ National Bank Limited (together "ANZ"). ANZ does not accept liability in connection with the integrity of or errors in the Communication, computer virus, data corruption, interference or delay arising from or in respect of the Communication." ------------------------------------------------------------------------------ Come build with us! The BlackBerry® Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9-12, 2009. Register now! http://p.sf.net/sfu/devconf _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
Free forum by Nabble | Edit this page |