[R-SIG-Finance] Extract option IDs from option chain
rex
rex at nosyntax.net
Tue Sep 7 01:10:30 CEST 2010
I'm using Jeff Ryan's excellent QuantMod and its getOptionChain
to download option data. I've fruitlessly spent hours searching
for a way to extract option ID's as strings.
Format is:
> allOpts <- getOptionChain("AAPL", Exp=optExpire)
> allOpts
$calls
Strike Last Chg Bid Ask Vol OI
AAPL100918C00150000 150 108.50 16.50 106.80 108.85 3 13
AAPL100918C00155000 155 96.77 0.00 102.40 103.85 4 10
AAPL100918C00160000 160 95.75 4.50 97.40 98.85 10 30
[...]
$puts
Strike Last Chg Bid Ask Vol OI
AAPL100918P00150000 150 0.01 0.00 NA 0.01 6 876
AAPL100918P00155000 155 0.02 0.00 NA 0.01 30 666
AAPL100918P00160000 160 0.02 0.00 NA 0.01 79 1535
[...]
$symbol
[1] "AAPL"
The obvious thing fails to produce the desired result:
> index(allOpts$puts)
[1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
What I need are the indexes of both $calls and $puts as a set of
strings that can be split, etc. (I need the expiration date of the
options as a Date to be used to calculate the days to expiration.)
Thanks in advance for any help on this very frustrating problem.
The R world is too vast for my half-vast brain... :(
-rex
--
My sister opened a computer store in Hawaii. She sells C shells down
by the seashore.
More information about the R-SIG-Finance
mailing list