Sparks, John
2018-Mar-05 02:28 UTC
[R] Interpret List Label as Date from Quantmod getOptionChain
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]]
Bert Gunter
2018-Mar-05 02:38 UTC
[R] Interpret List Label as Date from Quantmod getOptionChain
Package? The **names** of the top levels of your lists, "Mar.09.2018", "Mar.23.2018" certainly look like dates and if they are -- I have no idea what package/context is -- they certainly could be formatted as such. See e.g. "date-time" . There are also several package that provide date tools. Cheers, Bert Bert Gunter "The trouble with having an open mind is that people keep coming along and sticking things into it." -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip ) On Sun, Mar 4, 2018 at 6:28 PM, Sparks, John <jspark4 at uic.edu> wrote:> 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]] > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/ > posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >[[alternative HTML version deleted]]
Sparks, John
2018-Mar-05 02:46 UTC
[R] Interpret List Label as Date from Quantmod getOptionChain
Package? Quantmod. In the subject line. I agree that they look like dates, I don't know how to determine if they are actually dates. Josh Ulrich usually answers questions along these lines very informatively and quickly. One reasonable course of action is to wait to see if he does the same with this one. --JJS ________________________________ From: Bert Gunter <bgunter.4567 at gmail.com> Sent: Sunday, March 4, 2018 8:38 PM To: Sparks, John Cc: r-help at r-project.org Subject: Re: [R] Interpret List Label as Date from Quantmod getOptionChain Package? The **names** of the top levels of your lists, "Mar.09.2018", "Mar.23.2018" certainly look like dates and if they are -- I have no idea what package/context is -- they certainly could be formatted as such. See e.g. "date-time" . There are also several package that provide date tools. Cheers, Bert Bert Gunter "The trouble with having an open mind is that people keep coming along and sticking things into it." -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip ) On Sun, Mar 4, 2018 at 6:28 PM, Sparks, John <jspark4 at uic.edu<mailto:jspark4 at uic.edu>> wrote: 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]] ______________________________________________ R-help at r-project.org<mailto:R-help at r-project.org> mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help R-help -- Main R Mailing List: Primary help - Homepage - SfS<https://stat.ethz.ch/mailman/listinfo/r-help> stat.ethz.ch The main R mailing list, for announcements about the development of R and the availability of new code, questions and answers about problems and solutions using R ... PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]]
Seemingly Similar Threads
- Interpret List Label as Date from Quantmod getOptionChain
- Interpret List Label as Date from Quantmod getOptionChain
- Interpret List Label as Date from Quantmod getOptionChain
- Interpret List Label as Date from Quantmod getOptionChain
- quantmod getOptionChain Interpret List Label As Date