Learn R Programming

highfrequency (version 0.5.3)

TAQLoad: Load trade or quote data into R

Description

Function to load the taq data into R. If only the trades (or quotes) should be loaded the function returns them directly as xts object. If both trades and quotes should be extracted, the function returns a list with two items named "trades" and "quotes" respectively.

The function assumes that the files are ordered in folders per day, and the folders contain: ticker_trades.RData or ticker_quotes.RData. In these files the xts object is stored. If you used the function convert, this shall be the case. Please find more information in the pdf documentation.

Usage

TAQLoad(tickers,from,to,trades=TRUE,quotes=FALSE,
          datasource=NULL,variables=NULL)

Arguments

tickers

the ticker(s) to be loaded. It is recommended that you use only 1 ticker as input in case of non-synchronic observations. For synchronic data a vector of tickers can be used.

from

first day to load e.g. "2008-01-30".

to

last day to load e.g. "2008-01-30".

trades

boolean, determines whether trades are extracted.

quotes

boolean, determines whether quotes are extracted.

datasource

path to folder in which the files are contained.

variables

a character (or character vector) containing the name(s) of the variable(s) that should be loaded, e.g. c("SYMBOL","PRICE"). By default all data is loaded.

Value

see section description

Examples

Run this code
# NOT RUN {
#In order for these examples to work, the folder datasource 
#should contain two folders named 2008-01-02 and 2008-01-03.
#These folder contain the files with the trade data,
#which are named "AAPL_trades.RData" or "AA_trades.RData".

from="2008-01-02";
to = "2008-01-03";
# }
# NOT RUN {
datasource="C:\data";
# }
# NOT RUN {
#TAQLoad: load data for stock AAPL
# }
# NOT RUN {
xx = TAQLoad(tickers="AAPL",from,to,trades=TRUE,quotes=FALSE,
datasource=datasource,variables=NULL)
# }
# NOT RUN {
#Load only price data for stocks AA and AAPL
# }
# NOT RUN {
xx = TAQLoad(tickers=c("AA","AAPL"),from,to,trades=TRUE,
quotes=FALSE,datasource=datasource,variables="PRICE")
# }

Run the code above in your browser using DataLab