execute_order: Execute market order and return execution details.

Description Usage Arguments Value Author(s) Examples

View source: R/ic.R

Description

Execute a market order using limit order book data.

Usage

1
execute_order(lob.p, lob.q, Q)

Arguments

lob.p

A vector of limit order book snapshot (at a timestamp) of prices.

lob.q

A vector of limit order book snapshot (at a timestamp) of quantities at the quoted price.

Q

The execution quantity desired.

Value

A numeric vector containing:

Author(s)

Chirag Anand

Examples

 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
34
35
36
37
38
39
40
41
## Execution with lob.p and lob.q defined in the working
## environment.

lob.q <- matrix( nrow = 1, ncol = 4,
                 dimnames = list(c(),
                 c("bsq1", "bsq2",
                    "bsq3", "bsq4")))
lob.q[1, ] <- c(60, 70, 100, 50)  ## best sell quantity info

lob.p <- matrix( nrow = 1, ncol = 4 ,
                 dimnames = list(c(),
                 c("bsp1", "bsp2",
                    "bsp3", "bsp4")))
lob.p[1, ] <- c(101, 102, 103, 103) ## best sell price info
str(lob.p)
str(lob.q)

ans <- execute_order( lob.p, lob.q, Q = 200)

print(ans)

## Demonstration of IC functions using the market by price data
## of CINEMAX from the ic_CINEMAX dataset.
try(data( package = "ifrogs", "ic_CINEMAX"))
mbp <- cbind(as.data.frame(CINEMAX[1]),
             as.data.frame(CINEMAX[2]),
             as.data.frame(CINEMAX[3]),
             as.data.frame(CINEMAX[4]))

bbqSnap <- create_snapshot( mbp, type = "bbq")
head(bbqSnap)
lob.q <- bbqSnap[75, ] ##take any random timestamp
head(lob.q)

bbpSnap <- create_snapshot( mbp, type = "bbp")
head(bbqSnap)
lob.p <- bbpSnap[75, ] ## take any random timestamp
str(lob.p)
str(lob.q)
ans <- execute_order( lob.p, lob.q, Q = 1500)
print(ans)

igidrfrg/ifrogs documentation built on July 20, 2020, 2:02 p.m.