Description Usage Arguments Author(s) Examples
View source: R/visualisation.R
Convenience function for plotting event price and volume histograms. Will plot ask/bid bars side by side.
1 2 |
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.) |
phil
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | # 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)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.