filterDepth: Filter price level volume.

Description Usage Arguments Details Value Author(s) Examples

View source: R/depth.R

Description

Given depth data calculated by priceLevelVolume, filter between a specified time range. The resulting data will contain price level volume which is active only within the specified time range.

Usage

1
filterDepth(d, from, to)

Arguments

d

depth data.

from

Beginning of range.

to

End of range.

Details

For price levels with volume > 0 before the time range starts, timestamps will be set to the supplied from parameter.

For volume > 0 after the time range ends, timestamps will be set to the supplied to parameter and volume set to 0.

For example, the following data taken from priceLevelVolume for price level 243.29 shows the available volume through time at that price level between 00:52:37.686 and 03:28:49.621.

timestamp price volume side
2015-05-01 00:52:37.686 243.29 911500000 ask
2015-05-01 01:00:36.243 243.29 862200000 ask
2015-05-01 02:45:43.052 243.29 0 ask
2015-05-01 02:52:24.063 243.29 614700000 ask
2015-05-01 02:52:51.413 243.29 0 ask
2015-05-01 02:53:13.904 243.29 952300000 ask
2015-05-01 03:28:49.621 243.29 0 ask

applying filterDepth to this data for a time range beteen 02:45 and 03:00 will result in the following:

timestamp price volume side
2015-05-01 02:45:00.000 243.29 862200000 ask
2015-05-01 02:45:43.052 243.29 0 ask
2015-05-01 02:52:24.063 243.29 614700000 ask
2015-05-01 02:52:51.413 243.29 0 ask
2015-05-01 02:53:13.904 243.29 952300000 ask
2015-05-01 03:00:00.000 243.29 0 ask

Note that the timestamps at the begining and end of the table have been clamped to the specified range and the volume set to 0 at the end.

Value

Filtered depth data.

Author(s)

phil

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
# obtain price level volume for a 15 minute window.
filtered <- with(lob.data, filterDepth(depth,
    from=as.POSIXct("2015-05-01 02:45:00.000", tz="UTC"),
    to=as.POSIXct("2015-05-01 03:00:00.000", tz="UTC")))

# top 5 most active price levels during this 15 minute window.
head(sort(tapply(filtered$volume, filtered$price, length),
    decreasing=TRUE), 5)

# extract available volume for price level 233.78, then plot it.
level.233.78 <- filtered[filtered$price == 233.78, c("timestamp", "volume")]
plotTimeSeries(level.233.78$timestamp, level.233.78$volume*10^-8)

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