Learn R Programming

orderbook (version 1.03)

plot.function: plot

Description

Plotting the orderbook.

Usage

"plot"(x, bounds = 0.1, n = 10, type = "n")

Arguments

x
Object of class orderbook
bounds
Percentage above and below the midpoint to determine the y limits.
n
Number of price levels to plot.
type
Either "n", "sd", "o", or "s".

Value

Prints a Trellis object.

Details

This function plots the orderbook. n is only needed for type = "s", which plots the best bid vs. the best ask, and then the second best bid vs. the second best ask, for n bids and asks. If type = "n" then the orderbook will be plotted with price levels on the y-axis, and size on the x-axis. type = "o" is similar, except the number of orders for each price level are plotted. type = "sd" makes a plot that shows the supply and demand curves of the order book.

Examples

Run this code
library(orderbook)
filename <- system.file("extdata", "sample.txt",
                        package = "orderbook")

ob <- orderbook(file = filename)
ob <- read.orders(ob, n = 1000)
plot(ob)
plot(ob, type = "o")
plot(ob, type = "sd")
plot(ob, type = "s")

Run the code above in your browser using DataLab