Learn R Programming

highfrequency (version 0.5.3)

tradesCleanupFinal: Perform a final cleaning procedure on trade data

Description

Function performs cleaning procedure rmTradeOutliers for the trades of all stocks in "ticker" over the interval [from,to] and saves the result in "datadestination". Note that preferably the input data for this function is trade and quote data cleaned by respectively e.g. tradesCleanup and quotesCleanup.

Usage

tradesCleanupFinal(from,to,datasource,datadestination,ticker,
                    tdata,qdata,...)

Arguments

from

character indicating first date to clean, e.g. "2008-01-30".

to

character indicating last date to clean, e.g. "2008-01-31".

datasource

character indicating the folder in which the original data is stored.

datadestination

character indicating the folder in which the cleaned data is stored.

ticker

vector of tickers for which the data should be cleaned.

tdata

xts object containing (ONE day and for ONE stock only) trade data cleaned by tradesCleanup. This argument is NULL by default. Enabling it, means the arguments from, to, datasource and datadestination will be ignored. (only advisable for small chunks of data)

qdata

xts object containing (ONE day and for ONE stock only) cleaned quote data. This argument is NULL by default. Enabling it means the arguments from, to, datasource, datadestination will be ignored. (only advisable for small chunks of data)

...

additional arguments.

Value

For each day an xts object is saved into the folder of that date, containing the cleaned data. This procedure is performed for each stock in "ticker".

In case you supply the arguments "tdata" and "qdata", the on-disk functionality is ignored and the function returns a list with the cleaned trades as xts object (see examples).

References

Barndorff-Nielsen, O. E., P. R. Hansen, A. Lunde, and N. Shephard (2009). Realized kernels in practice: Trades and quotes. Econometrics Journal 12, C1-C32.

Brownlees, C.T. and Gallo, G.M. (2006). Financial econometric analysis at ultra-high frequency: Data handling concerns. Computational Statistics & Data Analysis, 51, pages 2232-2245.

Examples

Run this code
# NOT RUN {
#Consider you have raw trade data for 1 stock for 1 day 
#data("sample_qdata");    #load cleaned quote data
#data("sample_tdataraw"); #load raw trade data
#tdata_afterfirstcleaning = tradesCleanup(tdataraw=sample_tdataraw,
#exchange="N",report=FALSE);
#dim(tdata_afterfirstcleaning);
#tdata_afterfinalcleaning = tradesCleanupFinal(qdata=sample_qdata,
#tdata=tdata_afterfirstcleaning);
#dim(tdata_afterfinalcleaning);
#In case you have more data it is advised to use the on-disk functionality
#via "from","to","datasource",etc. arguments
# }

Run the code above in your browser using DataLab