[Blotter-commits] r600 - in pkg/RTAQ: R man

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Fri May 6 15:59:44 CEST 2011


Author: jonathan
Date: 2011-05-06 15:59:44 +0200 (Fri, 06 May 2011)
New Revision: 600

Modified:
   pkg/RTAQ/R/convert_to_RData.R
   pkg/RTAQ/man/convert.Rd
Log:
bugfix reported by Bj?\195?\182rn Hagstr?\195?\182mer

Modified: pkg/RTAQ/R/convert_to_RData.R
===================================================================
--- pkg/RTAQ/R/convert_to_RData.R	2011-04-28 14:57:19 UTC (rev 599)
+++ pkg/RTAQ/R/convert_to_RData.R	2011-05-06 13:59:44 UTC (rev 600)
@@ -50,6 +50,7 @@
   }
 }
 
+
 convert_trades = function (datasource, datadestination, ticker, extention = "txt", 
     header = FALSE, tradecolnames = NULL, format = "%Y%M%D %H:%M:%S") 
 {  
@@ -57,7 +58,7 @@
    
     suppressWarnings(dir.create(datadestination));
     suppressWarnings(dir.create(datasource));
-    
+
     setwd(datasource)
     adjtime = function(z) {
         zz = unlist(strsplit(z, ":"))
@@ -70,8 +71,9 @@
     for (i in 1:length(ticker)) {
         tfile_name = paste(datasource, "/", ticker[i], "_trades", 
             sep = "")
-        tdata = try(readdata(path = tfile_name, extention = extention, 
+        tdata = try(RTAQ:::readdata(path = tfile_name, extention = extention, 
             header = header, dims = 9), silent = TRUE)
+
         error = dim(tdata)[1] == 0
         if (error) {
             print(paste("no trades for stock", ticker[i]))
@@ -95,7 +97,8 @@
             oldtime = as.matrix(as.vector(tdata$TIME))
             newtime = apply(oldtime, 1, adjtime)
             tdata$TIME = newtime
-            rm(oldtime, newtime)
+            rm(oldtime, newtime);
+
             tdobject = timeDate:::timeDate(paste(as.vector(tdata$DATE), 
                 as.vector(tdata$TIME)), format = format, FinCenter = "GMT", 
                 zone = "GMT")
@@ -152,6 +155,9 @@
             newtime = apply(oldtime, 1, adjtime)
             qdata$TIME = newtime
             rm(oldtime, newtime)
+
+#            if(year == 1993){qdata = qdata[sort(qdata[,4], index.return = TRUE)$ix,]}
+
             test = paste(as.vector(qdata$DATE), as.vector(qdata$TIME))
             tdobject = timeDate:::timeDate(test, format = format, FinCenter = "GMT", 
                 zone = "GMT")

Modified: pkg/RTAQ/man/convert.Rd
===================================================================
--- pkg/RTAQ/man/convert.Rd	2011-04-28 14:57:19 UTC (rev 599)
+++ pkg/RTAQ/man/convert.Rd	2011-05-06 13:59:44 UTC (rev 600)
@@ -56,7 +56,8 @@
 convert(from,to,datasource,datadestination,trades=TRUE,
           quotes=FALSE,ticker=c("AA","AAPL"),dir=FALSE,extention="txt",
           header=FALSE,tradecolnames=NULL,quotecolnames=NULL,
-          format="%m/%d/%Y %H:%M:%S")
+          format="\%Y\%m\%d \%H:\%M:\%S");
+
 #Now, the folder datadestination will contain two folders
 #named 2008-01-02 and 2008-01-03 containing 
 #the files AAPL_trades.RData and AAPL_trades.RData containing the trades.



More information about the Blotter-commits mailing list