[QuantLibAddin-cvs] QuantLibAddin/Docs/pages faq.docs, 1.2.2.2, 1.2.2.3
Brought to you by:
ericehlers,
nando
|
From: Eric E. <eri...@us...> - 2006-08-29 13:45:30
|
Update of /cvsroot/quantlibaddin/QuantLibAddin/Docs/pages In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv15055/Docs/pages Modified Files: Tag: R000313f0-branch faq.docs Log Message: document fix for excel crash Index: faq.docs =================================================================== RCS file: /cvsroot/quantlibaddin/QuantLibAddin/Docs/pages/faq.docs,v retrieving revision 1.2.2.2 retrieving revision 1.2.2.3 diff -C2 -d -r1.2.2.2 -r1.2.2.3 *** faq.docs 29 Aug 2006 08:29:42 -0000 1.2.2.2 --- faq.docs 29 Aug 2006 13:45:22 -0000 1.2.2.3 *************** *** 31,34 **** --- 31,35 ---- \ref faq_issues\n + - \ref faq_vba_crash\n - \ref faq_buildtime\n *************** *** 51,54 **** --- 52,91 ---- \section faq_issues Issues With QuantLibAddin 0.3.13 Release + \section faq_vba_crash Calling QuantLibAddin from VBA Crashes Excel + + This is caused by a bug in ObjectHandler. You need to patch + ObjectHandler and rebuild QuantLibXL from source. The patch for + ObjectHandler is to edit file <tt>ohxl/objecthandlerxl.cpp</tt> + and replace the code for funtion <tt>ObjectHandlerXL::storeObject</tt> + as follows: + + \verbatim + std::string ObjectHandlerXL::storeObject( + std::string objectID, + const boost::shared_ptr<Object> &object) { + + if (objectID.empty()) { + objectID = generateObjectID(); + object->setAnonymous(); + } + + if (FunctionCall::instance().getCallerType() == Cell) { + boost::shared_ptr<CallingRange> callingRange = + getCallingRange(); + callingRange->deleteObject(objectID, object); + checkName(objectID); + callingRange->registerObject(objectID, object); + + std::string objectIDCounter = + ObjectHandler::storeObject(objectID, object); + return objectIDCounter + "#" + + callingRange->updateCount(); + } else { + ObjectHandler::storeObject(objectID, object); + return objectID; + } + } + \endverbatim + \section faq_buildtime QuantLibXL Build is Very Slow *************** *** 201,217 **** \verbatim Sub priceEuropeanOption() Dim blackVolHandle As String Dim blackScholesHandle As String Dim optionHandle As String Dim npv As Double blackVolHandle = Application.Run("qlBlackConstantVol", ! "blackconstantvol", 40250, 0.2, "Actual360") ! blackScholesHandle = Application.Run("qlBlackScholesProcess", ! "stoch1", blackVolHandle, 36, "Actual360", 40250, 0.06, 0) ! optionHandle = Application.Run("qlVanillaOption", "eur1", ! blackScholesHandle, "Put", "Vanilla", 35, "European", ! 43903, 0, "JR", 801) npv = Application.Run("qlNPV", optionHandle) Debug.Print npv End Sub \endverbatim --- 238,276 ---- \verbatim Sub priceEuropeanOption() + + On Error GoTo Catch + Dim blackVolHandle As String Dim blackScholesHandle As String + Dim exerciseHandle As String + Dim payoffHandle As String + Dim engineHandle As String Dim optionHandle As String Dim npv As Double + Call Application.Run("qlSetEvaluationDate", 35930) blackVolHandle = Application.Run("qlBlackConstantVol", ! "volatility", 35932, 0.2, "Actual/365 (Fixed)") ! blackScholesHandle = Application.Run( ! "qlGeneralizedBlackScholesProcess", "process", ! blackVolHandle, 36, "Actual/365 (Fixed)", 35932, 0.06, 0) ! exerciseHandle = Application.Run("qlEuropeanExercise", ! "exercise", 36297) ! payoffHandle = Application.Run("qlStrikedTypePayoff", ! "payoff", "Vanilla", "Put", 40) ! engineHandle = Application.Run("qlPricingEngine", "engine", ! "AE") ! optionHandle = Application.Run("qlVanillaOption", "option", ! blackScholesHandle, payoffHandle, exerciseHandle, ! engineHandle) npv = Application.Run("qlNPV", optionHandle) Debug.Print npv + + Exit Sub + + Catch: + + Debug.Print "QuantLibXL Error: " + Err.Description + MsgBox Err.Description, vbCritical, "QuantLibXL Error" + End Sub \endverbatim |