HP Forums
A new challenge in the HP19BII solver for the MOHPC community!! - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html)
+--- Forum: General Forum (/forum-4.html)
+--- Thread: A new challenge in the HP19BII solver for the MOHPC community!! (/thread-2822.html)



A new challenge in the HP19BII solver for the MOHPC community!! - Aconzio - 01-09-2015 03:35 PM

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!!


RE: A new challenge in the HP19BII solver for the MOHPC community!! - Don Shepherd - 01-09-2015 03:53 PM

(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.