Description Usage Arguments Value Details Author(s) Examples
Function returns an xts object containing the aggregated trade data with columns "SYMBOL", "EX", "PRICE", "SIZE".
See sample_tdata
for an example of the argument tdata.
1 | aggregateTrades(tdata,on="minutes",k=5,marketopen,marketclose)
|
tdata |
xts object to be aggregated, containing the intraday trade data of a stock for one day. |
on |
character, indicating the time scale in which "k" is expressed. Possible values are: "secs", "seconds", "mins", "minutes","hours". |
k |
positive integer, indicating the number of periods to aggregate over. E.g. to aggregate a xts object to the 5 minute frequency set k=5 and on="minutes". |
marketopen |
the market opening time, by default: marketopen= "09:30:00". |
marketclose |
the market closing time, by default: marketclose = "16:00:00". |
An xts object containing the aggregated trade data.
The output "PRICE" column is constructed using previous tick aggregation.
The variable "SIZE" is aggregated by taking the sum over each interval.
For the variables "SYMBOL" and "EX" aggregation doesn't really make sense, thus the first value of the input is taken as the value for the complete output.
Columns "COND", "CORR", "G127" are dropped because aggregating them makes absolutely no sense.
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 price,...).
Please input an object containing ONE day of data.
Jonathan Cornelissen and Kris Boudt
1 2 3 4 | data("sample_tdata");
#aggregate trade data to 5 minute frequency
x = aggregateTrades(sample_tdata,on="minutes",k=5)
head(x);
|
Loading required package: xts
Loading required package: zoo
Attaching package: 'zoo'
The following objects are masked from 'package:base':
as.Date, as.Date.numeric
Warning message:
In c.xts(b, ts2) : mismatched types: converting objects to numeric
SYMBOL EX PRICE SIZE
2008-01-04 09:30:00 "XXX" "N" "193.710" " 9100"
2008-01-04 09:35:00 "XXX" "N" "193.920" " 65450"
2008-01-04 09:40:00 "XXX" "N" "194.630" " 50100"
2008-01-04 09:45:00 "XXX" "N" "193.520" " 52250"
2008-01-04 09:50:00 "XXX" "N" "192.850" " 43500"
2008-01-04 09:55:00 "XXX" "N" "190.795" " 63500"
Warning message:
timezone of object (GMT) is different than current timezone ().
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.