Hi Frank,

The data is from: http://finance.yahoo.com/q/op?s=SPY+Options

There is no trade date, or underlying, so you are correct in that you will
need to cbind this by hand. Note that the underlying close isn't valid
until the current close. The chains are updated in delayed time (15min
IIRC), so you aren't able to just get the exact matching price.  getQuote
would be closer, but likely not exactly right.  In addition, the 'trade
date' isn't really the date, it is the moment the server gets around to
sending you back the chains.

The result is a list of options, with a list per expiry of calls and puts.
 If you simply want to append a column that repeats the current time of
request, and current underlying value (all with be the same of course) you
can do an lapply.

It may be just much cleaner to attach an attribute to the list that has the
requested time, as well as whatever underlying prices you want to track.
 Keep each object independent of each other (each getOptionChain request)
and you can build up a history that way if you are inclined.

HTH
Jeff


On Mon, Jan 28, 2013 at 11:20 AM, Frank <frankm60606@gmail.com> wrote:

> I see that getOptionChain has calls, puts and sym available, but I do not
> see Trade Date or Underlying Settlement Price. Is that correct?
>
>
>
> I'm trying to add Trade Date and Underlying Settlement Price to the calls
> from getOptionChain. I add the Settlement Price correctly but I am unable
> to
> add the Trade Date. No error is produced but the Trade Date, which is the
> last column, populates with NA and a column heading of coredata(x). First
> few rows of file are first and code is second. Thanks in advance.
>
>
>
> Index Strike      Last  Chg   Bid   Ask   Vol   OI    SPY.Close
> coredata(x)
>
> 1     25    117.58      0     124.82      125.07      2     10    150.25
> NA
>
> 2     45    102.54      0     104.82      105.07      11    11    150.25
> NA
>
>
>
> library(quantmod)
>
>
>
> ##
>
> ## Get Option Chain from Yahoo
>
> ##
>
>
>
> sym<-"SPY"
>
> nsym<-nchar(sym)
>
> nsym
>
> from_date="2013-1-1"
>
> Stock<-getSymbols.yahoo(sym, from = from_date, src = "yahoo", verbose=TRUE,
> auto.assign=FALSE) Close<-Stock[nrow(Stock)] Trade_Date<-Close[,0]
> Underlying_Close<-Close[,4] Trade_Date Underlying_Close optExpire <-
> "2013-03"
>
> Options<-getOptionChain(sym, Exp=optExpire)
>
> ##print(Options$calls)
>
> file_name<-paste0(sym,optExpire,".csv",sep="")
>
> write.zoo(Options$calls, file = file_name, append = FALSE, quote = TRUE,
> sep
> = ",", col.names = TRUE)
>
>
>
> file_name<-paste0(sym,"_",optExpire,".csv",sep="")
>
> Options_Stock<-na.locf(merge(Options$calls,Underlying_Close,
> retside=c(TRUE,
> TRUE))) Options_Stock<-na.locf(merge(Options_Stock, Trade_Date,
> retside=c(TRUE, TRUE)))
>
>
>
> write.zoo(Options_Stock, file = file_name, append = FALSE, quote = TRUE,
> sep
> = ",", col.names = TRUE)
>
> quit()
>
>
>
>
>
>
>         [[alternative HTML version deleted]]
>
> _______________________________________________
> R-SIG-Finance@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-finance
> -- Subscriber-posting only. If you want to post, subscribe first.
> -- Also note that this is not the r-help list where general R questions
> should go.
>



-- 
Jeffrey Ryan
jeffrey.ryan@lemnica.com

www.lemnica.com

R/Finance 2013: Applied R in Finance
May 17, 18 Chicago, IL
www.RinFinance.com

	[[alternative HTML version deleted]]

