Description Usage Arguments Details Author(s) Examples
View source: R/visualisation.R
Produces a visualisation of the limit order book depth through time.
1 2 3 4 5 |
depth |
The order book |
spread |
Spread to overlay obtained from |
trades |
|
show.mp |
If True, spread will be summarised as midprice. |
show.all.depth |
If True, show resting (and never hit) limit orders. |
col.bias |
1 = uniform colour spectrum. 0.25 = bias toward 0.25 (more red less blue). <= 0 enables logarithmic scaling. |
start.time |
Plot depth from this time onward. |
end.time |
Plot depth up until this time. |
price.from |
Plot depth with price levels >= this value. |
price.to |
Plot depth with price levels <= this value. |
volume.from |
Plot depth with volume >= this value relevant to volume.scale |
volume.to |
Plot depth with volume <= this value relevant to volume scale. |
volume.scale |
Volume scale factor. |
The available volume at each price level is colour coded according to the range of volume at all price levels. The colour coding follows the visible spectrum, such that larger amounts of volume appear "hotter" than smaller amounts, where cold = blue, hot = red.
Since the distribution of limit order size exponentially decays, it can be difficult to visually differentiate: most values will appear to be blue. The function provides price, volume and a colour bias range to overcome this.
phil
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | # bid/ask spread.
spread <- with(lob.data, getSpread(depth.summary))
## Not run:
# plot all depth levels, rescaling the volume by 10^-8.
# produce 2 plots side-by-side: second plot contains depth levels with > 50
# units of volume.
p1 <- with(lob.data, plotPriceLevels(depth, spread,
col.bias=0.1,
volume.scale=10^-8))
p2 <- with(lob.data, plotPriceLevels(depth, spread,
col.bias=0.1,
volume.scale=10^-8,
volume.from=50))
library(grid)
pushViewport(viewport(layout=grid.layout(1, 2)))
print(p1, vp=viewport(layout.pos.row=1, layout.pos.col=1))
print(p2, vp=viewport(layout.pos.row=1, layout.pos.col=2))
## End(Not run)
# zoom into 1 hour of activity, show the spread and directional trades.
with(lob.data, plotPriceLevels(depth, spread, trades,
start.time=as.POSIXct("2015-05-01 03:25:00.000", tz="UTC"),
end.time=as.POSIXct("2015-05-01 04:25:00.000", tz="UTC"),
volume.scale=10^-8))
# zoom in to 15 minutes of activity, show the bid/ask midprice.
with(lob.data, plotPriceLevels(depth, spread,
show.mp=FALSE,
start.time=as.POSIXct("2015-05-01 03:30:00.000", tz="UTC"),
end.time=as.POSIXct("2015-05-01 03:45:00.000", tz="UTC")))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.