Subject: Stock Option Retrieval and Analysis Software Date: April 22, 1994 Author: Gary Funck (gary@intrepid.com) Intrepid Technology, Inc. Mountain View, CA Tel: (415) 964-8135 COPYRIGHT/DISCLAIMER: this software is offered AS IS, no warranty offered or implied. The software has not been extensively tested, and is very much a prototype. Expect problems, and USE AT YOUR OWN RISK. The author grants free, unlimited use of this software and its source code. You may freely incorporate the software in other products or or software distributions. If you do use the source code the author requests a simple written acknowledgement in the form of program comments, or at an appropriate place in your program's documentation. Also, if you make improvements that you want to share with others, or find problems, the author would like to hear about them, so that improvements and fixes can be integrated into the next release of this software. Please send fixes and problem reports to the author, Gary Funck, via e-mail to: gary@intrepid.com. INTRODUCTION: This directory contains the sources used to build two programs that help automate the process of fetching option quote information and analyzing the resulting option quotes. They are packaged as two programs, but ideally the analysis software would be integrated with the retrieval software, so that at a minimum, it could read the output of the retrieval program directly. The retrieval program is written in C and runs on a UNIX workstation. The code has only been compiled and run on a MIPS RISC box, using the BSD compilation environment. Changes to the Makefiles and other sources will be needed to get the program to compile on other machines. Also, the retrieval program needs to be better parameterized with respect to the tty line (see get_quotes.c) it is to use and the user's login (see service.c). They should not be wired into the program as it is now. Also, there are some modem set up sequences and login sequences that may be peculiar to our Telebit 1000 and the front end service that we use to connect to DJNR. All these things should be driven from a file, or script. Once the get_quotes program is built, it will prompt you for some info regarding a stock and its associated option. The program will then fetch all the info. relating to a given option and print it out in a grid as shown below: enter option, stock, cycle: sgi sgi 2 SGI 22 7/8 Sep Oct Nov CALL 22.5 4 1 1/4 55 1 3/4 -- CALL 25 -- -- 35 1 1/4 SGI 22 7/8 Sep Oct Nov PUT 22.5 -- 100 7/8 -- enter option, stock, cycle: suq sunw 1 SUNW 31 1/8 Sep Oct Jan CALL 22.5 -- 500 8 7/8 -- CALL 25 60 6 1/8 110 6 1/4 32 6 3/4 CALL 30 309 1 3/8 709 2 3/16 29 3 3/4 CALL 35 70 3/8 176 1 9/16 SUNW 31 1/8 Sep Oct Jan PUT 22.5 -- 15 1/16 -- PUT 25 -- 8 1/8 33 7/8 PUT 30 44 3/8 307 7/8 65 2 3/8 As you can see, you have to know the option symbol and "cycle" associated with the option. The "cycle" controls which group of months the option expiration dates cycle through. The option symbols and cycles are listed in a little book that you can get from the Chicago Board Options Exchange (CBOE). Call them at 1-800-OPTIONS, and ask for the "Directory of Exchange Listed Options". Ultimately this info. should be kept online, so that the user simply enters the stock symbol, or provide a list of symbols in a file. On Dow Jones and other options quote services, you have to provide a special symbol to get an option quote. The special symbol has a "root symbol" followed by a two letter suffix which gives the expiration month and strike price. Look at the subroutine "option_symbol" in options.c to see what's involved. Right now the program doesn't handle the special suffixes used for index options, and stocks that have split. The algorithm used to get the option info. is: start at the current option price and try each month in the current cycle at each strike price, moving further away from the current price. This process terminates when there are no options listed in any of the three relevant months at a given strike price. To aid debugging, the program keeps a session log, "ttylog". Here's an excerpt resulting from the session shown above: ATE1\r\r\n OK\r\n ATS55=0\r\r\n OK\r\n ATX1\r\r\n OK\r\n ATS52=1\r\r\n OK\r\n ATDT 361 8701\r\r\n RRING\r\n \r\n CONNECT 2400\r\n \r\n -4411:01-005-\r\n please log in: DOW1;\r\n DJNS\r\n \r\n TC> host is online\r\n \177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\000\r\n WHAT SERVICE PLEASE????\r\n \n ENTER PASSWORD\r\n WWWWWWWWWWWWWWW\rMMMMMMMMMMMMMMM\r@@@@@@@@@@@@@@@\r \034\r\n DOW JONES NEWS/RETRIEVAL\r\n COPYRIGHT (C) 1992\r\n DOW JONES & COMPANY, INC.\r\n ALL RIGHTS RESERVED\r\n \r\n BUSH DECLARES DISASTER AREA\r\n IN HAWAII, SEE //NEWS;\r\n SELES WINS WOMEN'S FINAL AT\r\n U.S OPEN, SEE //SPORTS.\r\n ENTER QUERY\r\n \036 //CQE\r\n \034\r\n ENHANCED QUOTES BEING ACCESSED \r\n \n ENTER QUERY\r\n \036 SGI\r\n \r\n \r\n \034DOW JONES STOCK QUOTE REPORTER SERVICE\r\n STOCK QUOTES DELAYED OVER 15 MINUTES\r\n *=CLOSE PRICE ADJUSTED FOR EX-DIVIDEND\r\n \r\n \r\n STOCK BID ASKED\r\n CLOSE OPEN HIGH LOW LAST VOL(100'S)\r\n SGI 23 5/8 23 3/8 23 3/4 22 3/4 22 7/8 1314\r\n \r\n \r\n \036 -SGIIX\r\n \n \034STOCK BID ASKED\r\n CLOSE OPEN HIGH LOW LAST VOL(100'S)\r\n SGIIX 1 1/2 1 1/4 1 1/4 1 1/4 1 1/4 4\r\n \r\n \r\n \036 -SGIJX\r\n \n \034STOCK BID ASKED\r\n CLOSE OPEN HIGH LOW LAST VOL(100'S)\r\n SGIJX 1 11/16 1 3/4 1 7/8 1 3/4 1 3/4 55\r\n \r\n \r\n \036 -SGIAX\r\n \n \034STOCK BID ASKED\r\n CLOSE OPEN HIGH LOW LAST VOL(100'S)\r\n SGIAX STOCK SYMBOL IN ERROR\r\n \r\n \r\n \036 -SGIID\r\n \n \034STOCK BID ASKED\r\n CLOSE OPEN HIGH LOW LAST VOL(100'S)\r\n SGIID 3 3/8 910\r\n \r\n \r\n \036 -SGIJD\r\n \n \034STOCK BID ASKED\r\n CLOSE OPEN HIGH LOW LAST VOL(100'S)\r\n SGIJD 4 1/8 903\r\n \r\n \r\n \036 -SGIAD\r\n \n \034STOCK BID ASKED\r\n CLOSE OPEN HIGH LOW LAST VOL(100'S)\r\n SGIAD STOCK SYMBOL IN ERROR\r\n \r\n \r\n \036 -SGIIE\r\n \n \034STOCK BID ASKED\r\n CLOSE OPEN HIGH LOW LAST VOL(100'S)\r\n SGIIE 1/4 902\r\n \r\n \r\n \036 -SGIJE\r\n \n \034STOCK BID ASKED\r\n CLOSE OPEN HIGH LOW LAST VOL(100'S)\r\n SGIJE 11/16 910\r\n \r\n Notice that there are three kinds of lines resulting from a given option query: (1) a full line with open/close/high/low/last/volume, (2) a partial line just showing "last", where "volume" is actually the last trade date, (3) a "STOCK SYMBOL IN ERROR", which is printed if there is no option listed, or there was a transmission error when sending the option query. In the display of options, the program prints "---" if the option is listed but didn't trade that day, and blanks if it isn't listed at all. The second program, "ocalc", performs calculations on a given set of options. The program computes the theoretical price of an option, its implied volatility, and its "delta". All of these calculations are explained in Chapter 28, "Mathematical Applications" in the second edition of L. McMillan's book "Options as a Strategic Investment", published by the N. Y. Institute of Finance. The input is relatively free form; stock prices can be entered in decimal or fraction form, and expiration dates abbreviated to the first three letters of the month's name. Here's an example: gary@intrepid[143]% ocalc enter stock symbol price [dividend info] where dividend info is dividend period ex-div --> sunw 31 1/8 enter call/put strike month vol price follow the last entry with an empty line. --> c 30 sep 309 1 3/8 --> c 30 oct 709 2 3/16 --> c 30 jan 29 3 3/4 --> c 35 oct 70 3/8 --> c 35 jan 135 1 9/16 --> p 30 sep 44 3/8 --> p 30 oct 307 7/8 --> p 30 jan 65 2 3/8 --> .... And the resulting output: date: 09/13/1992 interest rate: 5.0% stock: sunw price: 31.125 implied volatility: 0.402 Volume Option Theo. I. V. Delta Price Price --------------------------------------------------------------- call 30.00 Sep-19-1992 309 1.375 1.363 0.412 0.770 call 30.00 Oct-17-1992 709 2.188 2.207 0.396 0.657 call 30.00 Jan-16-1993 29 3.750 3.728 0.405 0.635 call 35.00 Oct-17-1992 70 0.375 0.391 0.396 0.192 call 35.00 Jan-16-1993 135 1.562 1.699 0.381 0.368 put 30.00 Sep-19-1992 44 0.375 0.214 0.528 0.278 put 30.00 Oct-17-1992 307 0.875 0.946 0.381 0.339 put 30.00 Jan-16-1993 65 2.375 2.106 0.441 0.368 date: 09/13/1992 interest rate: 5.0% stock: sgi price: 22.875 implied volatility: 0.464 Volume Option Theo. I. V. Delta Price Price --------------------------------------------------------------- call 22.50 Sep-19-1992 4 1.250 0.758 0.898 0.582 call 22.50 Oct-17-1992 55 1.750 1.532 0.544 0.583 call 25.00 Nov-21-1992 35 1.250 1.115 0.500 0.399 put 22.50 Oct-17-1992 100 0.875 1.055 0.397 0.407