Description Usage Arguments Value Author(s) Examples
Execute a market order using limit order book data.
1 | execute_order(lob.p, lob.q, Q)
|
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. |
A numeric vector containing:
q: quantity executed
p: price at which the order was fully/ partially executed
partial: whether it was a partial execution (0 or 1)
Chirag Anand
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)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.