[R] quantmod getOptionChain Interpret List Label As Date
John Sparks
JohnSparks at msn.com
Mon Mar 5 03:14:43 CET 2018
Hi R Helpers,
Is it possible to interpret the top level of the list as a date after downloading all the option chain data for a ticker?
For example, after I run
aapl_total<-getOptionChain("AAPL", NULL)
the top descriptor of the lists is a date (Mar.09.2018, Mar.23.2018, etc.).
So if want to subset down to those parts of the list that correspond to say, (expiration) year=2019; or say, Mar or Apr or May of 2019, is this possible?
Guidance would be appreciated.
Thanks.
--John J. Sparks, Ph.D.
str(aapl_total)
List of 16
$ Mar.09.2018:List of 2
..$ calls:'data.frame': 31 obs. of 7 variables:
.. ..$ Strike: num [1:31] 135 143 146 147 148 ...
.. ..$ Last : num [1:31] 42.4 36.2 32 28.4 31 ...
.. ..$ Chg : num [1:31] 0 0 12.6 -4.71 0 ...
.. ..$ Bid : num [1:31] 41 35.8 32.8 29.1 28.1 ...
.. ..$ Ask : num [1:31] 41.5 36.4 33.4 29.5 28.6 ...
.. ..$ Vol : int [1:31] 5 2 1 45 2 2 90 3 11 129 ...
.. ..$ OI : int [1:31] 17 0 117 58 3 22 171 84 707 238 ...
..$ puts :'data.frame': 37 obs. of 7 variables:
.. ..$ Strike: num [1:37] 130 135 138 139 140 141 142 143 144 145 ...
.. ..$ Last : num [1:37] 0.01 0.07 0.27 0.04 0.03 0.98 0.05 0.03 0.03 0.01 ...
.. ..$ Chg : num [1:37] 0 -0.12 0 0 0 0 -0.05 0 0 -0.01 ...
.. ..$ Bid : num [1:37] 0 0.01 0 0 0 0.05 0.06 0 0 0 ...
.. ..$ Ask : num [1:37] 0.04 0.07 0.02 0.03 0.02 0.13 0.13 0.03 0.03 0.02 ...
.. ..$ Vol : int [1:37] 2 11 1 10 5 0 1 150 1 127 ...
.. ..$ OI : int [1:37] 8 12 1 0 723 192 37 275 125 297 ...
$ Mar.23.2018:List of 2
..$ calls:'data.frame': 35 obs. of 7 variables:
[[alternative HTML version deleted]]
More information about the R-help
mailing list