Learn R Programming

highfrequency (version 0.6.5)

getTradeDirection: Get trade direction

Description

Function returns a vector with the inferred trade direction which is determined using the Lee and Ready algorithym (Lee and Ready, 1991).

Usage

getTradeDirection(tqdata)

Arguments

tqdata

data.table or xts object, containing joined trades and quotes (e.g. using matchTradesQuotes)

Value

A vector which has values 1 or (-1) if the inferred trade direction is buy or sell respectively.

Details

NOTE: The value of the first (and second) observation of the output should be ignored if price == midpoint for the first (second) observation.

References

Lee, C. M. C. and M. J. Ready (1991). Inferring trade direction from intraday data. Journal of Finance 46, 733-746.

Examples

Run this code
# NOT RUN {
# generate matched trades and quote data set
tqdata <- matchTradesQuotes(sample_tdata, sample_qdata)
directions <- getTradeDirection(tqdata)
head(directions)

# }

Run the code above in your browser using DataLab