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]]
Dirk Eddelbuettel
2018-Mar-05 02:57 UTC
[R] Interpret List Label as Date from Quantmod getOptionChain
On 5 March 2018 at 02:46, Sparks, John wrote: | I agree that they look like dates, I don't know how to determine if they are actually dates. You know options but you are confused about maturity dates, i.e. expiry? In information in that list (ie along the date dimension) is the expiry; at each date you have another list for both puts and calls, and inside each of those a grid given by the active strikes (ie where bids/asks/trades happen). Dirk -- http://dirk.eddelbuettel.com | @eddelbuettel | edd at debian.org
Sparks, John
2018-Mar-05 03:13 UTC
[R] Interpret List Label as Date from Quantmod getOptionChain
Hi Dirk, Thanks for your note. I understand that expiry dates are the dates that the option expires, so I don't think that I am confused about that (although the upper limits of one's confusion is difficult to accurately estimate). My lack of clarity come from treating those "dates" as actual dates as opposed to strings, which one could reasonably interpret them to be from their appearance, yet the str() lists them in date order, not alphabetical order. So if I execute library(quantmod) #in fairness, I did not include this last time and my example was therefore not reproducible. Apologies to Bert and everyone else #for not following the posting guidelines. aapl_total<-getOptionChain("AAPL", NULL) How could I then get the subset of the entire list which only has expiry dates in 2019, or more specifically, in Mar or Apr or May of 2019? Guidance (that is not too burdensome) would be appreciated. --JJS ________________________________ From: Dirk Eddelbuettel <dirk.eddelbuettel at gmail.com> on behalf of Dirk Eddelbuettel <edd at debian.org> Sent: Sunday, March 4, 2018 8:57 PM To: Sparks, John Cc: Bert Gunter; r-help at r-project.org Subject: Re: [R] Interpret List Label as Date from Quantmod getOptionChain On 5 March 2018 at 02:46, Sparks, John wrote: | I agree that they look like dates, I don't know how to determine if they are actually dates. You know options but you are confused about maturity dates, i.e. expiry? In information in that list (ie along the date dimension) is the expiry; at each date you have another list for both puts and calls, and inside each of those a grid given by the active strikes (ie where bids/asks/trades happen). Dirk -- http://dirk.eddelbuettel.com | @eddelbuettel | edd at debian.org Dirk Eddelbuettel<http://dirk.eddelbuettel.com/> dirk.eddelbuettel.com Welcome. I contribute to several open source efforts, mostly Debian and R. Besides looking after a number of Debian packages, I ... [[alternative HTML version deleted]]
Reasonably Related 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
- Interpret List Label as Date from Quantmod getOptionChain