plotEventsHistogram: Plot a histogram given event data.

Description Usage Arguments Author(s) Examples

View source: R/visualisation.R

Description

Convenience function for plotting event price and volume histograms. Will plot ask/bid bars side by side.

Usage

1
2
plotEventsHistogram(events, start.time = min(events$timestamp),
  end.time = max(events$timestamp), val = "volume", bw = NULL)

Arguments

events

Limit order events data.

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

 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)

obAnalytics documentation built on May 1, 2019, 7:04 p.m.