The Museum of HP Calculators

HP Forum Archive 07

[ Return to Index | Top of Index ]

Hp-19BII, S Function
Message #1 Posted by Jim Kimes on 2 Dec 2001, 6:58 p.m.

Can someone tell me if the S function, as described on page 236 of the manual, will take only two nests? I tried it using three decisions and the invalid message kept pointing to the third : (colon). I presumed then that my problem was the nesting limit. I wrote other equations with two nests and they worked fine. If this is the case, are there any suggestions how I might make an equation more complex, circumventing the nesting limit? Thanks. Jim Kimes

      
Re: Hp-19BII, S Function
Message #2 Posted by W. Bruce Maguire II on 3 Dec 2001, 12:25 p.m.,
in response to message #1 by Jim Kimes

Jim:

I have used more than two levels of nesting (look at the recent post I made to the "Articles" section regarding the FMRR program---at the end).

Can you write-out the program (or at least the offending section) and post it? My guess is that you have some other syntax problem (missing or extra paretheses), and the 19BII is choosing to error on the colon.

Hopefully I understand the problem, but if I'm incorrect, please post back!

Bruce.

            
Re: Hp-19BII, S Function
Message #3 Posted by Jim Kimes on 5 Dec 2001, 9:51 a.m.,
in response to message #2 by W. Bruce Maguire II

Bruce:

Below is the equation Iím trying to use. Whatís strange is that the equation works if I remove the middle leg and it works if I remove the third leg, but doesnít work if I use all three.

IF(S(OPPROF):OPPROF-SHx(((SPx(1-SC)+OPx(1-OC-(PPx(1+SC)))))):RET-OPPROF/((SHxPP)x(1+SC)))=0

The above is the formula that works now. But if I try to add the number of days application, it balks. However, if I take out the middle leg and add the number of days function, it works; same syntax. Must be what you say, a parentheses problem or something of that nature.

IF(S(OPPROF):OPPROF-SHx(((SPx(1-SC)+OPx(1-OC-(PPx(1+SC)))))):RET-OPPROF/((SHxPP)x(1+SC): ANRET-((365/DDAYS(D1:D2:1))xRET)))=0

A sample problem would be:

SH = number of shares; SP = strike price of stock; SC = stock commissions; OC = Options commissions; PP = purchase of stock; OPPROF = profit on an options transactions if stock is called. So, if SH = 1,000; SP = $25.00; SC = .015; OC = .05; OP = $1.05; PP = $23.65; D2 = 12/21/01 and D1 = 11/23/01, solving this problem OPPROF = $1,617.75; RET = 6.74%; and ANRET (annualized return)= 87.9%

It will be interesting to see what you get. Jim Kimes

                  
Re: Hp-19BII, S Function
Message #4 Posted by W. Bruce Maguire II on 6 Dec 2001, 4:00 p.m.,
in response to message #3 by Jim Kimes

Jim:

I think I see it, but I want to make sure! I'll have the answer for you tomorrow afternoon (just too busy today!).

Bruce.

                  
Re: Hp-19BII, S Function
Message #5 Posted by W. Bruce Maguire II on 7 Dec 2001, 6:54 p.m.,
in response to message #3 by Jim Kimes

Jim:

Here are the alterations to your equation that I made. You did, indeed, have a few parentheses errors, as well as confusion with the "S" function. I changed the names of some of the variables, just to give you some ideas of naming conventions I like for clarity. One thing I like is to always enter percent values in percent, rather than a fraction. This is what I did in your equation, but if you are trained to use fractional values, than you will want to take out the "%" symbols in the names, and take out all the "divide by 100" instances in the equation. I also show you a technique to re-order your variables. Finally, you do not need the "=0" at the end, the machine will assume that.

I also remember seeing a technique to produce multiple results at once, which is really what you want here. If I can find it, I will post it.

For clarity, I use "_mult_" for the multiplication symbol, and "_div_" for the division symbol in the listing.

The program starts with "SELLING~CALLS:" followed by two spaces (for name readability), then key in the rest of the program without the white-space.

SELLING~CALLS:

0_mult_ SP$_mult_ PP$_mult_ SC%_mult_ OP$_mult_ OC%_mult_ SH#_mult_ DAT1_mult_ DAT2+

IF(S(PRO$): PRO$- SH#_mult_( SP$_mult_( 1-SC%_div_100 )+ OP$_mult_( 1-OC%_div_100 )- PP$_mult_( 1+SC%_div_100 ) ) : IF(S(RTN%): RTN%_div_100- PRO$_div_( SH#_mult_ PP$_mult_( 1+SC%_div_100 ) ) : ANN%_div_100-( 365_div_ DDAYS(D1:D2:1)_mult_ RTN%_div_100 ) ) )

I checked the formula on my 19BII with the parameters you sent me, and I get the same results:

----------Jim wrote:---------- A sample problem would be:

SH = number of shares; SP = strike price of stock; SC = stock commissions; OC = Options commissions; PP = purchase of stock; OPPROF = profit on an options transactions if stock is called. So, if SH = 1,000; SP = $25.00; SC = .015; OC = .05; OP = $1.05; PP = $23.65; D2 = 12/21/01 and D1 = 11/23/01, solving this problem OPPROF = $1,617.75; RET = 6.74%; and ANRET (annualized return)= 87.9%

It will be interesting to see what you get. Jim Kimes ------------------------------

Let me know how it works out, Bruce.

                        
Re: Hp-19BII, S Function
Message #6 Posted by Jim Kimes on 8 Dec 2001, 8:54 a.m.,
in response to message #5 by W. Bruce Maguire II

Bruce, I have not had a chance to analyze totally what you're saying in your Dec 7 posting; however, I revisited the problem while my wife watched QVC and when I finally realized what I was doing wrong, I felt abysmally stupid. I was leaving out the second IF(S) condition. What was so dumb is that I write conditional equations in Excel all the time and I know that with each nest I must have another IF. So I inserted that with a couple of other tweaks and here is what I came up with and it works beautifully. I appreciate the work you put in and will respond to your suggestions when I digest them.

IF(S(OPPROF):OPPROF-(SHx((SPx(1-SC)+(OPx(1-OC)-(PPx(1+SC)))))):IF(S(RET):RET-OPPROF/((SHxPP)x(1+SC)): ANRET-RETx(365/DDAYS(D1:D2:1))))=0

Now, when I fill in all variables I can obtain my option profit, my interim return and my annualized return. With further addendums I'm sure I could build in a method of obtaining IRR, also. Thanks, again. Jim Kimes

                              
Re: Hp-19BII, S Function
Message #7 Posted by W. Bruce Maguire II on 8 Dec 2001, 11:06 p.m.,
in response to message #6 by Jim Kimes

Jim:

You're very welcome. Please do take a look at the code I listed, as I think it makes a few significant improvements. If nothing else, I think you'll be interested in the technique for ordering the variable buttons (put them in the order you want (for entering data) up-front and multiply all of them by zero). Also, you may want to consider the other way of handling percentage variables and adding symbols tot he variable names to alleviate confusion.

Bruce.


[ Return to Index | Top of Index ]

Go back to the main exhibit hall