[QuantLibAddin-cvs] QuantLibAddin/Docs/pages faq.docs,1.3,1.4
Brought to you by:
ericehlers,
nando
|
From: Eric E. <eri...@us...> - 2006-08-29 13:50:19
|
Update of /cvsroot/quantlibaddin/QuantLibAddin/Docs/pages In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv17127/Docs/pages Modified Files: faq.docs Log Message: update VBA code Index: faq.docs =================================================================== RCS file: /cvsroot/quantlibaddin/QuantLibAddin/Docs/pages/faq.docs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** faq.docs 28 Aug 2006 10:05:24 -0000 1.3 --- faq.docs 29 Aug 2006 13:50:14 -0000 1.4 *************** *** 181,197 **** \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 --- 181,219 ---- \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 |