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

## Class BernoulliFillModel

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

public class BernoulliFillModel
extends Object
implements LimitOrderFillModel
In this fill model, orders are executed either always, never or according to the outcome of a Bernoulli trial, depending on the limit of the order. 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}$ 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
BernoulliFillModel(double p)
Constructs a Bernoulli fill model.
BernoulliFillModel(double p, com.numericalmethod.suanshu.stats.random.rng.univariate.RandomLongGenerator rlg)
Constructs a Bernoulli 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

• #### BernoulliFillModel

public BernoulliFillModel(double p,
com.numericalmethod.suanshu.stats.random.rng.univariate.RandomLongGenerator rlg)
Constructs a Bernoulli 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
• #### BernoulliFillModel

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

• #### fillOrder

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