caprarn9
2012-Oct-12 18:01 UTC
[R] RTAQ - convert function: warning causes incorrect loading of data
Hello, I am closely following the RTAQ documentation in order to load my dataset into R, however I get this warning when running the convert function in the following way: convert(from="2010-11-01", to="2010-11-01",datasource=datasource, datadestination=datadestination,trades=T,quotes=T,ticker="BAC",dir=T, extention="csv", header=T, tradecolnames=c("SYMBOL", "DATE", "TIME", "PRICE", "SIZE", "G127", "CORR", "COND", "EX"), quotecolnames=c("SYMBOL", "DATE", "TIME", "BID", "OFR", "BIDSIZ", "OFRSIZ", "MODE", "EX")) The only warning returned is: In `[<-.factor`(`*tmp*`, is.na(tdata$G127), value = c(1L, 1L, 1L, : invalid factor level, NAs generated As it is a warning, the .RData files still get created and I can use TAQLoad to load them: x <- TAQLoad("BAC",from="2010-11-01",to="2010-11-01",datasource=datadestination, trades=T,quotes=T) The PROBLEM: head(x) SYMBOL EX PRICE SIZE COND CORR G127 <NA> "BAC" "B" "11.4900" " 500" "@" "0" "0" ... This is the same for the quotes objects, but different headers obviously. I get a <NA> instead of the expected YYY-MM-DD HH:MM:SS format for each observation. I've spent a fair number of hours on trying to get this right, no success. Can you please provide me with some guidance? Thank you. A sample from the CSV files I use: SYMBOL,DATE,TIME,BID,OFR,BIDSIZ,OFRSIZ,MODE,EX BAC,20101101,9:30:00,11.5,11.51,5,116,12,P ... SYMBOL,DATE,TIME,PRICE,SIZE,G127,CORR,COND,EX BAC,20101101,10:30:00,11.49,500,0,0,@,B ... -- View this message in context: http://r.789695.n4.nabble.com/RTAQ-convert-function-warning-causes-incorrect-loading-of-data-tp4646025.html Sent from the R help mailing list archive at Nabble.com.
R. Michael Weylandt
2012-Oct-12 20:52 UTC
[R] RTAQ - convert function: warning causes incorrect loading of data
I'm forwarding this to the R-SIG-Finance list, where ou'll have a more specialized audience. In the meanwhile, you may wish to look at http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example Finally, I note you're posting from Nabble. Please do include context in your reply -- I don't believe Nabble does this automatically, so you'll need to manually include it. Most of the regular respondents on these lists don't use Nabble -- it is a _mailing list_ after all -- so we don't get the forum view you do, only emails of the individual posts. Combine that with the high volume of posts, and it's quite difficult to trace a discussion if we all don't make sure to include context. Cheers, Michael On Fri, Oct 12, 2012 at 7:01 PM, caprarn9 <caprarn9 at cs.man.ac.uk> wrote:> Hello, > > I am closely following the RTAQ documentation in order to load my dataset > into R, however I get this warning when running the convert function in the > following way: > > convert(from="2010-11-01", to="2010-11-01",datasource=datasource, > datadestination=datadestination,trades=T,quotes=T,ticker="BAC",dir=T, > extention="csv", header=T, tradecolnames=c("SYMBOL", "DATE", "TIME", > "PRICE", "SIZE", "G127", "CORR", "COND", "EX"), quotecolnames=c("SYMBOL", > "DATE", "TIME", "BID", "OFR", "BIDSIZ", "OFRSIZ", "MODE", "EX")) > > The only warning returned is: > In `[<-.factor`(`*tmp*`, is.na(tdata$G127), value = c(1L, 1L, 1L, : > invalid factor level, NAs generated > > As it is a warning, the .RData files still get created and I can use TAQLoad > to load them: > > x <- > TAQLoad("BAC",from="2010-11-01",to="2010-11-01",datasource=datadestination, > trades=T,quotes=T) > > The PROBLEM: > head(x) > SYMBOL EX PRICE SIZE COND CORR G127 > <NA> "BAC" "B" "11.4900" " 500" "@" "0" "0" > ... > > This is the same for the quotes objects, but different headers obviously. I > get a <NA> instead of the expected YYY-MM-DD HH:MM:SS format for each > observation. > > I've spent a fair number of hours on trying to get this right, no success. > Can you please provide me with some guidance? > > Thank you. > > A sample from the CSV files I use: > > SYMBOL,DATE,TIME,BID,OFR,BIDSIZ,OFRSIZ,MODE,EX > BAC,20101101,9:30:00,11.5,11.51,5,116,12,P > ... > > SYMBOL,DATE,TIME,PRICE,SIZE,G127,CORR,COND,EX > BAC,20101101,10:30:00,11.49,500,0,0,@,B > ... > > > > > -- > View this message in context: http://r.789695.n4.nabble.com/RTAQ-convert-function-warning-causes-incorrect-loading-of-data-tp4646025.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help at r-project.org mailing list > 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.