A new challenge in the HP19BII solver for the MOHPC community!!
01-09-2015, 03:35 PM
Post: #1
 Aconzio Junior Member Posts: 7 Joined: Jan 2015
A new challenge in the HP19BII solver for the MOHPC community!!
Dear MOHPC-Community!

Here I am again to bother you!-
Last week I couldn’t believe my eyes; I submitted to your attention a code for programming a call formula out of a finance book and Bill and Gerson discovered an error in the edited book in less than an hour!! - AMAZING..
I have already written to the publisher to notify the error and hopefully the 3rd edition will come out correctly…

Now I have a similar and related problem on HP19BII

Wanting to calculate the Black-Scholes version of the formulas for calls and Puts

C=SxN(d1)-XxEXP(-RxT)xN(d2) with

d1=((LN((SxX^-1xEXP(RxT))))÷(oxT^.5)+(.5xoxT^.5))
d2=((LN((SxX^-1xEXP(RxT))))÷(oxT^.5)+(.5xoxT^.5)) -oxT^.5

P=XxEXP(-RxT)xN(-d2)-SxN(-d1)

and using an approximation of the Normal distribution according to Zelen and Severo (1964) as follows:

Ν=1-(((2xPΙ)^-.5xEXP((-Y^2)÷2))x((.4361836x(1+.33267xΥ)^-1+(-.1201676)x(1+.33267xΥ)^-2
+.9372980x(1+.33267xΥ)^-3)))

substituting one gets these results for call and put:

CALL=Sx(1-(((2xPI)^-.5)xEXP(-((LN((Sx(X^-
1xEXP(RxT))))÷(oxT^.5)+(.5xoxT^.5)))^2÷2))x(.4361836x((1+(.33267x(LN((Sx(X^-1xEXP(RxT))))÷(oxT^.5)+(.5xoxT^.5))))^-1)+(-.1201676)x((1+(.33267x(LN((Sx(X^-
1xEXP(RxT))))÷(oxT^.5)+(.5xoxT^.5))))^-2)+.9372980x((1+(.33267x(LN((Sx(X^-1xEXP(RxT))))÷(oxT^.5)+(.5xoxT^.5))))^-3)))-
XxEXP(-RxT)x
(1-(((2xPI)^-.5)xEXP(-((LN((Sx(X^-1xEXP(RxT))))÷(oxT^.5)+(.5xoxT^.5))-oxT^.5)^2÷2))x
(.4361836x((1+(.33267x((LN((Sx(X^-1xEXP(RxT))))÷(oxT^.5)+(.5xoxT^.5))-oxT^.5)))^-1)
+(-.1201676)x((1+(.33267x((LN((Sx(X^-1xEXP(RxT))))÷(oxT^.5 )+(.5xoxT^.5))-oxT^.5)))^-2)
+.9372980x((1+(.33267x((LN((Sx(X^-1xEXP(RxT))))÷(oxT^.5)+(.5xoxT^.5))-oxT^.5)))^-3)))

********************************************************************************​*****************************

PUT=XxEXP(-RxT)x((1-(((2xPI)^-.5)xEXP(-((LN((Sx(X^-
1xEXP(RxT))))÷(oxT^.5)+(.5xoxT^.5))-oxT^.5)^2÷2))x(.4361836x((1+(.33267x((LN((Sx(X^-1xEXP(RxT))))÷(oxT^.5)+(.5xoxT^.5))-oxT^.5)))^-1)+(-.1201676)x((1+(.33267x((LN((Sx(X^-
1xEXP(RxT))))÷(oxT^.5)+(.5xoxT^.5))-oxT^.5)))^-2)+.9372980x((1+(.33267x((LN((Sx(X^-1xEXP(RxT))))÷(oxT^.5)+(.5xoxT^.5))-oxT^.5)))^-3))))-
Sx(1-(1-(((2xPI)^-.5)xEXP(-((LN((Sx(X^-1xEXP(RxT))))÷(oxT^.5)+(.5xoxT^.5)))^2÷2))x
(.4361836x((1+(.33267x(LN((Sx(X^-1xEXP(RxT))))÷(oxT^.5)+(.5xoxT^.5))))^-1)
+(-.1201676)x((1+(.33267x(LN((Sx(X^-1xEXP(RxT))))÷(oxT^.5 )+(.5xoxT^.5))))^-2)
+.9372980x((1+(.33267x(LN((Sx(X^-1xEXP(RxT))))÷(oxT^.5)+(.5xoxT^.5))))^-3))))

Where S=Spot price, X=Strike, R=interest rate, T=Time to maturity, o=Standard deviation

These formulas used to work well in the past …now after a battery change where all the solver’s content got lost ;-)) I re-inputted both both they deliver fully uncorrected results…My HPBii seems still to work…What happened? Did I do some input mistake with the brackets? Maybe other formulas in the solver with similar variables “contaminate“ those for Black and Scholes?...What do you thinK?...Regards!!
01-09-2015, 03:53 PM
Post: #2 Don Shepherd Senior Member Posts: 659 Joined: Dec 2013
RE: A new challenge in the HP19BII solver for the MOHPC community!!
(01-09-2015 03:35 PM)Aconzio Wrote:  Dear MOHPC-Community!

Here I am again to bother you!-
Last week I couldn’t believe my eyes; I submitted to your attention a code for programming a call formula out of a finance book and Bill and Gerson discovered an error in the edited book in less than an hour!! - AMAZING..
I have already written to the publisher to notify the error and hopefully the 3rd edition will come out correctly…

Now I have a similar and related problem on HP19BII

Wanting to calculate the Black-Scholes version of the formulas for calls and Puts

C=SxN(d1)-XxEXP(-RxT)xN(d2) with

d1=((LN((SxX^-1xEXP(RxT))))÷(oxT^.5)+(.5xoxT^.5))
d2=((LN((SxX^-1xEXP(RxT))))÷(oxT^.5)+(.5xoxT^.5)) -oxT^.5

P=XxEXP(-RxT)xN(-d2)-SxN(-d1)

and using an approximation of the Normal distribution according to Zelen and Severo (1964) as follows:

Ν=1-(((2xPΙ)^-.5xEXP((-Y^2)÷2))x((.4361836x(1+.33267xΥ)^-1+(-.1201676)x(1+.33267xΥ)^-2
+.9372980x(1+.33267xΥ)^-3)))

substituting one gets these results for call and put:

CALL=Sx(1-(((2xPI)^-.5)xEXP(-((LN((Sx(X^-
1xEXP(RxT))))÷(oxT^.5)+(.5xoxT^.5)))^2÷2))x(.4361836x((1+(.33267x(LN((Sx(X^-1xEXP(RxT))))÷(oxT^.5)+(.5xoxT^.5))))^-1)+(-.1201676)x((1+(.33267x(LN((Sx(X^-
1xEXP(RxT))))÷(oxT^.5)+(.5xoxT^.5))))^-2)+.9372980x((1+(.33267x(LN((Sx(X^-1xEXP(RxT))))÷(oxT^.5)+(.5xoxT^.5))))^-3)))-
XxEXP(-RxT)x
(1-(((2xPI)^-.5)xEXP(-((LN((Sx(X^-1xEXP(RxT))))÷(oxT^.5)+(.5xoxT^.5))-oxT^.5)^2÷2))x
(.4361836x((1+(.33267x((LN((Sx(X^-1xEXP(RxT))))÷(oxT^.5)+(.5xoxT^.5))-oxT^.5)))^-1)
+(-.1201676)x((1+(.33267x((LN((Sx(X^-1xEXP(RxT))))÷(oxT^.5 )+(.5xoxT^.5))-oxT^.5)))^-2)
+.9372980x((1+(.33267x((LN((Sx(X^-1xEXP(RxT))))÷(oxT^.5)+(.5xoxT^.5))-oxT^.5)))^-3)))

********************************************************************************​*****************************

PUT=XxEXP(-RxT)x((1-(((2xPI)^-.5)xEXP(-((LN((Sx(X^-
1xEXP(RxT))))÷(oxT^.5)+(.5xoxT^.5))-oxT^.5)^2÷2))x(.4361836x((1+(.33267x((LN((Sx(X^-1xEXP(RxT))))÷(oxT^.5)+(.5xoxT^.5))-oxT^.5)))^-1)+(-.1201676)x((1+(.33267x((LN((Sx(X^-
1xEXP(RxT))))÷(oxT^.5)+(.5xoxT^.5))-oxT^.5)))^-2)+.9372980x((1+(.33267x((LN((Sx(X^-1xEXP(RxT))))÷(oxT^.5)+(.5xoxT^.5))-oxT^.5)))^-3))))-
Sx(1-(1-(((2xPI)^-.5)xEXP(-((LN((Sx(X^-1xEXP(RxT))))÷(oxT^.5)+(.5xoxT^.5)))^2÷2))x
(.4361836x((1+(.33267x(LN((Sx(X^-1xEXP(RxT))))÷(oxT^.5)+(.5xoxT^.5))))^-1)
+(-.1201676)x((1+(.33267x(LN((Sx(X^-1xEXP(RxT))))÷(oxT^.5 )+(.5xoxT^.5))))^-2)
+.9372980x((1+(.33267x(LN((Sx(X^-1xEXP(RxT))))÷(oxT^.5)+(.5xoxT^.5))))^-3))))

Where S=Spot price, X=Strike, R=interest rate, T=Time to maturity, o=Standard deviation

These formulas used to work well in the past …now after a battery change where all the solver’s content got lost ;-)) I re-inputted both both they deliver fully uncorrected results…My HPBii seems still to work…What happened? Did I do some input mistake with the brackets? Maybe other formulas in the solver with similar variables “contaminate“ those for Black and Scholes?...What do you thinK?...Regards!!

Wow, that's some formula. If your opening and closing parentheses didn't match it wouldn't even run, you'd get an error message (like before). If you changed batteries and it lost all solver formulas, it lost all solver variables too, so that's not the problem.

I don't see any obvious problem in scanning the formula, but I'd suggest carefully comparing the formula on the calculator with a hardcopy reference that you know works. Even a single misplaced period can goof things up.

When you change batteries, be careful not to turn the calculator on while the batteries are being loaded, I think that will cause all formulas to be lost.

Good luck.
 « Next Oldest | Next Newest »

User(s) browsing this thread: 1 Guest(s)