[R-SIG-Finance] Extract option IDs from option chain

rex rex at nosyntax.net
Wed Sep 8 19:33:40 CEST 2010


Marc Delvaux <mdelvaux at gmail.com> [2010-09-06 20:30]:
>Just a final word of caution if you automate this procedure across a large
>number of stocks.  From time to time, you will find option symbols that
>deviate from the standard format, i.e. where there are more than 6
>characters between the stock ticker and the option type symbol.

Thanks for the heads up.

As Jeff mentioned, this is a Yahoo implementation problem, not
OSI. While OSI provides for symbol changes as you pointed out, OSI
also specifies field widths, and the symbol field should be padded
if the symbol < 6 chars. Unfortunately, the padding character is
apparently not specified, and longer fields are permitted. (!) 

http://www.optionsclearing.com/components/docs/initiatives/symbology/symbology_initiative_v1_8.pdf

(Page 4)
Minimum field sizes
      Symbol – 6 bytes
      Year – 2 bytes
      Month – 2 bytes
      Day – 2 bytes
      Call/Put indicator – 1 byte

> Options <- getOptionChain("BHI",Exp=NULL)

Your command above fails for me:
> Options <- getOptionChain("BHI",Exp=NULL)
Error in as.yearmon.character(allExp) :
  yearmon variable can only have one format

So does your next line when used on a successful getOptionChain call:

> rownames(Options[[2]]$puts)
Error in Options[[2]]$puts : $ operator is invalid for atomic
vectors

Both rownames(Options[[2]]) and rownames(Options$puts) return the
desired result.

I don't see how the commands below could possibly have worked for you.
>> rownames(Options[[2]]$puts)
> [1] "BHI1101016P00017000" "BHI1101016P00018000" "BHI1101016P00019000"
>"BHI101016P00020000"
> [5] "BHI1101016P00020000" "BHI1101016P00021000" "BHI1101016P00022000"
>"BHI101016P00022500"
> [9] "BHI1101016P00023000" "BHI1101016P00024000" "BHI101016P00025000"
>"BHI1101016P00025000"
>[13] "BHI1101016P00026000" "BHI101016P00030000"  "BHI101016P00034000"
>"BHI101016P00035000"
>[17] "BHI101016P00036000"  "BHI101016P00037000"  "BHI101016P00038000"
>"BHI101016P00039000"
>[21] "BHI101016P00040000"  "BHI101016P00041000"  "BHI101016P00042000"
>"BHI101016P00043000"
>[25] "BHI101016P00044000"  "BHI101016P00045000"  "BHI101016P00046000"
>"BHI101016P00047000"
>[29] "BHI101016P00048000"  "BHI101016P00049000"  "BHI101016P00050000"
>"BHI101016P00055000"
>[33] "BHI101016P00060000"  "BHI101016P00065000"
>> nchar(rownames(Options[[2]]$puts))
> [1] 19 19 19 18 19 19 19 18 19 19 18 19 19 18 18 18 18 18 18 18 18 18 18 18
>18 18 18 18 18
>[30] 18 18 18 18 18

-rex
-- 
"It is not disbelief that is dangerous to our society; it is
belief." --G.B. Shaw



More information about the R-SIG-Finance mailing list