matchTradesQuotes: Match trade and quote data

Description Usage Arguments Value Author(s) References Examples

View source: R/realized.R

Description

Function matches the trades and quotes and returns an xts-object containing both.

Usage

1
matchTradesQuotes(tdata,qdata,adjustment=2)

Arguments

tdata

xts-object containing the trade data.

qdata

xts-object containing the quote data.

adjustment

numeric, number of seconds the quotes are registered faster than the trades (should be round and positive). Based on the research of Vergote (2005), we set 2 seconds as the default.

Value

xts-object containing the matched trade and quote data

Author(s)

Jonathan Cornelissen and Kris Boudt

References

Vergote, O. (2005). How to match trades and quotes for NYSE stocks? K.U.Leuven working paper.

Examples

1
2
3
4
5
6
7
#load data samples
data("sample_tdata");
data("sample_qdata");
#match the trade and quote data
tqdata = matchTradesQuotes(sample_tdata,sample_qdata);
#have a look
head(tqdata);

Example output

Loading required package: xts
Loading required package: zoo

Attaching package: 'zoo'

The following objects are masked from 'package:base':

    as.Date, as.Date.numeric

                    SYMBOL EX  PRICE     SIZE   COND CORR G127 BID      BIDSIZ
2008-01-04 09:30:27 "XXX"  "N" "193.71"  "9100" "E"  "0"  "0"  "193.34" "4.5" 
2008-01-04 09:30:28 "XXX"  "N" "193.59"  "200"  "E"  "0"  "0"  "193.34" "4.5" 
2008-01-04 09:30:29 "XXX"  "N" "193.445" "200"  "E"  "0"  "0"  "193.25" "12.5"
2008-01-04 09:30:30 "XXX"  "N" "193.38"  "250"  "E"  "0"  "0"  "193.47" "0.5" 
2008-01-04 09:30:31 "XXX"  "N" "193.34"  "300"  "E"  "0"  "0"  "193.47" "0.5" 
2008-01-04 09:30:33 "XXX"  "N" "193.52"  "400"  "E"  "0"  "0"  "193.3"  "2.5" 
                    OFR      OFRSIZ MODE
2008-01-04 09:30:27 "193.89" "11.5" "12"
2008-01-04 09:30:28 "193.89" "11.5" "12"
2008-01-04 09:30:29 "193.81" "8.5"  "12"
2008-01-04 09:30:30 "193.63" "0.5"  "12"
2008-01-04 09:30:31 "193.63" "0.5"  "12"
2008-01-04 09:30:33 "193.64" "0.5"  "12"
Warning message:
timezone of object (GMT) is different than current timezone (). 

highfrequency documentation built on May 2, 2019, 6:09 p.m.