There are a couple of bugs in baroneadesiwhaley.cpp:
The Option::Call case, before the while loop there's the line: bi = dividendDiscount * cumNormalDist(d1) * (1 - 1/Q) + (1 - dividendDiscount * cumNormalDist(d1) / QL_SQRT(variance)) / Q; I believe this should read: bi = dividendDiscount * cumNormalDist(d1) * (1 - 1/Q) + (1 - dividendDiscount * cumNormalDist.derivative(d1) / QL_SQRT(variance)) / Q; And on the put side, the same bug is inside the while loop: bi = -dividendDiscount * cumNormalDist(-d1) * (1 - 1 / Q) - (1 + dividendDiscount * cumNormalDist(-d1) / QL_SQRT(variance)) / Q; I believe it should be: bi = -dividendDiscount * cumNormalDist(-d1) * (1 - 1 / Q) - (1 + dividendDiscount * cumNormalDist.derivative(-d1) / QL_SQRT(variance)) / Q; Incidentally the same bug exists in the Haug book VBA code... __________________________________ Start your day with Yahoo! - Make it your home page! http://www.yahoo.com/r/hs |
On 10/28/2005 04:05:14 PM, feynman44 wrote:
> There are a couple of bugs in baroneadesiwhaley.cpp: Ok, they're now fixed in CVS. Thanks, Luigi ---------------------------------------- Call on God, but row away from the rocks. -- Indian proverb |
In reply to this post by feynman44
On 10/28/05, feynman44 <[hidden email]> wrote:
> There are a couple of bugs in baroneadesiwhaley.cpp: > [.. ] Incidentally the same bug exists in the Haug book VBA > code... > Yeah, it was my C++ port of the original Haug VBA code. Have you been able to cross-checked the test cases provided in the test suite (see below)? thank you ciao -- Nando /* The data below are from "Option pricing formulas", E.G. Haug, McGraw-Hill 1998 pag 24 The following values were replicated only up to the second digit by the VB code provided by Haug, which was used as base for the C++ implementation */ AmericanOptionData values[] = { // type, strike, spot, q, r, t, vol, value { Option::Call, 100.00, 90.00, 0.10, 0.10, 0.10, 0.15, 0.0206 }, { Option::Call, 100.00, 100.00, 0.10, 0.10, 0.10, 0.15, 1.8771 }, { Option::Call, 100.00, 110.00, 0.10, 0.10, 0.10, 0.15, 10.0089 }, { Option::Call, 100.00, 90.00, 0.10, 0.10, 0.10, 0.25, 0.3159 }, { Option::Call, 100.00, 100.00, 0.10, 0.10, 0.10, 0.25, 3.1280 }, { Option::Call, 100.00, 110.00, 0.10, 0.10, 0.10, 0.25, 10.3919 }, { Option::Call, 100.00, 90.00, 0.10, 0.10, 0.10, 0.35, 0.9495 }, { Option::Call, 100.00, 100.00, 0.10, 0.10, 0.10, 0.35, 4.3777 }, { Option::Call, 100.00, 110.00, 0.10, 0.10, 0.10, 0.35, 11.1679 }, { Option::Call, 100.00, 90.00, 0.10, 0.10, 0.50, 0.15, 0.8208 }, { Option::Call, 100.00, 100.00, 0.10, 0.10, 0.50, 0.15, 4.0842 }, { Option::Call, 100.00, 110.00, 0.10, 0.10, 0.50, 0.15, 10.8087 }, { Option::Call, 100.00, 90.00, 0.10, 0.10, 0.50, 0.25, 2.7437 }, { Option::Call, 100.00, 100.00, 0.10, 0.10, 0.50, 0.25, 6.8015 }, { Option::Call, 100.00, 110.00, 0.10, 0.10, 0.50, 0.25, 13.0170 }, { Option::Call, 100.00, 90.00, 0.10, 0.10, 0.50, 0.35, 5.0063 }, { Option::Call, 100.00, 100.00, 0.10, 0.10, 0.50, 0.35, 9.5106 }, { Option::Call, 100.00, 110.00, 0.10, 0.10, 0.50, 0.35, 15.5689 }, { Option::Put, 100.00, 90.00, 0.10, 0.10, 0.10, 0.15, 10.0000 }, { Option::Put, 100.00, 100.00, 0.10, 0.10, 0.10, 0.15, 1.8770 }, { Option::Put, 100.00, 110.00, 0.10, 0.10, 0.10, 0.15, 0.0410 }, { Option::Put, 100.00, 90.00, 0.10, 0.10, 0.10, 0.25, 10.2533 }, { Option::Put, 100.00, 100.00, 0.10, 0.10, 0.10, 0.25, 3.1277 }, { Option::Put, 100.00, 110.00, 0.10, 0.10, 0.10, 0.25, 0.4562 }, { Option::Put, 100.00, 90.00, 0.10, 0.10, 0.10, 0.35, 10.8787 }, { Option::Put, 100.00, 100.00, 0.10, 0.10, 0.10, 0.35, 4.3777 }, { Option::Put, 100.00, 110.00, 0.10, 0.10, 0.10, 0.35, 1.2402 }, { Option::Put, 100.00, 90.00, 0.10, 0.10, 0.50, 0.15, 10.5595 }, { Option::Put, 100.00, 100.00, 0.10, 0.10, 0.50, 0.15, 4.0842 }, { Option::Put, 100.00, 110.00, 0.10, 0.10, 0.50, 0.15, 1.0822 }, { Option::Put, 100.00, 90.00, 0.10, 0.10, 0.50, 0.25, 12.4419 }, { Option::Put, 100.00, 100.00, 0.10, 0.10, 0.50, 0.25, 6.8014 }, { Option::Put, 100.00, 110.00, 0.10, 0.10, 0.50, 0.25, 3.3226 }, { Option::Put, 100.00, 90.00, 0.10, 0.10, 0.50, 0.35, 14.6945 }, { Option::Put, 100.00, 100.00, 0.10, 0.10, 0.50, 0.35, 9.5104 }, { Option::Put, 100.00, 110.00, 0.10, 0.10, 0.50, 0.35, 5.8823 } }; |
On Nov 5, 2005, at 3:50 PM, Ferdinando Ametrano wrote:
> On 10/28/05, feynman44 <[hidden email]> wrote: > > There are a couple of bugs in baroneadesiwhaley.cpp: > > [.. ] Incidentally the same bug exists in the Haug book VBA > > code... > > > > Yeah, it was my C++ port of the original Haug VBA code. Have you been > able to cross-checked the test cases provided in the test suite (see > below)? The test cases pass with the fix. Luigi |
Free forum by Nabble | Edit this page |