plotEventsHistogram {obAnalytics} | R Documentation |
Plot a histogram given event data.
Description
Convenience function for plotting event price and volume histograms. Will plot ask/bid bars side by side.
Usage
plotEventsHistogram(events, start.time = min(events$timestamp),
end.time = max(events$timestamp), val = "volume", bw = NULL)
Arguments
events |
Limit order |
start.time |
Include event data >= this time. |
end.time |
Include event data <= this time. |
val |
"volume" or "price". |
bw |
Bar width (for price, 0.5 = 50 cent buckets.) |
Author(s)
phil
Examples
# necessary columns from event data.
events <- lob.data$events[, c("timestamp", "direction", "price", "volume")]
# re-scale volume (if needed)
events$volume <- events$volume * 10^-8
# histogram of all volume aggregated into 5 unit buckets.
plotEventsHistogram(events[events$volume < 50, ], val="volume", bw=5)
# histogram of 99% of limit prices during a 1 hour time frame.
# bar width set to 0.25: counts are aggregated into 25 cent buckets.
plotEventsHistogram(events[events$price <= quantile(events$price, 0.99)
& events$price >= quantile(events$price, 0.01), ],
start.time=as.POSIXct("2015-05-01 02:15:00.000", tz="UTC"),
end.time=as.POSIXct("2015-05-01 03:15:00.000", tz="UTC"),
val="price", bw=0.25)
[Package obAnalytics version 0.1.1 Index]