The HP 48, and two programs I wrote for it
I have loved HP calculators all my life, and the HP 48 was the first I bought with my own hard earned money. In 1991 I taught mine the foreign exchange market and how to price a bond.
Filed under the date I posted both programs to Usenet, although my affection for these machines began well before that and has never really let up.
I have loved Hewlett-Packard calculators for as long as I have been allowed near one. My father had an HP-67, and the first program I ever wrote was on it, when I was twelve. Of all of them, though, the one I loved most was the HP 48, and it was the first I bought rather than was given. I got mine from EduCALC on release, at US$274.95 against a list price of US$350.
A short history
Hewlett-Packard had been at this since the HP-35 arrived in 1972 and put the slide rule out of business. What set them apart was Reverse Polish Notation, where instead of writing 2 + 3 = you put the two numbers on a stack and then told the machine what to do with them. I learned it on that HP-67 and never had to learn it again.
The HP 48SX was introduced on 6 March 1990, taking over from the HP-28S, and the family carried on being made until 2003. Mine had a Saturn processor, twelve digits of precision, and a screen of 131 by 64 pixels. Hewlett-Packard gave it a proper programming language, called RPL, which married the stack you already knew to lists, objects and directories. My bond work lived in a directory called BOND, and the six commands I wrote for it sat on the soft menu keys along the bottom of the screen, labelled and behaving exactly like the ones the factory had built in.
And then there were units. The HP 48 understood that a number could carry a dimension, so it converted between them as it went and complained if you tried to add metres to kilograms. Almost nothing else on a desk in 1991 did that.
Why I cared
In November 1991 I was a treasury analyst at State Bank Victoria, pricing exotic options and looking after the bank’s treasury management system. My days were exchange rates and bond yields. The bank had issued me an HP-19B when I arrived the year before. Both the programs below are for the 48 I had bought myself, because it seemed obvious to me that the machine in my pocket ought to be able to do my job.
I posted them to Usenet on the same day, 25 November 1991, from extro, the University of Sydney machine that reached the world outside itself, back when Australian addresses still ended in .oz.au. There was comp.sys.hp48 for talk and the moderated comp.sources.hp48 for code. How I came to have an Internet connection at all is a story of its own.
Foreign exchange, as a unit conversion
Converting between currencies looks exactly like converting between units, which the HP 48 already did beautifully, except for one wrinkle. A metre is always the same number of feet, but a currency has two rates rather than one. A dealer quotes a price at which they will buy and a slightly different price at which they will sell, and the gap between the two, the spread, is their profit. So a currency is a unit with two conversion factors, and which one applies depends on which way round the trade is going.
The obvious approach would have been to write a calculator program that asks you questions. What I did instead was teach the machine’s own unit system about currencies, by defining each one twice, once for the bid side and once for the offer:
bUSD '1_USD'
oUSD '1_USD'
bAUD '.779_USD'
oAUD '.7795_USD'
bDEM '.550660792952_USD'
oDEM '.550812448361_USD'
After that, the calculator did the rest by itself. If you were buying fifteen million Australian dollars, you keyed in the amount, pressed the AUD key, and the stack showed you 15000000.0000_bAUD. Press the USD key and it became -11685000.0000_oUSD, which is to say that buying fifteen million Australian dollars means selling about 11.685 million US dollars. The minus sign told you which way the money was going, and the machine had chosen the correct side of the spread on its own.
Cross rates fell out of it for free. Because everything was defined against the US dollar, you could price any currency against any other and the unit engine would work through the two conversions and take the right side of each quote without being asked. The program also knew that some currencies are quoted the other way round by convention, sterling and the Australian dollar among them, so you could simply type the market quote as you would say it out loud.
Pricing bonds
The second program was more conventional but rather more ambitious. It turned the HP 48 into a bond pricing calculator, and I was cheeky enough to say at the time that it went beyond what most financial calculators could do, including Hewlett-Packard’s own.
It priced bonds using the Reserve Bank of Australia formulae, extended to cope with different coupon frequencies and ex-interest periods, and it agreed with the bond functions on the HP-12C. Alongside the price it would give you capital price, accrued interest, implied yield, implied coupon, duration, modified duration, convexity, dispersion, and the price value of a basis point. You could also pull up the RBA parameters themselves if you wanted to check its working, which I often did.
The part I was proudest of was that everything stayed on the screen at once while you typed:
+-----------------------------------+
| |
|{ HOME BOND } |
|___________________________________|
| |
|Settlement 22-Nov-1991 |
|Maturity 15-Nov-2000 |
|Coupon 12.00% |
|Yield 10.500% |
|Bond Price 108.812 |
|_____ _____ _____ _____ _____ _____|
|SETTL MATU CPN YIELD PRICE RBA |
|----- ----- ----- ----- ----- -----|
+-----------------------------------+
Financial calculators of the day tended to hide their state, so you would key in four numbers, get an answer, and have no way of confirming you had not fat-fingered the maturity date. Here you could see the lot, and the soft keys underneath did exactly what they said. Those dates, by the way, are the ones I used in the manual at the time, which is how I can be sure of when I wrote it.
Still there
I wrote the documentation for the bond application properly, in TeX. Years later, in 1999, I ported it to the HP 49, the machine that succeeded the 48.
Both are still online at hpcalc.org, the HP calculator archive Eric Rechlin has been running since 1997. The bond application has been downloaded about 8,500 times and the foreign exchange one about 5,500. For programs written for a discontinued calculator by a treasury analyst in Sydney, that seems a perfectly respectable afterlife.
1991 turned out to be a busy year. I presented a paper at USENIX in January on why Unix password encryption was no longer safe, helped post a program that runs in eight languages in March, and finished the year teaching a calculator about the foreign exchange market.
I still have mine.
Sources
- Foreign Currency Bid/Offer Pricing/Conversions and Bond Pricing Application, both in the HP Calculator Archive, where the original documentation and source still sit.
- HP 48 series, Wikipedia, for the model dates and the hardware details.
- EduCALC’s own list of HP 48SX related products, dated 1 August 1990, for both prices: the HP 48SX Scientific Expandible at a list price of $350.00 and an EduCALC price of $274.95.