Quantitative Analysis, Risk Management, Modelling, Algo Trading, and Big Data Analysis

# Probability of a Limit Order Executing

Your algo strategy can assume that if the price of a given stock starts to increase (or fall) you chip-up (or chip-down). This rule can be programmed. If it works you leverage your position with a hope for higher gain. But let’s look at the same case scenario more from a statistical point of view which is also worth considering. This is a classical textbook example, often forgotten but useful in quick algo estimations.

Let’s say you have two limit orders outstanding on the same stock. One is placed at $\$21.50$and the second at$\$21.00$. Knowing that probability that Order 1 executes (event A) is $p_1$ and that Order 2 executes (event B) is $p_2$, $p_1>p_2$, and orders’ execution will take place within the same time-frame, consider the following probabilities:

Both or one of placed orders execute

Given $P(A)=p_1$ and $P(B)=p_2$, and
$$P(A|B) = 1$$ which simply says that if $B$ occurs (prices passes through lower value upwards) at $p_1\ne 0$, the probability that Order 1 and 2 will be executed is:
$$P(A\ \mbox{and}\ B) = P(A|B)P(B) = 1\times P(B) = p_2 \ .$$ That leads us to the case of:
$$P(A\ \mbox{or}\ B) = P(A)+P(B)-P(A\ \mbox{and}\ B) = p_1 + p_2 – p_2 = p_1 \ .$$

Order 2 executes given Order 1 executed

If the price of the stock falls and crossed $\$21.50$, the probability that Order 2 (of lower price) will also execute can be estimated using the principals of probability. Knowing that$P(A\ \mbox{and}\ B)=P(A|B)P(B)$we have: $$P(B\ \mbox{and}\ A) = P(B|A)P(A)$$ and at$P(B\ \mbox{and}\ A) = P(A\ \mbox{and}\ B)$what leads us to the solution: $$P(B|A) = \frac{P(B\ \mbox{and}\ A)}{P(A)} = \frac{p_2}{p_1} \ .$$ Remaining Practical Problem What is the best way to estimate$p_1$and$p_2$in any given trading conditions? • http://afekz.posterous.com/ Andrew Thomas-Woolf My stats knowledge is dangerously poor, but I have modeled things like this before. IMO factors worth pulling into a model: 1) Distance from inside BBO 2) Cumulative depth (volume) to your order 3) Historical order distributions 4) Recent signed trade There are other factors that I’d consider, e.g. current versus recent spread (order book refill probability – & what side?), but the above should cover a lot of ground. • NML Estimating p1 (or p2) is far harder than what you’ve solved here, right? Survival analysis? Or simply comparing the distance from the bid/ask to historal histogram of price evolution? • GiorgioG Hi Pawel, I am suggesting an idea to answer the question your topic ends with. I will take advantage of an approach which makes similar hypothesis as VaR basic analysis does. In doing that, I first determine the capital loss/gain based on known data and then the associated probability is computed. VaR concept does the opposite: a target probability is assumed and then the associated capital loss is computed. Herein below I do that for the price going downward scenario. Po is the current price at current time To. P1 is the price that can be reached with probability p1, (E1 event) P2 is the price that can be reached with probability p2, (E2 event) Po, P1 and P2 are given, p1 and p2 are to be computed. Time frame is 1 day. Example: Po =$22.50, P1 = $21.50, P2 =$21.00

Also daily price standard deviation, sd, must be known; let us suppose sd = 3%.
Supposing to hold one share, I compute the VaR based on price change associated to the event E1 and E2.

In case of E1 event, VaR is $21.50 –$22.50 = -$1.00 In case of E2 event, VaR is$21.00 – $22.50 = -$1.50

VaR(E1) = -$1.00 = alpha * sd *$22.50 = alpha * 0.03 * $22.50 = alpha *$0.675
VaR(E2) = -$1.50 = alpha * sd *$22.50 = alpha * 0.03 * $22.50 = alpha *$0.675

where alpha is a random variable having normal distribution.

E1: alpha = -1/0.675 = -1.48

corresponding to 6.9% probability as Prob(-inf .LT. alpha .LT. -1.48) = 6.9%

Similarly:

E2: alpha = -1.50/0.675 = -2.22, corresponding to 1.3% probability

p1 = 6.9%; p2 = 1.3%

Computing the probability of the event {E2|E1} requires to assume the current time is t1 and the current price is P1. If the price moves down to P2, the VaR is:

VaR({E2|E1}) = $21.00 –$21.50 = -$0.50 = alpha * sd *$21.50 = alpha * 0.645

alpha = -0.50/0.645 = -0.775

which corresponds to 22.1% probability for the event {E2|E1}

Normal distribution values can be found (for example) at:

http://www.mathsisfun.com/data/standard-normal-distribution-table.html

• GiorgioG

An immediate application is to calculate the chances that within
the current day the support or resistance prices may be reached.
Resistance and support prices are calculated as:

#average
VM = (H+L+C)/3

#First Level support and resistance:
S1 = (2*VM)-H
R1 = (2*VM)-L

#Second Level support and resistance:
S2 = VM – R1 + S1
R2 = VM – S1 + R1

#Third Level support and resistance:
S3 = S2 – H + L
R3 = R2 + H – L

Be N the current daily price at the new day opening and suppose
to know the daily standard deviation (sigma).
Here is a simple R language routine which computes resistance and
support prices with their probabilities to occur within the day.
(I hope the printout formatting to be correct).

# R language routine:

H <- 23.00 # high

L <- 21.00 # low

C <- 21.70 # closure

N <- 22.00 # current price (now)

sigma <- 0.03 # standard deviation

VM <- (H+L+C)/3 # average

S <- c((2*VM)-H, VM-R1+S1, S2-H+L) # supports

R <- c((2*VM)-L, VM-S1+R1, R2+H-L) # resistances

alpha <- function(SR, N, sigma) {(SR-N)/(sigma*N)} # the alpha standard normal distributed random variable

prob <- function(a) {if(a < 0) y = pnorm(a, lower.tail=TRUE) else y = pnorm(a, lower.tail=FALSE); y} # probability

as <- c(alpha(S[1],N,sigma),alpha(S[2],N,sigma),alpha(S[3],N,sigma))

ar <- c(alpha(R[1],N,sigma),alpha(R[2],N,sigma),alpha(R[3],N,sigma))

ProbS <- c(prob(as[1]),prob(as[2]),prob(as[3]))

ProbR <- c(prob(ar[1]),prob(ar[2]),prob(ar[3]))

F1 <- data.frame(R,ProbR)

F2 <- data.frame(S,ProbS)

F1

F2

• http://www.bearcave.com Ian Kaplan