[Blotter-commits] r589 - in pkg/RTAQ: . R data man src

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Thu Apr 7 19:29:19 CEST 2011


Author: jonathan
Date: 2011-04-07 19:29:18 +0200 (Thu, 07 Apr 2011)
New Revision: 589

Added:
   pkg/RTAQ/man/medianN.Rd
   pkg/RTAQ/man/previoustick.Rd
   pkg/RTAQ/man/sample_real5minprices.Rd
   pkg/RTAQ/man/sumN.Rd
Modified:
   pkg/RTAQ/DESCRIPTION
   pkg/RTAQ/NAMESPACE
   pkg/RTAQ/R/aggregate.R
   pkg/RTAQ/R/cleanupfunctions.R
   pkg/RTAQ/R/convert_to_RData.R
   pkg/RTAQ/R/manipulation.R
   pkg/RTAQ/data/sample_real5minprices.RData
   pkg/RTAQ/man/sample_5minprices.Rd
   pkg/RTAQ/man/sample_qdata.Rd
   pkg/RTAQ/man/sample_tdata.Rd
   pkg/RTAQ/man/spotVol.rd
   pkg/RTAQ/man/tqLiquidity.Rd
   pkg/RTAQ/src/rtaq.c
Log:
"warning"-free version, and bugfix tqLiquidity

Modified: pkg/RTAQ/DESCRIPTION
===================================================================
--- pkg/RTAQ/DESCRIPTION	2011-03-31 14:24:31 UTC (rev 588)
+++ pkg/RTAQ/DESCRIPTION	2011-04-07 17:29:18 UTC (rev 589)
@@ -6,6 +6,6 @@
 Maintainer: Jonathan Cornelissen <Jonathan.cornelissen at econ.kuleuven.be>
 Description: The Trades and Quotes data of the New York Stock Exchange is a popular input for the implementation of intraday trading strategies, the measurement of liquidity and volatility and investigation of the market microstructure, among others. This package contains a collection of R functions to carefully clean and match the trades and quotes data, calculate ex post liquidity and volatility measures and detect price jumps in the data.
 Depends: xts, timeDate
-Suggests: realized, robustbase, cubature, mvtnorm
+Suggests: realized, robustbase, cubature, mvtnorm, chron
 License: GPL
 LazyLoad: yes
\ No newline at end of file

Modified: pkg/RTAQ/NAMESPACE
===================================================================
--- pkg/RTAQ/NAMESPACE	2011-03-31 14:24:31 UTC (rev 588)
+++ pkg/RTAQ/NAMESPACE	2011-04-07 17:29:18 UTC (rev 589)
@@ -62,9 +62,9 @@
 #tspread, pts, p_return_sqr, p_return_abs, qs, pqs,  
 #logqs, logsize, qslope, logqslope, mq_return_sqr, mq_return_abs,
 #rest :
-spotVol, 
-sumN,                       #TODO with match.fun!!
-previoustick,                #TODO with match.fun!!
+spotVol,
+sumN,                       #previously included...
+previoustick,               #idem
 medianN                     #idem
 )
 

Modified: pkg/RTAQ/R/aggregate.R
===================================================================
--- pkg/RTAQ/R/aggregate.R	2011-03-31 14:24:31 UTC (rev 588)
+++ pkg/RTAQ/R/aggregate.R	2011-04-07 17:29:18 UTC (rev 589)
@@ -21,8 +21,6 @@
     reclass(xx, x[INDEX])
 }
 
-
-
 ## AGGREGATION;
 aggregatets = function (ts, FUN = "previoustick", on = "minutes", k = 1, weights = NULL,dropna=FALSE) 
 {
@@ -113,6 +111,7 @@
 
 aggregatePrice = function (ts, FUN = "previoustick", on = "minutes", k = 1,marketopen="09:30:00",marketclose = "16:00:00") 
 {
+
     ts = dataformatc(ts)
     ts2 = aggregatets(ts, FUN = FUN, on, k)
     date = strsplit(as.character(index(ts)), " ")[[1]][1]
@@ -135,6 +134,7 @@
 #VOLUME: (specificity: always sum)
 agg_volume= function(ts, FUN = "sumN", on = "minutes", k = 5, includeopen = FALSE,marketopen="09:30:00",marketclose="16:00:00") 
 {
+
     ts = dataformatc(ts)
     if (!includeopen) {
         ts3 = aggregatets(ts, FUN = FUN, on, k)

Modified: pkg/RTAQ/R/cleanupfunctions.R
===================================================================
--- pkg/RTAQ/R/cleanupfunctions.R	2011-03-31 14:24:31 UTC (rev 588)
+++ pkg/RTAQ/R/cleanupfunctions.R	2011-04-07 17:29:18 UTC (rev 589)
@@ -25,11 +25,11 @@
   gettime = function(z){unlist(strsplit(as.character(z)," "))[2]};
   times1 = as.matrix(as.vector(as.character(index(data))));
   times = apply(times1,1,gettime); 
-  tdtimes = timeDate(times,format = "%H:%M:%S",FinCenter = "GMT",zone="GMT");
+  tdtimes = timeDate:::timeDate(times,format = "%H:%M:%S",FinCenter = "GMT",zone="GMT");
 
   #create timeDate begin and end
-  tddaybegin = timeDate(daybegin,format = "%H:%M:%S",FinCenter = "GMT",zone="GMT");
-  tddayend = timeDate(dayend,format = "%H:%M:%S",FinCenter = "GMT",zone="GMT");
+  tddaybegin = timeDate:::timeDate(daybegin,format = "%H:%M:%S",FinCenter = "GMT",zone="GMT");
+  tddayend = timeDate:::timeDate(dayend,format = "%H:%M:%S",FinCenter = "GMT",zone="GMT");
 
   #select correct observations
   filteredts = data[tdtimes>=tddaybegin & tdtimes<=tddayend];

Modified: pkg/RTAQ/R/convert_to_RData.R
===================================================================
--- pkg/RTAQ/R/convert_to_RData.R	2011-03-31 14:24:31 UTC (rev 588)
+++ pkg/RTAQ/R/convert_to_RData.R	2011-04-07 17:29:18 UTC (rev 589)
@@ -96,7 +96,7 @@
             newtime = apply(oldtime, 1, adjtime)
             tdata$TIME = newtime
             rm(oldtime, newtime)
-            tdobject = timeDate(paste(as.vector(tdata$DATE), 
+            tdobject = timeDate:::timeDate(paste(as.vector(tdata$DATE), 
                 as.vector(tdata$TIME)), format = format, FinCenter = "GMT", 
                 zone = "GMT")
             tdata = xts(tdata, order.by = tdobject)
@@ -153,9 +153,9 @@
             qdata$TIME = newtime
             rm(oldtime, newtime)
             test = paste(as.vector(qdata$DATE), as.vector(qdata$TIME))
-            tdobject = timeDate(test, format = format, FinCenter = "GMT", 
+            tdobject = timeDate:::timeDate(test, format = format, FinCenter = "GMT", 
                 zone = "GMT")
-            tdobject = timeDate(test, format = format, FinCenter = "GMT", 
+            tdobject = timeDate:::timeDate(test, format = format, FinCenter = "GMT", 
                 zone = "GMT")
             qdata = xts(qdata, order.by = tdobject)
             qdata = qdata[, c("SYMBOL", "EX", "BID", "BIDSIZ", 

Modified: pkg/RTAQ/R/manipulation.R
===================================================================
--- pkg/RTAQ/R/manipulation.R	2011-03-31 14:24:31 UTC (rev 588)
+++ pkg/RTAQ/R/manipulation.R	2011-04-07 17:29:18 UTC (rev 589)
@@ -107,8 +107,8 @@
   merged[,((tt+1):dim(merged)[2])] = na.locf(as.zoo(merged[,((tt+1):dim(merged)[2])]), na.rm=FALSE);
 
   #Select trades:
-  index(tdata)=as.POSIXct(index(tdata));
-  index(merged)=as.POSIXct(index(merged));  
+  index(tdata)=  as.POSIXct(index(tdata));
+  index(merged)= as.POSIXct(index(merged));  
   merged = merged[index(tdata)];
 
   #return useful parts:
@@ -296,7 +296,7 @@
   offer = as.numeric(data$OFR);
   midpoints = (bid + offer)/2;
 
-  pes = 100*es/midpoints
+  pes = es/midpoints
   pes_xts = xts(pes,order.by=index(data));
   return(pes_xts);
 }
@@ -308,7 +308,7 @@
   bid = as.numeric(data$BID);
   offer = as.numeric(data$OFR);
   midpoints = (bid + offer)/2;
-  prs = 100*rs/midpoints
+  prs = rs/midpoints
   prs_xts = xts(prs,order.by=index(data));
   return(prs_xts);
 }
@@ -333,7 +333,7 @@
   offer = as.numeric(data$OFR);
   midpoints = (bid + offer)/2;
 
-  prop_pi = (100*(es-rs)/2)/midpoints;
+  prop_pi = ((es-rs)/2)/midpoints;
   prop_pi_xts = xts(prop_pi,order.by=index(data));
   return(prop_pi_xts);
 }
@@ -394,7 +394,7 @@
   offer = as.numeric(data$OFR);
   midpoints = (bid + offer)/2;
   qs = offer-bid;
-  pqs = 100*qs/midpoints;
+  pqs = qs/midpoints;
 
   pqs_xts = xts(pqs,order.by=index(data));
   return(pqs_xts);

Modified: pkg/RTAQ/data/sample_real5minprices.RData
===================================================================
(Binary files differ)

Added: pkg/RTAQ/man/medianN.Rd
===================================================================
--- pkg/RTAQ/man/medianN.Rd	                        (rev 0)
+++ pkg/RTAQ/man/medianN.Rd	2011-04-07 17:29:18 UTC (rev 589)
@@ -0,0 +1,9 @@
+\name{medianN}
+\Rdversion{1.1}
+\alias{medianN}
+\title{
+medianN (internal function)
+}
+\description{
+See \code{\link{aggregatets}}.
+}

Added: pkg/RTAQ/man/previoustick.Rd
===================================================================
--- pkg/RTAQ/man/previoustick.Rd	                        (rev 0)
+++ pkg/RTAQ/man/previoustick.Rd	2011-04-07 17:29:18 UTC (rev 589)
@@ -0,0 +1,9 @@
+\name{previoustick}
+\Rdversion{1.1}
+\alias{previoustick}
+\title{
+previoustick (internal function)
+}
+\description{
+See \code{\link{aggregatets}}.
+}

Modified: pkg/RTAQ/man/sample_5minprices.Rd
===================================================================
--- pkg/RTAQ/man/sample_5minprices.Rd	2011-03-31 14:24:31 UTC (rev 588)
+++ pkg/RTAQ/man/sample_5minprices.Rd	2011-04-07 17:29:18 UTC (rev 589)
@@ -22,4 +22,4 @@
 Multivariate realised kernels: consistent positive semi-definite
 estimators of the covariation of equity prices with noise and non-synchronous
 trading. Journal of Econometrics, forthcoming.}
-\keyword{datasets}
\ No newline at end of file
+\keyword{datasets}          
\ No newline at end of file

Modified: pkg/RTAQ/man/sample_qdata.Rd
===================================================================
--- pkg/RTAQ/man/sample_qdata.Rd	2011-03-31 14:24:31 UTC (rev 588)
+++ pkg/RTAQ/man/sample_qdata.Rd	2011-04-07 17:29:18 UTC (rev 589)
@@ -3,7 +3,7 @@
 \alias{sample_qdata}
 \title{Sample of cleaned quotes for stock XXX for 1 day}
 \description{
-An imaginary xts object containing the raw quotes for stock XXX for 1 day, in the typical NYSE TAQ database format.
+An xts object containing the raw quotes for the imaginary stock XXX for 1 day, in the typical NYSE TAQ database format.
 This is the cleaned version of the data sample \code{\link{sample_qdataraw}}, using \code{\link{quotesCleanup}}.
 }
 \usage{data("sample_qdata")}

Added: pkg/RTAQ/man/sample_real5minprices.Rd
===================================================================
--- pkg/RTAQ/man/sample_real5minprices.Rd	                        (rev 0)
+++ pkg/RTAQ/man/sample_real5minprices.Rd	2011-04-07 17:29:18 UTC (rev 589)
@@ -0,0 +1,11 @@
+\name{sample_real5minprices}
+\docType{data}
+\alias{sample_real5minprices}
+\title{Sample of imaginary price data for 61 days}
+\description{
+An xts object containing the 5-min aggregated imaginary price series for the trading
+ days between 2005-03-04 and 2005-06-01.
+ }
+\usage{data("sample_real5minprices")}
+\format{xts object}
+\keyword{datasets}
\ No newline at end of file

Modified: pkg/RTAQ/man/sample_tdata.Rd
===================================================================
--- pkg/RTAQ/man/sample_tdata.Rd	2011-03-31 14:24:31 UTC (rev 588)
+++ pkg/RTAQ/man/sample_tdata.Rd	2011-04-07 17:29:18 UTC (rev 589)
@@ -3,7 +3,7 @@
 \alias{sample_tdata}
 \title{Sample of cleaned trades for stock XXX for 1 day}
 \description{
-An imaginary xts object containing the trades for stock XXX for 1 day, in the typical NYSE TAQ database format.
+An xts object containing the trades for the imaginary stock XXX for 1 day, in the typical NYSE TAQ database format.
 This is the cleaned version of the data sample \code{\link{sample_tdataraw}}, using \code{\link{tradesCleanup}}.
 }
 \usage{data("sample_tdata")}

Modified: pkg/RTAQ/man/spotVol.rd
===================================================================
--- pkg/RTAQ/man/spotVol.rd	2011-03-31 14:24:31 UTC (rev 588)
+++ pkg/RTAQ/man/spotVol.rd	2011-04-07 17:29:18 UTC (rev 589)
@@ -51,8 +51,6 @@
 the daily volatility factor and, finally, the fourth column is the periodic component. 
 }
 
-
-
 \references{
 Andersen, T. G. and T. Bollerslev (1997). Intraday periodicity and volatility persistence in financial markets. 
 Journal of Empirical Finance 4, 115-158.
@@ -75,13 +73,14 @@
 data("sample_real5minprices");
 
 #compute and plot intraday periodicity
-out = spotVol(price,P1=6,P2=4,periodicvol="TML",k=5, dummies=FALSE);
+out = spotVol(sample_real5minprices,P1=6,P2=4,periodicvol="TML",k=5, 
+dummies=FALSE);
 head(out);
 }
 
-\keyword{ volatility}
+\keyword{volatility}
 
-\author{ Jonathan Cornelissen and Kris Boudt}
+\author{Jonathan Cornelissen and Kris Boudt}
 
 %cd C:\package\TradeAnalytics\pkg\RTAQ\man
 %R CMD Rdconv --type=html --output=sample_5minprices.htm sample_5minprices.Rd

Added: pkg/RTAQ/man/sumN.Rd
===================================================================
--- pkg/RTAQ/man/sumN.Rd	                        (rev 0)
+++ pkg/RTAQ/man/sumN.Rd	2011-04-07 17:29:18 UTC (rev 589)
@@ -0,0 +1,9 @@
+\name{sumN}
+\Rdversion{1.1}
+\alias{sumN}
+\title{
+sumN (internal function)
+}
+\description{
+See \code{\link{aggregatets}}.
+}

Modified: pkg/RTAQ/man/tqLiquidity.Rd
===================================================================
--- pkg/RTAQ/man/tqLiquidity.Rd	2011-03-31 14:24:31 UTC (rev 588)
+++ pkg/RTAQ/man/tqLiquidity.Rd	2011-04-07 17:29:18 UTC (rev 589)
@@ -106,7 +106,7 @@
  
 \item{prop_price_impact: proportional price impact}{
 \deqn{
-\mbox{proportional price impact}_t =  \frac{100*\frac{(\mbox{effective spread}_t - \mbox{realized spread}_t)}{2}}{\frac{\mbox{OFR}_{t}+\mbox{BID}_{t}}{2}}
+\mbox{proportional price impact}_t =  \frac{\frac{(\mbox{effective spread}_t - \mbox{realized spread}_t)}{2}}{\frac{\mbox{OFR}_{t}+\mbox{BID}_{t}}{2}}
 }
 (Venkataraman, 2001).
 Note that the input of this function consists of the matched trades and

Modified: pkg/RTAQ/src/rtaq.c
===================================================================
--- pkg/RTAQ/src/rtaq.c	2011-03-31 14:24:31 UTC (rev 588)
+++ pkg/RTAQ/src/rtaq.c	2011-04-07 17:29:18 UTC (rev 589)
@@ -1,54 +1,54 @@
-#include <stdio.h>
-#include <stdlib.h>
-
-int nsmaller(int *times, int *lengths, int start, int end, int max)
-{
-int i=0;
-while ( (i < (lengths[end] - lengths[start])) && (*(times+ (lengths[start]+i)) <= max)){
-i++;
-}
-return i;
-}
-
-void refreshpoints( int *times, int *lengths, int *ttau, int *dim, int *aa, int *indices, int *lindex){
-  //my first C program, so probably improvable..
-  //length start with all starting points: from zero and upto last endpoint +1
-  // getting variables declared
-int  t_max=0, i, j,a,b;;
-int condition = 1;
-int Ntau[*dim];
-int tnext[*dim];
-  //int xx tau[*lindex];
-  // getting starting values before looping
- *ttau = 0;
- for(i = 0; i<*dim ; i++){
-     if( *ttau < *(times + lengths[i]) )
-     { *ttau = *(times + lengths[i] ); }
-     }
-
- for(i = 0; i < *dim; i++){
-    Ntau[i] = nsmaller(times, lengths, i, (i+1), *ttau);
-    *(indices + i * (*lindex))  = Ntau[i];}
- j=0;
- // start the loop over all observations
-while( condition >= 1 ){
-
- for(i = 0; i<*dim; i++){
-    tnext[i] = *(times + Ntau[i] + lengths[i]);
-    if( tnext[i] > t_max ){ t_max = tnext[i]; }
-    }
-    j++;
-    *(ttau+j) = t_max;
- for(i = 0; i<*dim; i++){
-    Ntau[i] = nsmaller(times, lengths, i, (i+1), *(ttau+j));
-    *(indices + i* (*lindex) + j)  = Ntau[i];
-    a = lengths[i+1];
-    b =  (Ntau[i] + lengths[i]);
-    if( a <= b ){ condition = 0; }
-    }
-    t_max = 0;
-
- }
- *aa = j+1;
-}
-
+#include <stdio.h>
+#include <stdlib.h>
+
+int nsmaller(int *times, int *lengths, int start, int end, int max)
+{
+int i=0;
+while ( (i < (lengths[end] - lengths[start])) && (*(times+ (lengths[start]+i)) <= max)){
+i++;
+}
+return i;
+}
+
+void refreshpoints( int *times, int *lengths, int *ttau, int *dim, int *aa, int *indices, int *lindex){
+  //my first C program, so probably improvable..
+  //length start with all starting points: from zero and upto last endpoint +1
+  // getting variables declared
+int  t_max=0, i, j,a,b;;
+int condition = 1;
+int Ntau[*dim];
+int tnext[*dim];
+  //int xx tau[*lindex];
+  // getting starting values before looping
+ *ttau = 0;
+ for(i = 0; i<*dim ; i++){
+     if( *ttau < *(times + lengths[i]) )
+     { *ttau = *(times + lengths[i] ); }
+     }
+
+ for(i = 0; i < *dim; i++){
+    Ntau[i] = nsmaller(times, lengths, i, (i+1), *ttau);
+    *(indices + i * (*lindex))  = Ntau[i];}
+ j=0;
+ // start the loop over all observations
+while( condition >= 1 ){
+
+ for(i = 0; i<*dim; i++){
+    tnext[i] = *(times + Ntau[i] + lengths[i]);
+    if( tnext[i] > t_max ){ t_max = tnext[i]; }
+    }
+    j++;
+    *(ttau+j) = t_max;
+ for(i = 0; i<*dim; i++){
+    Ntau[i] = nsmaller(times, lengths, i, (i+1), *(ttau+j));
+    *(indices + i* (*lindex) + j)  = Ntau[i];
+    a = lengths[i+1];
+    b =  (Ntau[i] + lengths[i]);
+    if( a <= b ){ condition = 0; }
+    }
+    t_max = 0;
+
+ }
+ *aa = j+1;
+}
+



More information about the Blotter-commits mailing list