aggregateQuotes {highfrequency} | R Documentation |
Aggregate a data.table
or xts
object containing quote data
Description
Aggregate tick-by-tick quote data and return a data.table
or xts
object containing the aggregated quote data.
See sampleQData
for an example of the argument qData. This function accepts arbitrary number of symbols over an arbitrary number of days.
Usage
aggregateQuotes(
qData,
alignBy = "minutes",
alignPeriod = 5,
marketOpen = "09:30:00",
marketClose = "16:00:00",
tz = NULL
)
Arguments
qData |
|
alignBy |
character, indicating the time scale in which |
alignPeriod |
positive numeric, indicating the number of periods to aggregate over. E.g. to aggregate
based on a 5 minute frequency, set |
marketOpen |
the market opening time, by default: |
marketClose |
the market closing time, by default: |
tz |
fallback time zone used in case we we are unable to identify the timezone of the data, by default: |
Details
The output "BID" and "OFR" columns are constructed using previous tick aggregation.
The variables "BIDSIZ" and "OFRSIZ" are aggregated by taking the sum of the respective inputs over each interval.
The timestamps of the new time series are the closing times of the intervals.
Please note: Returned objects always contain the first observation (i.e. opening quotes,...).
Value
A data.table
or an xts
object containing the aggregated quote data.
Author(s)
Jonathan Cornelissen, Kris Boudt, Onno Kleen, and Emil Sjoerup.
Examples
# Aggregate quote data to the 30 second frequency
qDataAggregated <- aggregateQuotes(sampleQData, alignBy = "seconds", alignPeriod = 30)
qDataAggregated # Show the aggregated data