add.order

Share:

Description

Modify the order book.

Usage

1
2
3
4
5
add.order(object, price, size, type, time = NULL, id = NULL, status =
FALSE)
remove.order(object, id)
replace.order(object, id, size)
market.order(object, size, type)

Arguments

object

Object of class orderbook

price

of the order to be added.

size

the size of the order to be added. In the case of a replace.order it is the new size of the order. market.order takes this value to be the number of shares to be bought or sold.

type

the user can specify "bid" or "ask." For a market.order the user can specify "buy" or "sell."

time

of the order. If no time is specified the order book will automatically add 1000ms to the current time for the new order.

id

of the order. It must be unique. If no ID is specfied then add.order will automatically add 1 to the largest numeric ID and use it as the new ID.cancel.order and replace.order identify the order to remove/modify using the ID.

status

indicating whether or not the order belongs to the user.

Details

The user can add, remove, and replace orders from the order book. Additionally, the user can issue market orders. These functions are useful for simulating an order book.

Value

Return an object of class orderbook

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
library(orderbook)
filename <- system.file("extdata", "sample.txt",
                        package = "orderbook")

ob <- orderbook(file = filename)

ob <- add.order(ob, price = 123, size = 123, type = "BID", time = 1, id = 1)
ob <- replace.order(ob, 1, 100)
ob <- market.order(ob, 50, "SELL")
ob <- remove.order(ob, 1)