AlgoQuant, an integrated trading strategy research and backtesting system
com.numericalmethod.algoquant.execution.component.simulator.market.limitorder

## Class BernoulliPartialFillModel

• java.lang.Object
• com.numericalmethod.algoquant.execution.component.simulator.market.limitorder.BernoulliPartialFillModel
• All Implemented Interfaces:
LimitOrderFillModel

public class BernoulliPartialFillModel
extends Object
implements LimitOrderFillModel
This fill model is an extension of the BernoulliFillModel, with the enhancement that some orders may not be filled completely, i.e., filled partially. Let ask be the lowest ask price, bid the highest bid price, limit the limit price of the order, and p the execution probability. For a BUY order: $\mathbb{P}(execution) = \begin{cases} 1 & \text{ if } limit \geq ask \\ p & \text{ if } bid \leq limit \leq ask \\ 0 & \text{otherwise} \end{cases}$ For a SELL order: $\mathbb{P}(execution) = \begin{cases} 1 & \text{ if } limit \leq bid \\ p & \text{ if } bid \leq limit \leq ask \\ 0 & \text{otherwise} \end{cases}$ After determining whether an order gets executed at all, the quantity filled is determined as follows:
• Buy orders with a limit greater than the lowest ask price and sell orders with a limit smaller than or equal to the highest bid price will always be filled completely.
• Orders whose execution depends on the outcome of a Bernoulli trial will get filled by an amount drawn from $$U(0, qty)$$, i.e. the quantity will be uniformly distributed between 0 and the full quantity.
The price at which an order is executed is determined by $$\min(ask, limit)$$ for a BUY and $$\max(bid, limit)$$ for a SELL order.
• ### Constructor Summary

Constructors
Constructor and Description
BernoulliPartialFillModel(double p)
Constructs a Bernoulli partial fill model.
BernoulliPartialFillModel(double p, com.numericalmethod.suanshu.stats.random.rng.univariate.RandomLongGenerator rlg)
Constructs a Bernoulli partial fill model.
• ### Method Summary

All Methods
Modifier and Type Method and Description
Fill fillOrder(OrderBook depth, Order order)
• ### Methods inherited from class java.lang.Object

clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
• ### Constructor Detail

• #### BernoulliPartialFillModel

public BernoulliPartialFillModel(double p,
com.numericalmethod.suanshu.stats.random.rng.univariate.RandomLongGenerator rlg)
Constructs a Bernoulli partial fill model. The given random number generator must produce uniformly distributed values in the range [0, 1] for this class to operate as described.
Parameters:
p - an execution probability
rlg - a uniform random number generator used for the Bernoulli trial
• #### BernoulliPartialFillModel

public BernoulliPartialFillModel(double p)
Constructs a Bernoulli partial fill model.
Parameters:
p - an execution probability
• ### Method Detail

• #### fillOrder

public Fill fillOrder(OrderBook depth,
Order order)
Specified by:
fillOrder in interface LimitOrderFillModel