Learn R Programming

orderbook (version 1.03)

view.trade.function: view.trade

Description

View the orderbook object when a particular trade happens.

Usage

view.trade(object, tradenum) next.trade(object) previous.trade(object) midpoint.return(object, tradenum, time)

Arguments

object
Object of class orderbook
tradenum
the trade we want to view.
time
Specifies the number of seconds after the trade to calculate the midpoint return for. Can also be a vector of times.

Value

Return an object of class orderbook. view.trade and midpoint.return print information to the terminal about the trade and midpoint return, respectively.

Details

The orderbook object internally keeps track of the the trades it has read from the data file. The view.trade function returns information about the nth trade. This function can only view trades that occurred prior to the current order.book time.

previous.trade sets the state of the orderbook to the first trade to have happened before the current time. next.trade sets the state to the orderbook at the very next trade to have happened after the current time.

midpoint.return calculates the midpoint return for a trade a specified number of seconds into the future.

Examples

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

ob <- orderbook(file = filename)
ob <- next.trade(ob)
view.trade(ob, 1)
midpoint.return(ob, 1, c(5, 10))

Run the code above in your browser using DataLab